@@ -29,16 +29,18 @@ class _MyAppState extends State<MyApp> {
2929 OptimizelyDecideOption .includeReasons,
3030 OptimizelyDecideOption .excludeVariables
3131 };
32+
3233 final customLogger = CustomLogger ();
3334
34- var flutterSDK = OptimizelyFlutterSdk ("X9mZd2WDywaUL9hZXyh9A" ,
35- datafilePeriodicDownloadInterval: 10 * 60 ,
36- eventOptions: const EventOptions (
37- batchSize: 1 , timeInterval: 60 , maxQueueSize: 10000 ),
38- defaultLogLevel: OptimizelyLogLevel .debug,
39- defaultDecideOptions: defaultOptions,
40- logger: customLogger,
41- );
35+ var flutterSDK = OptimizelyFlutterSdk (
36+ "X9mZd2WDywaUL9hZXyh9A" ,
37+ datafilePeriodicDownloadInterval: 10 * 60 ,
38+ eventOptions: const EventOptions (
39+ batchSize: 1 , timeInterval: 60 , maxQueueSize: 10000 ),
40+ defaultLogLevel: OptimizelyLogLevel .debug,
41+ defaultDecideOptions: defaultOptions,
42+ logger: customLogger,
43+ );
4244 var response = await flutterSDK.initializeClient ();
4345
4446 setState (() {
@@ -60,7 +62,7 @@ class _MyAppState extends State<MyApp> {
6062 "stringValue" : "121"
6163 });
6264
63- // To add decide listener
65+ // Add decide listener
6466 var decideListenerId =
6567 await flutterSDK.addDecisionNotificationListener ((notification) {
6668 print ("Parsed decision event ...................." );
@@ -73,17 +75,13 @@ class _MyAppState extends State<MyApp> {
7375 Set <OptimizelyDecideOption > options = {
7476 OptimizelyDecideOption .ignoreUserProfileService,
7577 };
78+
7679 // Decide call
7780 var decideResponse = await userContext.decide ('flag1' , options);
7881 uiResponse +=
7982 "\n First decide call variationKey: ${decideResponse .decision !.variationKey }" ;
8083
81- // should return following response without forced decision
82- // flagKey: flag1
83- // ruleKey: default-rollout-7371-20896892800
84- // variationKey: off
85-
86- // Setting forced decision
84+ // Set forced decision
8785 await userContext.setForcedDecision (
8886 OptimizelyDecisionContext ("flag1" , "flag1_experiment" ),
8987 OptimizelyForcedDecision ("variation_a" ));
@@ -93,11 +91,6 @@ class _MyAppState extends State<MyApp> {
9391 uiResponse +=
9492 "\n Second decide call variationKey: ${decideResponse .decision !.variationKey }" ;
9593
96- // should return following response with forced decision
97- // flagKey: flag1
98- // ruleKey: flag1_experiment
99- // variationKey: variation_a
100-
10194 // removing forced decision
10295 await userContext.removeForcedDecision (
10396 OptimizelyDecisionContext ("flag1" , "flag1_experiment" ));
@@ -111,14 +104,6 @@ class _MyAppState extends State<MyApp> {
111104 uiResponse = uiResponse;
112105 });
113106
114- // should return original response without forced decision
115- // flagKey: flag1
116- // ruleKey: default-rollout-7371-20896892800
117- // variationKey: off
118-
119- // To cancel decide listener
120- // await flutterSDK.removeNotificationListener(decideListenerId);
121-
122107 // To add track listener
123108 var trackListenerID =
124109 await flutterSDK.addTrackNotificationListener ((notification) {
@@ -149,10 +134,7 @@ class _MyAppState extends State<MyApp> {
149134 {"name" : "Product A" , "quantity" : 2 , "price" : 49.99 },
150135 {"name" : "Product B" , "quantity" : 1 , "price" : 50.00 }
151136 ],
152- "metadata" : {
153- "source" : "mobile_app" ,
154- "platform" : "ios"
155- }
137+ "metadata" : {"source" : "mobile_app" , "platform" : "ios" }
156138 });
157139
158140 // To cancel track listener
0 commit comments