如何在flutter中将图像下载到图库

Jag*_*gan 1 file-upload image dart flutter flutter-layout

我正在使用学校管理应用程序,在这里我需要将图像和视频发送到应用程序,并允许用户将图像和视频下载到他们的手机图库。我被这个困住了!请帮助我..谢谢..

小智 5

这是可能有帮助的功能

saveImage(String url) async {
    
    var response = await Dio()
        .get(url, options: Options(responseType: ResponseType.bytes));
    final result = await ImageGallerySaver.saveImage(
        Uint8List.fromList(response.data),
        quality: 100,
        name: "${widget.id}");
  }

Run Code Online (Sandbox Code Playgroud)

为了使用这个功能,你必须安装两个包(并且它们在你的 pubspec.ymal 文件中):

dio: ^3.0.10
image_gallery_saver: '^1.5.0'
Run Code Online (Sandbox Code Playgroud)