fromDynamic static method
Builds the builder from a Map-like dynamic structure. This expects the JSON format to be of the following structure:
{
"alignment": "<Alignment>",
"boundaryMargin": "<EdgeInsets>",
"clipBehavior": "<Clip>",
"constrained": "<bool>",
"interactionEndFrictionCoefficient": "<double>",
"maxScale": "<double>",
"minScale": "<double>",
"onInteractionEnd": "<GestureScaleEndCallback>",
"onInteractionStart": "<GestureScaleStartCallback>",
"onInteractionUpdate": "<GestureScaleUpdateCallback>",
"panAxis": "<PanAxis>",
"panEnabled": "<bool>",
"scaleEnabled": "<bool>",
"scaleFactor": "<double>",
"transformationController": "<TransformationController>"
}
As a note, the GestureScaleEndCallback, GestureScaleStartCallback, GestureScaleUpdateCallback, and TransformationController 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.decodeEdgeInsetsGeometry
Implementation
static JsonInteractiveViewerBuilder? fromDynamic(
dynamic map, {
JsonWidgetRegistry? registry,
}) {
JsonInteractiveViewerBuilder? result;
if (map != null) {
result = JsonInteractiveViewerBuilder(
alignment: ThemeDecoder.decodeAlignment(
map['alignment'],
validate: false,
),
boundaryMargin: ThemeDecoder.decodeEdgeInsetsGeometry(
map['boundaryMargin'],
validate: false,
) as EdgeInsets? ??
EdgeInsets.zero,
clipBehavior: ThemeDecoder.decodeClip(
map['clipBehavior'],
validate: false,
) ??
Clip.hardEdge,
constrained: map['constrained'] == null
? true
: JsonClass.parseBool(
map['constrained'],
),
interactionEndFrictionCoefficient: JsonClass.maybeParseDouble(
map['interactionEndFrictionCoefficient']) ??
0.0000135,
maxScale: JsonClass.maybeParseDouble(
map['maxScale'],
2.5,
)!,
minScale: JsonClass.maybeParseDouble(
map['minScale'],
0.8,
)!,
onInteractionEnd: map['onInteractionEnd'],
onInteractionStart: map['onInteractionStart'],
onInteractionUpdate: map['onInteractionUpdate'],
panAxis: ThemeDecoder.decodePanAxis(
map['panAxis'],
validate: false,
) ??
PanAxis.free,
panEnabled: map['panEnabled'] == null
? true
: JsonClass.parseBool(
map['panEnabled'],
),
scaleEnabled: map['scaleEnabled'] == null
? true
: JsonClass.parseBool(
map['scaleEnabled'],
),
scaleFactor: JsonClass.maybeParseDouble(map['scaleFactor']) ?? 200.0,
transformationController: map['transformationController'],
);
}
return result;
}