TextLine.fromJson constructor
TextLine.fromJson(
- Map<String, dynamic> json
)
Implementation
factory TextLine.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(),
);
}
List<TextElement> elems = [];
if (json['elements'] != null && json['elements'] is List) {
elems = (json['elements'] as List)
.map((e) => TextElement.fromJson(e as Map<String, dynamic>))
.toList();
}
return TextLine(
text: json['text'] as String? ?? '',
elements: elems,
boundingBox: box,
confidence: (json['confidence'] as num?)?.toDouble() ?? 1.0,
recognizedLanguage: json['recognizedLanguage'] as String?,
);
}