pushToViewerWithDelegate<A, P> static method

Future<List<A>?> pushToViewerWithDelegate<A, P>(
  1. BuildContext context, {
  2. required AssetPickerViewerBuilderDelegate<A, P> delegate,
  3. PermissionRequestOption permissionRequestOption = const PermissionRequestOption(),
})

Call the viewer with provided delegate and provider. 通过指定的 delegate 调用查看器

Implementation

static Future<List<A>?> pushToViewerWithDelegate<A, P>(
  BuildContext context, {
  required AssetPickerViewerBuilderDelegate<A, P> delegate,
  PermissionRequestOption permissionRequestOption =
      const PermissionRequestOption(),
}) async {
  await AssetPicker.permissionCheck(requestOption: permissionRequestOption);
  final Widget viewer = AssetPickerViewer<A, P>(builder: delegate);
  final PageRouteBuilder<List<A>> pageRoute = PageRouteBuilder<List<A>>(
    pageBuilder: (_, __, ___) => viewer,
    transitionsBuilder: (_, Animation<double> animation, __, Widget child) {
      return FadeTransition(opacity: animation, child: child);
    },
  );
  final List<A>? result =
      await Navigator.maybeOf(context)?.push<List<A>>(pageRoute);
  return result;
}