FreeTextAnnotation.fromJson constructor
FreeTextAnnotation.fromJson(
- Map<String, dynamic> json
)
Implementation
factory FreeTextAnnotation.fromJson(Map<String, dynamic> json) {
return FreeTextAnnotation(
id: json['id'] as String?,
bbox: Annotation._toDoubleList(json['bbox'] as List),
createdAt: json['createdAt'] as String?,
creatorName: json['creatorName'] as String?,
text:
TextContent.fromJson(Map<String, dynamic>.from(json['text'] as Map)),
backgroundColor:
Annotation._hexToColor(json['backgroundColor'] as String?),
fontSize: Annotation._toDouble(json['fontSize']),
font: json['font'] as String? ?? 'sans-serif',
horizontalTextAlign: json['horizontalAlign'] != null
? HorizontalTextAlignment.values.firstWhere(
(e) => e.name == json['horizontalAlign'] as String,
orElse: () => HorizontalTextAlignment.left,
)
: null,
verticalAlign: json['verticalAlign'] != null
? VerticalAlignment.values.firstWhere(
(e) => e.name == json['verticalAlign'] as String,
orElse: () => VerticalAlignment.top,
)
: null,
fontColor:
Annotation._hexToColor(json['fontColor'] as String?) ?? Colors.black,
isFitting: json['isFitting'] as bool?,
disableAutoReturn: json['disableAutoReturn'] as bool?,
callout: json['callout'] as Map<String, dynamic>?,
borderStyle: json['borderStyle'] != null
? BorderStyle.values.firstWhere(
(e) => e.name == json['borderStyle'] as String,
orElse: () => BorderStyle.solid,
)
: null,
borderDashArray: json['borderDashArray'] != null
? Annotation._toDoubleList(json['borderDashArray'] as List<dynamic>)
: null,
borderWidth: json['borderWidth'] != null
? Annotation._toDouble(json['borderWidth'])
: null,
rotation: json['rotation'] as int? ?? 0,
cloudyBorderIntensity: json['cloudyBorderIntensity'] != null
? Annotation._toDouble(json['cloudyBorderIntensity'])
: null,
cloudyBorderInset: json['cloudyBorderInset'] is List<dynamic>
? Annotation._toDoubleList(json['cloudyBorderInset'] as List<dynamic>)
: null,
pageIndex: json['pageIndex'] as int,
opacity:
json['opacity'] != null ? Annotation._toDouble(json['opacity']) : 1.0,
pdfObjectId: json['pdfObjectId'] as int?,
flags: Annotation._stringsToFlags(json['flags'] as List<dynamic>?),
updatedAt: json['updatedAt'] as String?,
name: json['name'] as String?,
subject: json['subject'] as String?,
hidden: json['hidden'] as bool? ?? false,
customData: json['customData'] != null
? Map<String, dynamic>.from(json['customData'])
: null,
);
}