安装
dependencies:
image_picker: ^0.8.4+2 #图片选择器
import 'package:image_picker/image_picker.dart';//引入库
Pictureselection() async {
ImagePicker _picker = ImagePicker();//定义选择器
_picker.pickImage(source: source),//选择图片
_picker.pickMultiImage(),//选择多个图片
_picker.pickVideo(source: source),//选择视频
// required ImageSource source,//定义选择类型
// double? maxWidth,//最大宽度
// double? maxHeight,//最大高度
// int? imageQuality,//画面质量
// CameraDevice preferredCameraDevice = CameraDevice.rear,//首选相机设备
///多图选择
List<XFile>? images = await _picker.pickMultiImage();
images?.forEach((element) {
print(element.path);//返回路径
print(element.name);//返回文件名称
print('---');
print(element.reactive);
print(element.length());
print(element.mimeType);
});
}
THE END