如图所示,我有一个“获取”休息响应,它以 64 位值数组的形式返回。如何将这些数据转换为 Flutter 中的图像?
内容类型为“application/octet-stream”,必须将 64 位转换为 8 位才能显示灰度图像。
我试过 base64.decode(response) 但它抛出了 FormatException (FormatException: Invalid base64 data (at character 2)
['get' 请求的 postman 响应]:[1]:/image/FoxKR.png
谢谢
[编辑]:这是我提出的要求:
final response = await dio.get(
Consts.baseUrl + endPointUrl,
queryParameters: {
'_id': '5f6c5a7e8934b52296b957c5',
'type': 'contamination'
},
options: Options(
headers: {'Authorization': Consts.apiKey},
contentType: 'application/octet-stream'),
);
最佳答案
Directory tempDir = await getTemporaryDirectory();
String tempPath = tempDir.path;
File file = new File('$tempPath/image.png');
await file.writeAsBytes(image64BitData);
// Display your image => file
关于flutter - 如何将 64 位值的矩阵转换为 Dart 中的图像响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64629613/