initMethod method

  1. @override
Future<void> initMethod(
  1. BuildContext context, {
  2. required String appId,
  3. bool showNativeUI = false,
  4. Widget? customWidget(
    1. Map<String, dynamic> response
    )?,
})
override

context is required to show dialog isShowNative is used to show customWidget isShowNative turn it off if you want to show your customWidget you can show your customWidget ui

Implementation

@override
Future<void> initMethod(
  BuildContext context, {
  required String appId,
  bool showNativeUI = false,
  Widget? Function(Map<String, dynamic> response)? customWidget,
}) async {
  WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
    this.context = context;
    final result = await methodChannel.invokeMethod(
        'setApplicationID', {"AppId": appId, "showNativeUI": showNativeUI});
    if (result) {
      _listenToNativeMethod();
      final appUpdateResponse = await _check();
      if (customWidget != null) {
        final widget = customWidget.call(appUpdateResponse);

        ///custom ui dialog
        if (!showNativeUI && widget != null) {
          _alertDialog(widget);
        }
      }
    }
  });
}