initMethod method

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

Initializes the method channel and listens to native method calls.

  • context: The BuildContext used for dialogs.
  • showNativeUI: Determines if the native UI dialog should be shown.
  • customWidget: A function that returns a custom widget for the dialog.

Implementation

@override
Future<void> initMethod(
  BuildContext context, {
  bool showNativeUI = true,
  Widget? Function(Map<String, dynamic> response)? customWidget,
}) async {
  WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
    this.context = context;
    _listenToNativeMethod();
    final appUpdateResponse = await _check(showNativeUI);
    if (customWidget != null) {
      final widget = customWidget.call(appUpdateResponse);

      /// Displays a custom UI dialog.
      if (!showNativeUI && widget != null) {
        _alertDialog(widget);
      }
    }
  });
}