in example/lib/main.dart [40:86]
Future<void> initPlatformState() async {
String message;
String object;
// Platform messages may fail, so we use a try/catch PlatformException.
// We also handle the message potentially returning null.
try {
await dotenv.load(fileName: ".env");
await _confidenceFlutterSdkPlugin.setup(dotenv.env["API_KEY"]!);
await _confidenceFlutterSdkPlugin.putAllContext({
"targeting_key": "random",
"my_bool": false,
"my_int": 1,
"my_double": 1.1,
"my_map": {"key": "value"},
"my_list": ["value1", "value2"]
});
await _confidenceFlutterSdkPlugin.fetchAndActivate();
object =
(_confidenceFlutterSdkPlugin.getObject("hawkflag", <String, dynamic>{})).toString();
message =
(_confidenceFlutterSdkPlugin.getString("ludwigs-new-test-flag.struct-key.string-key", "0"));
final data = {
'screen': 'home',
"my_bool": false,
"my_int": 1,
"my_double": 1.1,
"my_map": {"key": "value"},
"my_list": ["value1", "value2"]
};
_confidenceFlutterSdkPlugin.track("navigate", data);
_confidenceFlutterSdkPlugin.flush();
} on PlatformException {
message = 'Failed to get platform version.';
object = 'Failed to get object.';
}
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted) return;
setState(() {
_message = message;
_object = object;
});
initCompleter.complete();
}