pushToViewer static method

Future<AssetEntity?> pushToViewer(
  1. BuildContext context, {
  2. required CameraPickerConfig pickerConfig,
  3. required CameraPickerViewType viewType,
  4. required XFile previewXFile,
  5. CameraPickerViewerState createViewerState()?,
  6. bool useRootNavigator = true,
})

Static method to push with the navigator. 跳转至选择预览的静态方法

Implementation

static Future<AssetEntity?> pushToViewer(
  BuildContext context, {
  required CameraPickerConfig pickerConfig,
  required CameraPickerViewType viewType,
  required XFile previewXFile,
  CameraPickerViewerState Function()? createViewerState,
  bool useRootNavigator = true,
}) {
  return Navigator.of(
    context,
    rootNavigator: useRootNavigator,
  ).push<AssetEntity?>(
    PageRouteBuilder<AssetEntity?>(
      pageBuilder: (_, __, ___) => CameraPickerViewer._(
        viewType: viewType,
        previewXFile: previewXFile,
        pickerConfig: pickerConfig,
        createViewerState: createViewerState,
      ),
      transitionsBuilder: (
        BuildContext context,
        Animation<double> animation,
        Animation<double> secondaryAnimation,
        Widget child,
      ) {
        return FadeTransition(opacity: animation, child: child);
      },
    ),
  );
}