Skip to content

flutter-cavalry/ph_picker_view_controller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ph_picker_view_controller

pub package

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

Usage

pick

final _plugin = PhPickerViewController();

/// Shows an asset picker backed by `PHPickerViewController`.
///
/// [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] same as `PHPickerViewController.fileRepresentation`.
/// Defaults to `UTType.data.identifier`.
///
/// [appendLiveVideos] If true, appends Live Photo video assets to the results.
/// Use [PHPickerResult.liveVideoUrl] and [PHPickerResult.liveVideoPath] to access them.
await _plugin.pick(
  filter: {
    'any': ['livePhotos', 'videos'],
  },
  preferredAssetRepresentationMode: PHPickerAssetRepresentationMode.current,
  selection: PHPickerSelection.ordered,
  selectionLimit: 3,
);

PHPickerResult:

/// The result type returned from [pick] function.
///
/// [id] asset ID.
/// [url] asset local URL.
/// [path] asset local path.
/// [liveVideoUrl] live video local URL.
/// [liveVideoPath] live video local path.
/// [error] error message.
class PHPickerResult {
  final String id;
  final String? url;
  final String? path;
  final String? liveVideoUrl;
  final String? liveVideoPath;
}

delete

final _plugin = PhPickerViewController();

final deleted = await _plugin.delete(
  ids: ['assetID1', 'assetID2'],
);

About

A wrapper around iOS `PHPickerViewController` API.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published