pub package


A wrapper around iOS PHPickerViewController API. (iOS 14+).



final _plugin = PhPickerViewController();

/// Shows an asset picker backed by `PHPickerViewController`.
/// [fetchURL] fetches file URLs. By default, only asset IDs are returned.
/// [filter] same as `PHPickerViewController.filter`.
/// Example:
/// `{'any': ['livePhotos', 'videos']}` is equivalent to
/// `PHPickerFilter.any(of: [.livePhotos, .videos])`.
/// [selectionLimit] same as `PHPickerViewController.selectionLimit`.
/// [preferredAssetRepresentationMode] same as `PHPickerViewController.preferredAssetRepresentationMode`.
/// [selection] same as `PHPickerViewController.selection`.
/// [fileRepresentation] defaults to `UTType.item.identifier`. Use this to
/// specify the file representation of the picked assets.
/// For example, live photos are represented as MOV files. To get GIF files,
/// pass `public.image` instead.
await _plugin.pick(
        filter: {
          'any': ['livePhotos', 'videos'],
        preferredAssetRepresentationMode: AssetRepresentationMode.current,
        selection: Selection.ordered,
        selectionLimit: 3,
        fetchURL: true,


/// The result type returned by [pick] function.
/// [id] asset ID.
/// [url] asset local URL.
/// [path] asset local path.
/// [error] error message.
class PHPickerResult {
  final String id;
  final String? url;
  final String? error;
  PHPickerResult(, this.url, this.error);