Flutter 颤振:将Base64字符串图像url转换为文件,并在FileImage或相关小部件中使用它
我尝试过这种方法,并在Flutter 颤振:将Base64字符串图像url转换为文件,并在FileImage或相关小部件中使用它,flutter,dart,base64,Flutter,Dart,Base64,我尝试过这种方法,并在FileImage中使用它,但没有找到一个反弹点 Uint8List bytes = base64.decode(imageBase64); File file = File.fromRawPath(bytes); imageBase64是已编码的图像url 这件事的重点是,我想在FileImage或其他小部件图像文件中使用它,但我不想将此图像保存到设备并将此文件上载到附件文件Rest API 有人能帮我吗。如果你得到字节后想做的是显示图像,那么你可以使用image.me
FileImage
中使用它,但没有找到一个反弹点
Uint8List bytes = base64.decode(imageBase64);
File file = File.fromRawPath(bytes);
imageBase64
是已编码的图像url
这件事的重点是,我想在FileImage
或其他小部件图像文件中使用它,但我不想将此图像保存到设备并将此文件上载到附件文件Rest API
有人能帮我吗。如果你得到字节后想做的是显示图像,那么你可以使用
image.memory
var imageWidget = Image.memory(bytes);
如果你想上传图片,你不需要把它转换成文件。假设不能使用base64编码上传字节,则可以直接使用字节。包装
如果您有UintList8,则可以使用MemoryImage(字节)
但是我必须把它转换成文件。你想要一个从文件加载图像的文件图像还是一个二进制文件本身的文件图像?但是我必须把它转换成文件。也许我误解了你的问题,但是你说想要一个
FileImage
或另一个小部件<代码>图像。内存返回一个小部件。你想用那个@Miko做什么?
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();
Uint8List bytes = base64.decode(imageBase64);
Image(image: MemoryImage(bytes));