decodeTextSpan static method
Decodes a given Map-like value
into a TextStyle. This expects the
given value
to have the following structure:
{
"children": "<List<TextSpan>>",
"locale": "<Locale>",
"mouseCursor": "<MouseCursor>",
"onEnter": "<PointerEnterEventListener>",
"onExit": "<PointerExitEventListener>",
"recognizer": "<GestureRecognizer>",
"semanticsLabel": "<String>",
"spellOut": "<bool>",
"style": "<TextStyle>",
"text": "<String>"
}
See Also:
Implementation
static TextSpan? decodeTextSpan(
dynamic value, {
bool validate = true,
}) {
TextSpan? result;
if (value is TextSpan) {
result = value;
} else if (value is String) {
result = TextSpan(text: value);
} else if (value != null) {
assert(SchemaValidator.validate(
schemaId: '$_baseSchemaUrl/text_span',
value: value,
validate: validate,
));
result = TextSpan(
children: (value['children'] as List?)
?.map((e) => decodeTextSpan(e, validate: false)!)
.toList(),
locale: decodeLocale(
value['locale'],
validate: false,
),
mouseCursor: decodeMouseCursor(
value['mouseCursor'],
validate: false,
),
onEnter: value['onEnter'],
onExit: value['onExit'],
recognizer: value['recognizer'],
semanticsLabel: value['semanticsLabel']?.toString(),
spellOut: JsonClass.maybeParseBool(value['spellOut']),
style: decodeTextStyle(
value['style'],
validate: false,
),
text: value['text']?.toString(),
);
}
return result;
}