我尝试过这种方法,并在FileImage
中使用它,但没有找到集合点
Uint8List bytes = base64.decode(imageBase64);
File file = File.fromRawPath(bytes);
imageBase64
是已编码的图像url。
重点是,我想在FileImage
或其他小部件图像文件中使用它,但我不希望将此图像保存到设备并将此文件上传到附件文件Rest API
有人能帮我吗。
发布于 2020-06-26 01:14:13
如果获得字节后您想要做的是显示图像,那么可以使用Image.memory
。
var imageWidget = Image.memory(bytes);
如果你正在尝试上传图片,你不需要把它转换成文件。你可以直接使用字节,假设你不能使用base64编码上传它。包http
import 'package:http/http.dart';
..。
//create multipart using filepath, string or bytes
MultipartFile multipartFile = MultipartFile.fromBytes(
'file',
byteData,
filename: fileName,
);
//add multipart to request
request.files.add(multipartFile);
var response = await request.send();
发布于 2020-06-26 01:14:40
如果你有一个字节,你可以使用MemoryImage( UintList8 )。
Uint8List bytes = base64.decode(imageBase64);
Image(image: MemoryImage(bytes));
https://stackoverflow.com/questions/62580704
复制相似问题