fromDynamic static method
Builds the builder from a Map-like dynamic structure. This expects the JSON format to be of the following structure:
{
"curve": "<Curve>",
"duration": "<int; millis>",
"maxLines": "<int>",
"onEnd": "<VoidCallback>",
"overflow": "<TextOverflow>",
"softWrap": "<bool>",
"style": "<TextStyle>",
"textAlign": "<TextAlign>",
"textHeightBehavior": "<TextHeightBehavior>",
"textWidthBasis": "<TextWidthBasis>"
}
As a note, the Curve and VoidCallback cannot be decoded via JSON. Instead, the only way to bind those values to the builder is to use a function or a variable reference via the JsonWidgetRegistry.
See also:
ThemeDecoder.decodeTextOverflow
ThemeDecoder.decodeTextStyle
ThemeDecoder.decodeTextAlign
ThemeDecoder.decodeTextHeightBehavior
ThemeDecoder.decodeTextWidthBasis
Implementation
static JsonAnimatedDefaultTextStyleBuilder? fromDynamic(
dynamic map, {
JsonWidgetRegistry? registry,
}) {
JsonAnimatedDefaultTextStyleBuilder? result;
if (map != null) {
result = JsonAnimatedDefaultTextStyleBuilder(
curve: map['curve'] ?? Curves.linear,
duration: JsonClass.maybeParseDurationFromMillis(
map['duration'],
)!,
maxLines: JsonClass.maybeParseInt(map['maxLines']),
onEnd: map['onEnd'],
overflow: ThemeDecoder.decodeTextOverflow(
map['overflow'],
validate: false,
) ??
TextOverflow.clip,
softWrap: JsonClass.parseBool(map['softWrap'] ?? true),
style: ThemeDecoder.decodeTextStyle(
map['style'],
validate: false,
)!,
textAlign: ThemeDecoder.decodeTextAlign(
map['textAlign'],
validate: false,
),
textHeightBehavior: ThemeDecoder.decodeTextHeightBehavior(
map['textHeightBehavior'],
validate: false,
),
textWidthBasis: ThemeDecoder.decodeTextWidthBasis(
map['textWidthBasis'],
validate: false,
) ??
TextWidthBasis.parent,
);
}
return result;
}