pickerPaths static method
Future<List<Media> >
pickerPaths({
- GalleryMode galleryMode = GalleryMode.image,
- UIConfig? uiConfig,
- int selectCount = 1,
- bool showCamera = false,
- bool showGif = true,
- CropConfig? cropConfig,
- int compressSize = 500,
选择图片或视频 Choose an image or video
返回选择的图片或视频的信息 Return information of the selected picture or video
galleryMode 选择图片或者选择视频 枚举 Select an image or select a video to enumerate
uiConfig 选择图片或选择视频页面的主题 默认 0xfffefefe Select an image or select the theme of the video page Default 0xfffefefe
selectCount 要选择的图片数量 Number of images to select
showCamera 是否显示相机按钮 Whether to display the camera button
cropConfig 裁剪配置(视频不支持裁剪和压缩,当选择视频时此参数无效) Crop configuration (video does not support cropping and compression, this parameter is not available when selecting video)
compressSize 选择图片(选择视频时此参数无效)后的忽略压缩大小,当图片大小小于compressSize时将不压缩 单位 KB Ignore compression size after selection, will not compress unit KB when the image size is smaller than compressSize
Implementation
static Future<List<Media>> pickerPaths({
GalleryMode galleryMode: GalleryMode.image,
UIConfig? uiConfig,
int selectCount: 1,
bool showCamera: false,
bool showGif: true,
CropConfig? cropConfig,
int compressSize: 500,
}) async {
String gMode = "image";
if (galleryMode == GalleryMode.image) {
gMode = "image";
} else if (galleryMode == GalleryMode.video) {
gMode = "video";
}
Color uiColor = UIConfig.defUiThemeColor;
if (uiConfig != null) {
uiColor = uiConfig.uiThemeColor;
}
bool enableCrop = false;
int width = 1;
int height = 1;
if (cropConfig != null) {
enableCrop = cropConfig.enableCrop;
width = cropConfig.width <= 0 ? 1 : cropConfig.width;
height = cropConfig.height <= 0 ? 1 : cropConfig.height;
}
final Map<String, dynamic> params = <String, dynamic>{
'galleryMode': gMode,
'showGif': showGif,
'uiColor': {
"a": 255,
"r": uiColor.red,
"g": uiColor.green,
"b": uiColor.blue,
"l": (uiColor.computeLuminance() * 255).toInt()
},
'selectCount': selectCount,
'showCamera': showCamera,
'enableCrop': enableCrop,
'width': width,
'height': height,
'compressSize': compressSize < 50 ? 50 : compressSize,
};
final List<dynamic> paths =
await _channel.invokeMethod('getPickerPaths', params);
List<Media> medias = [];
paths.forEach((data) {
Media media = Media();
media.thumbPath = data["thumbPath"];
media.path = data["path"];
media.galleryMode = galleryMode;
medias.add(media);
});
return medias;
}