【发布时间】:2020-11-22 07:21:36
【问题描述】:
我正在将 Flutter Web 用于 Web 应用程序,并且无法将图像从图像选择器转换为文件以便将其上传到我的服务器。我在 Image.file(xxx) 中显示图像,但出现错误:
尝试加载资产时出错:FormatException: Illegal scheme 字符(在字符 6 处) Image(image:%20MemoryImage(Uint8List%234267a,%20scale:%201),%20frameBuilder...
这是我正在尝试的代码:
Future getImage(bool isCamera) async {
Image image;
if (isCamera) {
image = await FlutterWebImagePicker.getImage;
} else {
}
var bytes = await rootBundle.load('$image');
String tempPath = (await getTemporaryDirectory()).path;
File file = File('$tempPath/profile.png');
await file.writeAsBytes(
bytes.buffer.asUint8List(bytes.offsetInBytes, bytes.lengthInBytes));
setState(() {
currentSelfie = file;
_accDetails['customer_selfie'] = currentSelfie;
});
}
提前致谢
【问题讨论】:
-
您是否尝试从您的 Finder/Windows 资源管理器中获取图像?你不需要图书馆。即使您尝试从笔记本电脑/手机获取图像也非常简单。如果是这种情况,请告诉我,我将发布获取文件的完整过程。
-
@marianoZorrilla 你有完整流程的链接吗?我只是从移动设备/桌面获取照片
标签: flutter dart flutter-web imagepicker