Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,10 @@ void main() {
/// `setContext` during the app initialization.
WidgetsFlutterBinding.ensureInitialized();

String writeKey;
if(Platform.isAndroid){
writeKey = "ANDROID_WRITE_KEY";
} else{ //iOS
writeKey = "IOS_WRITE_KEY";
}

Segment.config(
options: SegmentConfig(
writeKey: 'YOUR_WRITE_KEY_GOES_HERE',
androidWriteKey: 'YOUR_ANDROID_WRITE_KEY_GOES_HERE',
iosWriteKey: 'YOUR_IOS_WRITE_KEY_GOES_HERE',
trackApplicationLifecycleEvents: false,
amplitudeIntegrationEnabled: false,
debug: false,
Expand Down
3 changes: 2 additions & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ void main() {

Segment.config(
options: SegmentConfig(
writeKey: 'YOUR_WRITE_KEY_GOES_HERE',
androidWriteKey: 'YOUR_ANDROID_WRITE_KEY_GOES_HERE',
iosWriteKey: 'YOUR_IOS_WRITE_KEY_GOES_HERE',
trackApplicationLifecycleEvents: false,
),
);
Expand Down
27 changes: 24 additions & 3 deletions lib/src/segment_config.dart
Original file line number Diff line number Diff line change
@@ -1,18 +1,39 @@

import 'dart:io';

class SegmentConfig {

SegmentConfig({
required this.writeKey,
this.androidWriteKey,
this.iosWriteKey,
this.trackApplicationLifecycleEvents = false,
this.amplitudeIntegrationEnabled = false,
this.appsflyerIntegrationEnabled = false,
this.debug = false,
});
}) {
if (Platform.isIOS) {
assert(iosWriteKey != null, 'Provide an right Write Key to IOS platform');
} else if (Platform.isAndroid) {
assert(androidWriteKey != null, 'Provide an right Write Key to Android platform');
}
}

final String writeKey;
final bool trackApplicationLifecycleEvents;

final bool amplitudeIntegrationEnabled;

final bool appsflyerIntegrationEnabled;

final bool debug;

final String? androidWriteKey;

final String? iosWriteKey;

String get writeKey {
return Platform.isIOS ? iosWriteKey! : androidWriteKey!;
}

Map<String, dynamic> toMap() {
return {
'writeKey': writeKey,
Expand Down