I try to code some gallery picker function from Youtube but I want to ask for permission for storage to user ,when I code below code, I get into the app info why I get there and how to fix it
import 'package:photo_manager/photo_manager.dart';
class MediaServices {
Future loadAlbum(RequestType requestType) async {
var permission = await PhotoManager.requestPermissionExtend();
List<AssetPathEntity> albumList = [];
if (permission == true) {
albumList = await PhotoManager.getAssetPathList(
type: requestType,
);
} else {
PhotoManager.openSetting();
}
return albumList;
}
Future loadAssets(AssetPathEntity selectedAlbum) async {
// ignore: deprecated_member_use
List<AssetEntity> assetList = await selectedAlbum.getAssetListRange(
// ignore: deprecated_member_use
start: 0, end: selectedAlbum.assetCount);
return assetList;
}
}
2
Answers
Finally I figured out that I have missed something in my code . And I watched video agian and I realized it.I have to put "if(permission.isAuth==true)" instead of this one "if(permission==true)".
Instead of this
I have to use this one
Use Permission handler plugin from pub.dev, this is similar answer
for android add these lines in Androidmainfest.xml file
for iOS add below code in info.plist file
modify below code accordingly.