initMethod method
Future<void>
initMethod(
- BuildContext context, {
- bool showNativeUI = true,
- Widget? customWidget()?,
override
Initializes the method channel and listens to native method calls.
context: TheBuildContextused 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);
}
}
});
}