toJson method
Implementation
@override
Map<String, dynamic>? toJson(ImageProvider? object) {
if (object == null) return null;
assert(object is AssetImage ||
object is MemoryImage ||
object is NetworkImage);
if (object is AssetImage) {
return <String, dynamic>{
'assetName': object.assetName,
'package': object.package,
'type': 'asset',
};
} else if (object is MemoryImage) {
return <String, dynamic>{
'bytes': base64Encode(object.bytes),
'scale': object.scale,
'type': 'memory',
};
} else if (object is NetworkImage) {
return <String, dynamic>{
'headers': object.headers,
'scale': object.scale,
'type': 'network',
'url': object.url,
};
}
throw 'Json_Unsuported_Value';
}