TextElement.fromJson constructor
TextElement.fromJson(
- Map<String, dynamic> json
)
Implementation
factory TextElement.fromJson(Map<String, dynamic> json) {
Rect? box;
if (json['boundingBox'] != null && json['boundingBox'] is Map) {
final b = json['boundingBox'] as Map<String, dynamic>;
box = Rect.fromLTWH(
(b['left'] as num).toDouble(),
(b['top'] as num).toDouble(),
(b['width'] as num).toDouble(),
(b['height'] as num).toDouble(),
);
}
return TextElement(
text: json['text'] as String? ?? '',
confidence: (json['confidence'] as num?)?.toDouble() ?? 1.0,
boundingBox: box,
recognizedLanguage: json['recognizedLanguage'] as String?,
);
}