Image 参数类型';字符串';can';不能分配给参数类型';UINT8列表';

Image 参数类型';字符串';can';不能分配给参数类型';UINT8列表';,image,flutter,dart,Image,Flutter,Dart,我的响应中有一个base64字符串,并试图将该base64转换为图像。我使用了Uint8List类。但无法将转换后的base64引用到Image.memory class Data { String sId; String name; String category; String image; int iV; var decoded; Uint8List bytes ; Data({this.sId, this.name, this.category, thi

我的响应中有一个base64字符串,并试图将该base64转换为图像。我使用了Uint8List类。但无法将转换后的base64引用到Image.memory

class Data {
  String sId;
  String name;
  String category;
  String image;
  int iV;
  var decoded;
  Uint8List bytes ;

  Data({this.sId, this.name, this.category, this.image, this.iV, this.bytes});

  Data.fromJson(Map<String, dynamic> json) {
    sId = json['_id'];
    name = json['name'];
    category = json['category'];
    image = json['image'];
    iV = json['__v'];
 // decoded = Base64Decoder().convert(image);
   bytes = base64.decode(image);
  }


你应该这样写:

Container(     
margin: const EdgeInsets.symmetric(horizontal: 2.0),
                                          width: 100.0,
                                          height: 140.0,
                                          child:Image.memory(data.bytes),
                                        ),
Container(     
margin: const EdgeInsets.symmetric(horizontal: 2.0),
                                          width: 100.0,
                                          height: 140.0,
                                          child:Image.memory(data.bytes),
                                        ),