|
|
@@ -35,22 +35,35 @@ class AudioPickerController extends BaseController {
|
|
|
@override
|
|
|
void onReady() async {
|
|
|
super.onReady();
|
|
|
+ bool isGrant = await checkFilePermission();
|
|
|
+ if (!isGrant) {
|
|
|
+ _onRecordPermissionDenied();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ _initAudioPathList();
|
|
|
+ }
|
|
|
+
|
|
|
+ void _initAudioPathList() async {
|
|
|
+ currentPath = await initPathEntity();
|
|
|
+ totalCount = await currentPath?.assetCountAsync ?? 0;
|
|
|
+ requestList(0, limit, isClearAll: true);
|
|
|
+ }
|
|
|
+
|
|
|
+ Future<bool> checkFilePermission({void Function()? requestPermission}) async {
|
|
|
if (!await AudioPickerUtils.hasPermission()) {
|
|
|
bool isAllow = await _showRequestPermissionDialog();
|
|
|
if (isAllow) {
|
|
|
bool permission = await AudioPickerUtils.requestPermissionExtend();
|
|
|
if (!permission) {
|
|
|
- _onRecordPermissionDenied();
|
|
|
- return;
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ requestPermission?.call();
|
|
|
}
|
|
|
} else {
|
|
|
- _onRecordPermissionDenied();
|
|
|
- return;
|
|
|
+ return false;
|
|
|
}
|
|
|
}
|
|
|
- currentPath = await initPathEntity();
|
|
|
- totalCount = await currentPath?.assetCountAsync ?? 0;
|
|
|
- requestList(0, limit, isClearAll: true);
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
_onRecordPermissionDenied() {
|
|
|
@@ -167,7 +180,14 @@ class AudioPickerController extends BaseController {
|
|
|
requestList(audioList.length, limit);
|
|
|
}
|
|
|
|
|
|
- void pickSystemFile() {
|
|
|
+ void pickSystemFile() async {
|
|
|
+ bool isGrant = await checkFilePermission(requestPermission: () {
|
|
|
+ _initAudioPathList();
|
|
|
+ });
|
|
|
+ if (!isGrant) {
|
|
|
+ _onRecordPermissionDenied();
|
|
|
+ return;
|
|
|
+ }
|
|
|
FileUploadCheckHelper.choicePlatformLocalFileAndCreateOrder(
|
|
|
choiceSuccessCallback: () {
|
|
|
Get.back();
|