I'm working on an application where the user is only really working from a single album. I don't want to display all of the users pictures while they are in the app, just the ones that they will be dealing with. I'm using photo_manager and it's great for getting all of the images, but I can't find a way to get just one album - all of the tutorials I've found for working with photo_manager just pull all the images from the phone. filteroptionsgroup seemed promising but doesn't provide a way to identify an album via string. I can tell AssetEntity gets the name of albums but I don't know how to compare it. Here's the code so far:
class gallery extends StatefulWidget {
gallery({Key? key}) : super(key: key);
@override
State<gallery> createState() => _galleryState();
}
class _galleryState extends State<gallery> {
List<AssetEntity> assets = [];
_fetchAssests() async {
final FilterOptionGroup filter = new FilterOptionGroup();
final albums = await PhotoManager.getAssetPathList(
type: RequestType.image, filterOption: filter);
// this is where I am lost, I don't know how to get a specific album.
final wordpicsalbum = albums.first;
final recentAssets = await wordpicsalbum.getAssetListRange(
start: 0,
end: 50000,
);
setState(() {
assets = recentAssets;
});
}
@override
void initState() {
_fetchAssests();
super.initState();
}
Formatting is weird between my setup in vscode and what SO expects, sorry about that.
Have you tried using AssetPathEntity instead of AssetEntity?
Get albums/folders (AssetPathEntity) Albums or folders are abstracted as the AssetPathEntity class. It represent a bucket in the MediaStore on Android, and the PHAssetCollection object on iOS/macOS. To get all of them:
See getAssetPathList for more detail.