Flutter中onRequestPermissionResult()的替代方法

时间:2018-12-20 13:07:10

标签: flutter flutter-dependencies

我正在Flutter中请求运行时权限。如何处理Flutter中的权限结果。众所周知,在Android中有onRequestPermissionsResult()。什么是Flutter中的替代方法。

1 个答案:

答案 0 :(得分:0)

使用插件simple_permissions

它可以检查,请求并获得回调权限

示例中的示例代码

requestPermission() async {
    final res = await SimplePermissions.requestPermission(permission);
    print("permission request result is " + res.toString());
  }

  checkPermission() async {
    bool res = await SimplePermissions.checkPermission(permission);
    print("permission is " + res.toString());
  }

  getPermissionStatus() async {
    final res = await SimplePermissions.getPermissionStatus(permission);
    print("permission status is " + res.toString());
  }