initialize method

  1. @override
Future<void> initialize(
  1. BuildContext context, {
  2. bool shakeGestureEnable = true,
  3. Map<String, dynamic> options = const {},
  4. required dynamic onRemarkResponse(
    1. Map<String, dynamic>
    ),
})
override

Initializes the AppsOnAir AppRemark SDK.

  • context: Required to show a dialog or overlay.
  • shakeGestureEnable: Determines whether the shake gesture is enabled for feedback (default is true).
  • options: Additional configuration options for the SDK.

Implementation

@override
Future<void> initialize(
  BuildContext context, {
  bool shakeGestureEnable = true,
  Map<String, dynamic> options = const {},
  required Function(Map<String, dynamic>) onRemarkResponse,
}) async {
  WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
    this.context = context;
    _listenToNativeMethod();

    // Setup EventChannel listener
    _setupEventChannelListener(onRemarkResponse);

    try {
      final result = await methodChannel.invokeMethod('initializeAppRemark', {
        "shakeGestureEnable": shakeGestureEnable,
        'options': options,
      });
      if (result is! bool) {
        log("AppRemark : ${result["error"]}");
      }
    } on PlatformException catch (e) {
      debugPrint(
          'Failed to initialize AppsOnAir AppRemarkSDK! ${e.message ?? ''}');
    }
  });
}