pushToViewer static method
Future<List<AssetEntity> ?>
pushToViewer(
- BuildContext context, {
- int currentIndex = 0,
- required List<
AssetEntity> previewAssets, - required ThemeData themeData,
- DefaultAssetPickerProvider? selectorProvider,
- ThumbnailSize? previewThumbnailSize,
- List<
AssetEntity> ? selectedAssets, - SpecialPickerType? specialPickerType,
- int? maxAssets,
- bool shouldReversePreview = false,
- AssetSelectPredicate<
AssetEntity> ? selectPredicate,
Static method to push with the navigator. 跳转至选择预览的静态方法
Implementation
static Future<List<AssetEntity>?> pushToViewer(
BuildContext context, {
int currentIndex = 0,
required List<AssetEntity> previewAssets,
required ThemeData themeData,
DefaultAssetPickerProvider? selectorProvider,
ThumbnailSize? previewThumbnailSize,
List<AssetEntity>? selectedAssets,
SpecialPickerType? specialPickerType,
int? maxAssets,
bool shouldReversePreview = false,
AssetSelectPredicate<AssetEntity>? selectPredicate,
}) async {
await AssetPicker.permissionCheck();
final Widget viewer = AssetPickerViewer<AssetEntity, AssetPathEntity>(
builder: DefaultAssetPickerViewerBuilderDelegate(
currentIndex: currentIndex,
previewAssets: previewAssets,
provider: selectedAssets != null
? AssetPickerViewerProvider<AssetEntity>(
selectedAssets,
maxAssets: maxAssets ??
selectorProvider?.maxAssets ??
defaultMaxAssetsCount,
)
: null,
themeData: themeData,
previewThumbnailSize: previewThumbnailSize,
specialPickerType: specialPickerType,
selectedAssets: selectedAssets,
selectorProvider: selectorProvider,
maxAssets: maxAssets,
shouldReversePreview: shouldReversePreview,
selectPredicate: selectPredicate,
),
);
final PageRouteBuilder<List<AssetEntity>> pageRoute =
PageRouteBuilder<List<AssetEntity>>(
pageBuilder: (_, __, ___) => viewer,
transitionsBuilder: (_, Animation<double> animation, __, Widget child) {
return FadeTransition(opacity: animation, child: child);
},
);
final List<AssetEntity>? result =
await Navigator.of(context).push<List<AssetEntity>>(pageRoute);
return result;
}