fetchAssetsFor method
void
fetchAssetsFor(
- AssetPathEntity album
Implementation
void fetchAssetsFor(AssetPathEntity album) async {
albumNotifier.value = albumNotifier.value.copyWith(data: album);
final state = await PhotoManager.requestPermissionExtend();
final assetCount = await album.assetCountAsync;
if (state == PermissionState.authorized) {
try {
final entities =
await album.getAssetListRange(start: 0, end: assetCount);
entitiesNotifier.value =
BaseStateGallery(data: entities, hasPermission: true);
recentEntitiesNotifier.value =
BaseStateGallery(data: entities, hasPermission: true);
} catch (e) {
entitiesNotifier.value = BaseStateGallery(
hasPermission: true,
hasError: true,
error: e.toString(),
);
}
} else {
entitiesNotifier.value = const BaseStateGallery(
hasError: true,
error: 'Permission denied',
);
}
}