flutter 动态申请权限

    

 

https://pub.flutter-io.cn/packages/permission_handler 

https://www.jianshu.com/p/fa68876fbdfd

  Future requestPermission() async {
    // 申请权限
    Map<PermissionGroup, PermissionStatus> permissions =
        await PermissionHandler().requestPermissions([PermissionGroup.storage]);

    // 申请结果
    PermissionStatus permission = await PermissionHandler()
        .checkPermissionStatus(PermissionGroup.storage);

    if (permission == PermissionStatus.granted) {
      print("权限申请通过");
    } else {
      print("权限申请通过");
    }
  }
} 

 

posted @ 2019-05-24 11:57  富坚老贼  阅读(6093)  评论(0编辑  收藏  举报