我需要在我的 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!))),
),
],
),
);
}
你有什么建议我该如何解决这个问题?