Flutter 获取系统相册

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_27981847/article/details/90473542

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;
    });
  }

猜你喜欢

转载自blog.csdn.net/qq_27981847/article/details/90473542