iOS需要再项目内配置plist文件,申请访问权
<key>NSPhotoLibraryUsageDescription</key>
<string>Example usage description</string>
<key>NSCameraUsageDescription</key>
<string>Example usage description</string>
在pubspec.yaml中添加依赖:
image_picker: ^0.6.0+4
Future getImage() async {
var image = await ImagePicker.pickImage(source: ImageSource.gallery);
setState(() {
if (image != null) _image = image;
});
}