parse method
Widget
parse(
- Map<
String, dynamic> map, - BuildContext buildContext,
- ClickListener? listener
override
parse the json map into a flutter widget.
Implementation
@override
Widget parse(Map<String, dynamic> map, BuildContext buildContext,
ClickListener? listener) {
String? data = map['data'];
String? textAlignString = map['textAlign'];
String? overflow = map['overflow'];
int? maxLines = map['maxLines'];
String? semanticsLabel = map['semanticsLabel'];
bool? softWrap = map['softWrap'];
String? textDirectionString = map['textDirection'];
double? textScaleFactor = map['textScaleFactor']?.toDouble();
var textSpan;
var textSpanParser = TextSpanParser();
if (map.containsKey("textSpan")) {
textSpan = textSpanParser.parse(map['textSpan'], listener);
}
if (textSpan == null) {
return Text(
data!,
textAlign: parseTextAlign(textAlignString),
overflow: parseTextOverflow(overflow),
maxLines: maxLines,
semanticsLabel: semanticsLabel,
softWrap: softWrap,
textDirection: parseTextDirection(textDirectionString),
style: map.containsKey('style') ? parseTextStyle(map['style']) : null,
textScaleFactor: textScaleFactor,
);
} else {
return Text.rich(
textSpan,
textAlign: parseTextAlign(textAlignString),
overflow: parseTextOverflow(overflow),
maxLines: maxLines,
semanticsLabel: semanticsLabel,
softWrap: softWrap,
textDirection: parseTextDirection(textDirectionString),
style: map.containsKey('style') ? parseTextStyle(map['style']) : null,
textScaleFactor: textScaleFactor,
);
}
}