initX5 static method

Future<void> initX5({
  1. OnNeedPermissionCallback? needPermissionCallback,
})

Implementation

static Future<void> initX5({OnNeedPermissionCallback? needPermissionCallback}) async {
  if (defaultTargetPlatform == TargetPlatform.android) {
    _channel.setMethodCallHandler((MethodCall call) {
      if (call.method == 'needPermission') {
        try {
          List<dynamic> args = call.arguments["permissions"];
          List<String> permissions = [];
          for (final dynamic item in args) {
            permissions.add(item.toString());
          }
          // print('22222 $permissions $needPermissionCallback');
          needPermissionCallback?.call(permissions);
        } catch (e) {
          print('error $e');
        }
      }
      return Future.value(true);
    });

    await _channel.invokeMethod('initX5', {});
  }
}