demo 测试成功,
import 'package:permission/permission.dart';
Future requirePermission()async {
await Permission.requestPermissions([PermissionName.Storage]);
return 'my_db.db';
}
Future getPath(String dbName)async{
fileDirectory = (await getExternalStorageDirectory()).path;
}
Future getDataBase(String dbName) async {
await requirePermission().then((x)=>getPath(x));
....
....
import 'package:permission/permission.dart';
# Android
List<Permissions> permissions = await Permission.getPermissionStatus([PermissionName.Calendar, PermissionName.Camera]);
List<PermissionName> permissionNames = await Permission.requestPermissions([PermissionName.Calendar, PermissionName.Camera]);
# iOS
PermissionStatus permissionStatus = await Permission.getSinglePermissionStatus(PermissionName.Calendar);
PermissionStatus permissionStatus = await Permission.requestSinglePermission(PermissionName.Calendar);
# Both
Permission.openSettings;
app - src - debug/main/profile / AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="cn.qwert.flutter_study">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.MODE_WORLD_READABLE"/>
<uses-permission android:name="android.permission.MODE_WORLD_WRITEABLE"/>
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
.....
.....
.....
.....