requestPermission method

FutureOr<bool> requestPermission (
  1. String permission
)

Android Check has permission Permission like android.permission.READ_PHONE_STATE

Implementation

static FutureOr<bool> requestPermission(String permission) async {
  if (!_isAndroid()) {
    return false;
  }

  var requestCode =
      (await _channel.invokeMethod('requestPermissions', <String, dynamic>{
    'permissions': [permission]
  })) as int;
  if (requestCode == null) {
    throw "Invalid permission request: $permission - enable Drifter.debug see more detail";
  }
  var c = Completer<bool>();
  _callbacks[requestCode] = (MethodCall call) {
    try {
      c.complete((call.arguments as Map)['result'] == true);
    } catch (e, st) {
      c.completeError(e, st);
    }
  };
  return c.future;
}