flutter_toolkit

path_provider

import 'package:flutter_toolkit/path_provider.dart';

APP内部文件路径

Directory dir = await PathProvider.getInternalFilesDirectory;

APP内部缓存路径

Directory dir = await PathProvider.getInternalCacheDirectory;

APP外部文件路径

Directory dir = await PathProvider.getExternalFilesDirectory;

APP外部缓存路径

Directory dir = await PathProvider.getExternalCacheDirectory;

APP外部资源路径

Directory dir = await PathProvider.getExternalMusicDirectory;
Directory dir = await PathProvider.getExternalMoviesDirectory;
Directory dir = await PathProvider.getExternalPicturesDirectory;
Directory dir = await PathProvider.getExternalDCIMDirectory;
Directory dir = await PathProvider.getExternalDownloadsDirectory;
Directory dir = await PathProvider.getExternalDocumentsDirectory;

外部公共根目录

Directory dir = await PathProvider.getExternalPublicRootDirectory;

外部公共资源路径

Directory dir = await PathProvider.getExternalPublicMusicDirectory;
Directory dir = await PathProvider.getExternalPublicMoviesDirectory;
Directory dir = await PathProvider.getExternalPublicPicturesDirectory;
Directory dir = await PathProvider.getExternalPublicDCIMDirectory;
Directory dir = await PathProvider.getExternalPublicDownloadsDirectory;
Directory dir = await PathProvider.getExternalPublicDocumentsDirectory;

PackageInfo

import 'package:flutter_toolkit/package_info.dart';

版本信息

PackageInfo packageInfo = await PackageInfo.getPackageInfo;    

版本号

int code = await PackageInfo.getVersionCode;

版本名称

String versionName = await PackageInfo.getVersionName;

包名

String packageName = await PackageInfo.getPackageName;

GPSLocation

import 'package:flutter_toolkit/gps_location.dart';

获取当前GPS定位信息

GPSLocation gpsLocation = await GPSLocation.getCurrentGPSLocation;

获取最后GPS定位信息

GPSLocation gpsLocation = await GPSLocation.getLastKnownGPSLocation;

获取持续GPS定位信息

GPSLocation.getGPSLocationStream.listen((gpsLocation){
    ......
});

PermissionHandler

import 'package:flutter_toolkit/permission.dart'
group:
      Permission.permission_group_calendar;
      Permission.permission_group_camera;
      Permission.permission_group_contacts;
      Permission.permission_group_location;
      Permission.permission_group_microphone;
      Permission.permission_group_phone;
      Permission.permission_group_sensors;
      Permission.permission_group_sms;
      Permission.permission_group_storage;
      Permission.permission_group_ignore_battery_optimizations;
      Permission.permission_group_system_alert_window;
      Permission.permission_group_request_install_packages; 

checkPermissionsStatus

int status = await Permission.checkPermissionsStatus(group);
if(status == 1){
    //granted
}else{
    //denied
}

requestPermission && requestPermissions

int status = await Permission.checkPermission(group);    
if(status == 1){
    //granted
}else{
    //denied
}

Map<int,int> map = await Permission.checkPermissions([group1`,gropu2,...groupn]);

shouldShowRequestPermissionRationale

bool should = await Permission.shouldShowRequestPermissionRationale(group);

openAppSetting

bool open = await Permission.openAppSetting();

Libraries

camera_preview
gps_location
package_info
path_provider
permission
video_thumbnail