相关疑难解决方法(0)

如何在flutter中将图像从base64字符串保存到文件?

我有 64 进制图像字符串。
如何将该图像保存到用户的移动设备?这是我尝试过的:

  var response = await http.post('${Utility.serverUrl}/', body: (body));
  final encodedStr = data['result'];
  Uint8List bytes = base64.decode(encodedStr);

  String dir = (await getApplicationDocumentsDirectory()).path;
  File file = File("$dir/" + 'myimage' + ".jpg");
  await file.writeAsBytes(bytes);
  print(file.path);
Run Code Online (Sandbox Code Playgroud)

并在用户的画廊中显示该图像?

mobile-application dart flutter

6
推荐指数
1
解决办法
8765
查看次数

标签 统计

dart ×1

flutter ×1

mobile-application ×1