fromDynamic static method
Builds the builder from a Map-like dynamic structure. This expects the JSON format to be of the following structure:
{
"animateColor: <bool>,
"animateShadowColor: <bool>,
"borderRadius: <BorderRadius>,
"clipBehavior: <Clip>,
"color": <Color>,
"curve": <Curve>,
"duration": <int; millis>,
"elevation": <double>,
"onEnd": <VoidCallback>,
"shadowColor": <Color>,
"shape": <BoxShape>,
}
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.decodeBoxShape
Implementation
static JsonAnimatedPhysicalModelBuilder? fromDynamic(
dynamic map, {
JsonWidgetRegistry? registry,
}) {
JsonAnimatedPhysicalModelBuilder? result;
if (map != null) {
result = JsonAnimatedPhysicalModelBuilder(
animateColor: JsonClass.parseBool(
map['animateColor'] ?? true,
),
animateShadowColor: JsonClass.parseBool(
map['animateShadowColor'] ?? true,
),
borderRadius: ThemeDecoder.decodeBorderRadius(
map['borderRadius'],
) ??
BorderRadius.zero,
clipBehavior: ThemeDecoder.decodeClip(
map['clipBehavior'],
) ??
Clip.none,
color: ThemeDecoder.decodeColor(
map['color'],
)!,
curve: map['curve'] ?? Curves.linear,
duration: JsonClass.parseDurationFromMillis(
map['duration'],
)!,
elevation: JsonClass.parseDouble(
map['elevation'],
)!,
onEnd: map['onEnd'],
shadowColor: ThemeDecoder.decodeColor(
map['shadowColor'],
)!,
shape: ThemeDecoder.decodeBoxShape(
map['shape'],
)!,
);
}
return result;
}