您正在使用包含逗号后的数据的URI,该URI由RFC-2397定义。 Dart的Uri类基于RFC-3986,因此您不能使用它。请通过逗号拆分字符串并获取其最后部分:
String uri = 'data:image/gif;base64,...';
Uint8List _bytes = base64.decode(uri.split(',').last);
示例代码对初学者非常有用☺️
GestureDetector(
onTap:(){
showDialog(context: context, builder: (context){
var img64 = snapshot.getStudentDetailModel?.courseDetails?.pscPaymetSlip;
final decodestring = base64Decode('$img64'.split(',').last);
Uint8List encodeedimg = decodestring;
return AlertDialog(
contentPadding: EdgeInsets.zero,
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
height:300,
decoration: BoxDecoration(
image: DecorationImage(
fit: BoxFit.cover,
image: MemoryImage(encodeedimg))),),],),);
});
},
child:Text('View', textAlign:TextAlign.end),),
base64.decode
,起始于/9j/4AAQ .........'
- pskink