pickAssetsWithDelegate<Asset, Path, PickerProvider extends AssetPickerProvider<Asset, Path>> method

Future<List<Asset>?> pickAssetsWithDelegate<Asset, Path, PickerProvider extends AssetPickerProvider<Asset, Path>>(
  1. BuildContext context, {
  2. required AssetPickerBuilderDelegate<Asset, Path> delegate,
  3. PermissionRequestOption permissionRequestOption = const PermissionRequestOption(),
  4. Key? key,
  5. bool useRootNavigator = true,
  6. AssetPickerPageRouteBuilder<List<Asset>>? pageRouteBuilder,
})

Pick assets with the given delegate. 根据给定的 delegate 选择资源。

Set useRootNavigator to determine whether the picker route should use the root Navigator. 使用 useRootNavigator 来控制选择器的路由是否使用最顶层的 Navigator

By extending the AssetPickerPageRoute, users can customize the route and use it with the pageRouteBuilder. 继承 AssetPickerPageRoute 可以自定义路由, 并且通过 pageRouteBuilder 进行使用。

See also:

Implementation

Future<List<Asset>?> pickAssetsWithDelegate<Asset, Path,
    PickerProvider extends AssetPickerProvider<Asset, Path>>(
  BuildContext context, {
  required AssetPickerBuilderDelegate<Asset, Path> delegate,
  PermissionRequestOption permissionRequestOption =
      const PermissionRequestOption(),
  Key? key,
  bool useRootNavigator = true,
  AssetPickerPageRouteBuilder<List<Asset>>? pageRouteBuilder,
}) async {
  await permissionCheck(requestOption: permissionRequestOption);
  final Widget picker = AssetPicker<Asset, Path>(
    key: key,
    permissionRequestOption: permissionRequestOption,
    builder: delegate,
  );
  final List<Asset>? result = await Navigator.maybeOf(
    context,
    rootNavigator: useRootNavigator,
  )?.push<List<Asset>>(
    pageRouteBuilder?.call(picker) ??
        AssetPickerPageRoute<List<Asset>>(builder: (_) => picker),
  );
  return result;
}