toJson method
Implementation
Map<String, dynamic> toJson() {
if (type == FFillType.json) {
return {
'json_get_attr': jsonGetAttribute?.toJson(),
't': 'json',
};
}
if (type == FFillType.variable) {
return {'varID': variableID, 't': 'v'};
}
if (paletteStyle == null) {
String? typeString;
if (type == FFillType.solid) typeString = 's';
if (type == FFillType.linearGradient) typeString = 'l';
if (type == FFillType.radialGradient) typeString = 'r';
if (type == FFillType.image) typeString = 'i';
if (type == FFillType.none) typeString = 'n';
final levelsMap = <Map<String, dynamic>>[];
for (final e in levels) {
levelsMap.add(e.toJson());
}
return <String, dynamic>{
'l': levelsMap,
't': typeString,
'b': alignToJson(begin),
'e': alignToJson(end),
'c': alignToJson(center),
'r': radius,
'pltt': paletteStyle,
'varID': variableID,
'bF': (boxFit != null)
? boxFit!.toJson()
: const FBoxFit(value: BoxFit.cover).toJson(),
}..removeWhere((final String key, final dynamic value) => value == null);
} else {
return {
'pltt': paletteStyle,
};
}
}