如何显示Image.memory

时间:2019-09-10 04:10:22

标签: flutter flutter-image

我需要在项目中显示一个Image.memory,但是当我将此代码放在body的{​​{1}}中时,它不会显示。

Scaffold

1 个答案:

答案 0 :(得分:0)

// Create an instance variable
Image image;

@override
void initState() {
  super.initState();

  // put them here
  Codec<String, String> stringToBase64 = utf8.fuse(base64);
  String imagenJson = "Here, I put the BASE64 string";
  Uint8List _image = base64Decode(imagenJson);
  image = Image.memory(_image); // assign it value here

}

@override
Widget build(BuildContext context) {
  return Scaffold(
    appBar: AppBar(),
    body: image, // use it here
  );
}