【发布时间】:2021-12-18 09:26:43
【问题描述】:
我得到一个 PNG 图像(不是 URI)作为对我的 api 请求的响应,如下所示:
Future PostToGetPostImages(String pic_id,String pic_type) async {
try {
var parms = {
'code': pic_type+"_"+pic_id,
};
Response response = await _dio.post(_get_post_image,
data: parms,
options: Options(contentType: Headers.formUrlEncodedContentType),
onSendProgress: (int sent, int total) {
print('sent : $sent // total : $total');
}, onReceiveProgress: (v, s) {
print('v : $v // s : $s');
});
print('***** Response body Download Profile Images: ${response.data} **********');
return response.data;
} catch (error, stacktrace) {
_handleError(error);
print("Exception occured A: $error stackTrace: $stacktrace");
}
}
这是执行后打印的内容:
I/flutter (12777): ***** Response body Download Profile Images: �PNG
我需要知道如何在颤动中显示此响应(png 图像),我正在使用此代码但它不起作用:
FutureBuilder(
future: aptProvider().PostToGetProfileImages("1", "m"),
builder: (context, snapshot) {
return CircleAvatar(
radius: 65.0,
backgroundImage: backgroundImage: NetworkImage(snapshot.data
.toString()));
}),
【问题讨论】:
-
请分享您的 json 数据示例,之后我可以为您提供更多帮助,因为您使用了不正确的函数格式。你需要使用 mvvm 技术
-
在这里评论你的网址