restorableAssetsPicker method
- BuildContext context, {
- Key? key,
- AssetPickerPageRouteBuilder<
List< ? pageRouteBuilder,AssetEntity> > - dynamic onPermissionDenied(
- BuildContext context,
- String delegateDescription
- InstaAssetCropDelegate cropDelegate = const InstaAssetCropDelegate(),
- int gridCount = _kGridCount,
- required DefaultAssetPickerProvider provider,
- ThemeData? pickerTheme,
- AssetPickerTextDelegate? textDelegate,
- String? title,
- bool closeOnComplete = false,
- required dynamic onCompleted(
- Stream<
InstaAssetsExportDetails> exportDetails
- Stream<
- Widget loadingIndicatorBuilder(
- BuildContext context,
- bool isAssetsEmpty
- LimitedPermissionOverlayPredicate? limitedPermissionOverlayPredicate,
- Widget? specialItemBuilder(
- BuildContext context,
- AssetPathEntity? path,
- int length
- SpecialItemPosition? specialItemPosition,
- InstaPickerActionsBuilder? actionsBuilder,
When using restorableAssetsPicker
function, the picker's state is preserved even after pop
⚠️ InstaAssetPicker and provider
must be disposed manually
Set useRootNavigator
to determine
whether the picker route should use the root Navigator.
By extending the AssetPickerPageRoute
, users can customize the route
and use it with the pageRouteBuilder
.
Set onPermissionDenied
to manually handle the denied permission error.
The default behavior is to open a ScaffoldMessenger.
Crop options
- Set
cropDelegate
to customize the display and export of crops.
Those arguments are used by InstaAssetPickerBuilder
-
Set
provider
of type DefaultAssetPickerProvider to specifies picker options. This argument is required. -
Set
gridCount
to specifies the number of assets in the cross axis. Defaults to_kGridCount
, like instagram. -
Set
pickerTheme
to specifies the theme to apply to the picker. It is by default initialized with theprimaryColor
of the context theme. -
Set
textDelegate
to specifies the language to apply to the picker. Default is the locale language from the context. -
Set
title
to specifies the text title in the picker AppBar. -
Set
closeOnComplete
to specifies if the picker should be closed after assets selection confirmation. -
The
onCompleted
callback is called when the assets selection is confirmed. It will as argument a Stream with exportation details InstaAssetsExportDetails. -
Set
loadingIndicatorBuilder
to specifies the loader indicator to display in the picker. -
Set
limitedPermissionOverlayPredicate
to specifies if the limited permission overlay should be displayed. -
Set
specialItemPosition
to allows users to set a special item in the picker with several positions. Since the grid view is reversed, SpecialItemPosition.prepend will be at the top and SpecialItemPosition.append at the bottom. Defaults to SpecialItemPosition.none. -
Set
specialItemBuilder
to specifies Widget for the the special item. -
Set
actionsBuilder
function to specifies the Widgets to display on top of the assets grid view. Default is unselect all assets button.
Implementation
Future<List<AssetEntity>?> restorableAssetsPicker(
BuildContext context, {
Key? key,
bool useRootNavigator = true,
AssetPickerPageRouteBuilder<List<AssetEntity>>? pageRouteBuilder,
Function(BuildContext context, String delegateDescription)?
onPermissionDenied,
/// Crop options
InstaAssetCropDelegate cropDelegate = const InstaAssetCropDelegate(),
/// InstaAssetPickerBuilder options
int gridCount = _kGridCount,
required DefaultAssetPickerProvider provider,
ThemeData? pickerTheme,
AssetPickerTextDelegate? textDelegate,
String? title,
bool closeOnComplete = false,
required Function(Stream<InstaAssetsExportDetails> exportDetails)
onCompleted,
Widget Function(BuildContext context, bool isAssetsEmpty)?
loadingIndicatorBuilder,
LimitedPermissionOverlayPredicate? limitedPermissionOverlayPredicate,
Widget? Function(BuildContext context, AssetPathEntity? path, int length)?
specialItemBuilder,
SpecialItemPosition? specialItemPosition,
InstaPickerActionsBuilder? actionsBuilder,
}) async {
assert(provider.requestType == RequestType.image,
'Only images can be shown in the picker for now');
final text = textDelegate ?? defaultTextDelegate(context);
PermissionState? ps;
if (builder == null) {
try {
ps = await _permissionCheck();
} catch (e) {
_openErrorPermission(context, text, onPermissionDenied);
}
}
builder ??= InstaAssetPickerBuilder(
initialPermission: ps ?? PermissionState.denied,
provider: provider,
title: title,
gridCount: gridCount,
pickerTheme: pickerTheme ?? themeData(Theme.of(context).primaryColor),
locale: Localizations.maybeLocaleOf(context),
keepScrollOffset: true,
textDelegate: text,
loadingIndicatorBuilder: loadingIndicatorBuilder,
limitedPermissionOverlayPredicate: limitedPermissionOverlayPredicate,
closeOnComplete: closeOnComplete,
cropDelegate: cropDelegate,
onCompleted: onCompleted,
specialItemBuilder: specialItemBuilder,
specialItemPosition: specialItemPosition,
actionsBuilder: actionsBuilder,
);
return AssetPicker.pickAssetsWithDelegate(
context,
delegate: builder!,
useRootNavigator: useRootNavigator,
pageRouteBuilder: pageRouteBuilder,
);
}