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.parseDouble(value['fontSize']),
fontStyle: decodeFontStyle(
value['fontStyle'],
validate: false,
),
fontWeight: decodeFontWeight(
value['fontWeight'],
validate: false,
),
forceStrutHeight: value['forceStrutHeight'] == null
? null
: JsonClass.parseBool(value['forceStrutHeight']),
height: JsonClass.parseDouble(value['height']),
leading: JsonClass.parseDouble(value['leading']),
leadingDistribution: decodeTextLeadingDistribution(
value['leadingDistribution'],
),
package: value['package'],
);
}
return result;
}