decodeStrutStyle static method
Decodes the given value
into a StrutStyle. If the value is null
then null
will be returned. Otherwise, this expects a Map like value
that in JSON would look like:
{
"fontFamily": "<String>",
"fontFamilyFallback": "<String[]>",
"fontSize": "<double>",
"fontStyle": "<FontStyle>",
"fontWeight": "<FontWeight>"
"forceStrutHeight": "<bool>",
"height": "<double>",
"leading": "<double>",
"leadingDistribution": "<TextLeadingDistribution>",
"package": "<String>"
}
See also:
Implementation
static StrutStyle? decodeStrutStyle(
dynamic value, {
bool validate = true,
}) {
StrutStyle? result;
if (value is StrutStyle) {
result = value;
} else if (value != null) {
assert(SchemaValidator.validate(
schemaId: '$_baseSchemaUrl/strut_style',
value: value,
validate: validate,
));
result = StrutStyle(
fontFamily: value['fontFamily'],
fontFamilyFallback: _decodeStringList(
value['fontFamilyFallback'],
(value) => value,
),
fontSize: JsonClass.maybeParseDouble(value['fontSize']),
fontStyle: decodeFontStyle(
value['fontStyle'],
validate: false,
),
fontWeight: decodeFontWeight(
value['fontWeight'],
validate: false,
),
forceStrutHeight: JsonClass.maybeParseBool(value['forceStrutHeight']),
height: JsonClass.maybeParseDouble(value['height']),
leading: JsonClass.maybeParseDouble(value['leading']),
leadingDistribution: decodeTextLeadingDistribution(
value['leadingDistribution'],
validate: false,
),
package: value['package'],
);
}
return result;
}