fromJson static method
Creates a CPDFShapeAttr instance from a JSON map. example:
CPDFShapeAttr.fromJson({
'fillColor': '#FF0000',
'borderColor': '#00FF00',
'colorAlpha': 128,
'borderWidth': 2,
'borderStyle': {
'style': 'dashed',
'dashGap': 5
}
});
Implementation
static CPDFShapeAttr fromJson(Map<String, dynamic> json) {
return CPDFShapeAttr(
fillColor: HexColor.fromHex(json['fillColor']),
borderColor: HexColor.fromHex(json['borderColor']),
colorAlpha: json['colorAlpha'] ?? 128,
borderWidth: json['borderWidth'] ?? 2.0,
borderStyle: json['borderStyle'] != null
? CPDFBorderStyle(
style: CPDFAnnotBorderStyle.values.firstWhere(
(e) => e.name == json['borderStyle']['style']),
dashGap: json['borderStyle']['dashGap'] ?? 0)
: const CPDFBorderStyle.solid(),
);
}