【发布时间】:2022-01-11 05:28:32
【问题描述】:
我需要在我的 Flutter 应用程序中显示 gif。从后端,我从响应中获取 gif 作为 Uint8List 列表。你能帮我看看如何在屏幕上显示这个吗?
我的代码在这里:
widget.session
.get('/api/caff/getCaff/' + widget.gifId.toString())
.then((response) async {
if (response.statusCode == 200) {
Uint8List bytes = response.bodyBytes;
_gifFile = File.fromRawPath(bytes); // tried this but didn't work
} else {
CaffToast.showError(
'Something went wrong! Please check your network connection!');
}
});
我尝试将其显示为文件图像,但它不起作用:
@override
Widget build(BuildContext context) {
return Container(
child: Column(
children: [
_gifFile == null ? Container() : Container(
decoration: BoxDecoration(
image: DecorationImage(
image: FileImage(_gifFile!))),
),
],
),
);
}
您有什么建议可以解决这个问题吗?
【问题讨论】:
标签: flutter gif mobile-development uint8list