handleMethodCall method

Future handleMethodCall(
  1. MethodCall call
)

Handles platform-channel calls from the Dart API.

Implementation

Future<dynamic> handleMethodCall(MethodCall call) async {
  switch (call.method) {
    case 'restartCapability':
      return <String, Object?>{
        'fullProcessRestart': false,
        'flutterEngineRestart': false,
        'notificationFallback': false,
        'engineRestartConfigured': false,
        'platformDefaultMode': 'platformDefault',
        'reason': 'Web restart reloads the current page.',
      };
    case 'restartApp':
      final args = call.arguments as Map?;
      final mode = args?['mode'] as String? ?? 'platformDefault';
      if (mode != 'platformDefault') {
        throw PlatformException(
          code: 'UNSUPPORTED_RESTART_MODE',
          message: "Restart mode '$mode' is not supported on web.",
        );
      }

      final webOrigin = args?['webOrigin'] as String?;
      restart(webOrigin);
      if (args?['structuredResult'] == true) {
        return <String, Object?>{
          'success': true,
          'mode': 'platformDefault',
        };
      }
      return 'ok';
    default:
      throw PlatformException(
        code: 'Unimplemented',
        message: '${call.method} is not implemented on the web platform.',
      );
  }
}