decodeTextHeightBehavior static method
Decodes the given value
into a TextHeightBehavior. If the value is
null
then null
will be returned. Otherwise, this expects a Map like
value that in JSON would look like:
{
"applyHeightToFirstAscent": <bool>,
"applyHeightToLastDescent": <bool>,
"leadingDistribution": <TextLeadingDistribution>
}
Implementation
static TextHeightBehavior? decodeTextHeightBehavior(
dynamic value, {
bool validate = true,
}) {
TextHeightBehavior? result;
if (value is TextHeightBehavior) {
result = value;
} else if (value != null) {
assert(SchemaValidator.validate(
schemaId: '$_baseSchemaUrl/text_height_behavior',
value: value,
validate: validate,
));
result = TextHeightBehavior(
applyHeightToFirstAscent: value['applyHeightToFirstAscent'] == null
? true
: JsonClass.parseBool(value['applyHeightToLastDescent']),
applyHeightToLastDescent: value['applyHeightToLastDescent'] == null
? true
: JsonClass.parseBool(value['applyHeightToLastDescent']),
leadingDistribution: decodeTextLeadingDistribution(
value['leadingDistribution'],
validate: false,
) ??
TextLeadingDistribution.proportional,
);
}
return result;
}