fromDynamic static method
Builds the builder from a Map-like dynamic structure. This expects the JSON format to be of the following structure:
{
"behavior": "<HitTestBehavior>",
"dragStartBehavior": "<DragStartBehavior>",
"excludeFromSemantics": "<bool>",
"onDoubleTap": "<GestureDoubleTapCallback>",
"onDoubleTapCancel": "<GestureTapCancelCallback>",
"onDoubleTapDown": "<GestureTapDownCallback>",
"onForcePressEnd": "<GestureForcePressEndCallback>",
"onForcePressPeak": "<GestureForcePressPeakCallback>",
"onForcePressStart": "<GestureForcePressStartCallback>",
"onForcePressUpdate": "<GestureForcePressUpdateCallback>",
"onHorizontalDragCancel": "<GestureDragCancelCallback>",
"onHorizontalDragDown": "<GestureDragDownCallback>",
"onHorizontalDragEnd": "<GestureDragEndCallback>",
"onHorizontalDragStart": "<GestureDragStartCallback>",
"onHorizontalDragUpdate": "<GestureDragUpdateCallback>",
"onLongPress": "<GestureLongPressCallback>",
"onLongPressCancel": "<GestureLongPressCancelCallback>",
"onLongPressDown": "<GestureLongPressDownCallback>",
"onLongPressEnd": "<GestureLongPressEndCallback>",
"onLongPressMoveUpdate": "<GestureLongPressMoveUpdateCallback>",
"onLongPressStart": "<GestureLongPressStartCallback>",
"onLongPressUp": "<GestureLongPressUpCallback>",
"onPanCancel": "<GestureDragCancelCallback>",
"onPanDown": "<GestureDragDownCallback>",
"onPanEnd": "<GestureDragEndCallback>",
"onPanStart": "<GestureDragStartCallback>",
"onPanUpdate": "<GestureDragUpdateCallback>",
"onScaleEnd": "<GestureScaleEndCallback>",
"onScaleStart": "<GestureScaleStartCallback>",
"onScaleUpdate": "<GestureScaleUpdateCallback>",
"onSecondaryLongPress": "<GestureLongPressCallback>",
"onSecondaryLongPressCancel": "<GestureLongPressCancelCallback>",
"onSecondaryLongPressDown": "<GestureLongPressDownCallback>",
"onSecondaryLongPressEnd": "<GestureLongPressEndCallback>",
"onSecondaryLongPressMoveUpdate": "<GestureLongPressMoveUpdateCallback>",
"onSecondaryLongPressStart": "<GestureLongPressStartCallback>",
"onSecondaryLongPressUp": "<GestureLongPressUpCallback>",
"onSecondaryTap": "<GestureTapCallback>",
"onSecondaryTapCancel": "<GestureTapCancelCallback>",
"onSecondaryTapDown": "<GestureTapDownCallback>",
"onSecondaryTapUp": "<GestureTapUpCallback>",
"onTap": "<GestureTapCallback>",
"onTapCancel": "<GestureTapCancelCallback>",
"onTapDown": "<GestureTapDownCallback>",
"onTapUp": "<GestureTapUpCallback>",
"onTertiaryLongPress": "<GestureLongPressCallback>",
"onTertiaryLongPressCancel": "<GestureLongPressCancelCallback>",
"onTertiaryLongPressDown": "<GestureLongPressDownCallback>",
"onTertiaryLongPressEnd": "<GestureLongPressEndCallback>",
"onTertiaryLongPressMoveUpdate": "<GestureLongPressMoveUpdateCallback>",
"onTertiaryLongPressStart": "<GestureLongPressStartCallback>",
"onTertiaryLongPressUp": "<GestureLongPressUpCallback>",
"onTertiaryTapCancel": "<GestureTapCancelCallback>",
"onTertiaryTapDown": "<GestureTapDownCallback>",
"onTertiaryTapUp": "<GestureTapUpCallback>",
"onVerticalDragCancel": "<GestureDragCancelCallback>",
"onVerticalDragDown": "<GestureDragDownCallback>",
"onVerticalDragEnd": "<GestureDragEndCallback>",
"onVerticalDragStart": "<GestureDragStartCallback>",
"onVerticalDragUpdate": "<GestureDragUpdateCallback>",
"supportedDevices": "<List<PointerDeviceKind>>"
}
As a note, none of the Gesture*Callback
classes can 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.decodeDragStartBehavior
ThemeDecoder.decodeHitTestBehavior
Implementation
static JsonGestureDetectorBuilder? fromDynamic(
dynamic map, {
JsonWidgetRegistry? registry,
}) {
JsonGestureDetectorBuilder? result;
if (map != null) {
result = JsonGestureDetectorBuilder(
behavior: ThemeDecoder.decodeHitTestBehavior(
map['behavior'],
validate: false,
),
dragStartBehavior: ThemeDecoder.decodeDragStartBehavior(
map['dragStartBehavior'],
validate: false,
) ??
DragStartBehavior.start,
excludeFromSemantics: JsonClass.parseBool(map['excludeFromSemantics']),
onDoubleTap: map['onDoubleTap'],
onDoubleTapCancel: map['onDoubleTapCancel'],
onDoubleTapDown: map['onDoubleTapDown'],
onForcePressEnd: map['onForcePressEnd'],
onForcePressPeak: map['onForcePressPeak'],
onForcePressStart: map['onForcePressStart'],
onForcePressUpdate: map['onForcePressUpdate'],
onHorizontalDragCancel: map['onHorizontalDragCancel'],
onHorizontalDragDown: map['onHorizontalDragDown'],
onHorizontalDragEnd: map['onHorizontalDragEnd'],
onHorizontalDragStart: map['onHorizontalDragStart'],
onHorizontalDragUpdate: map['onHorizontalDragUpdate'],
onLongPress: map['onLongPress'],
onLongPressCancel: map['onLongPressCancel'],
onLongPressDown: map['onLongPressDown'],
onLongPressEnd: map['onLongPressEnd'],
onLongPressMoveUpdate: map['onLongPressMoveUpdate'],
onLongPressStart: map['onLongPressStart'],
onLongPressUp: map['onLongPressUp'],
onPanCancel: map['onPanCancel'],
onPanDown: map['onPanDown'],
onPanEnd: map['onPanEnd'],
onPanStart: map['onPanStart'],
onPanUpdate: map['onPanUpdate'],
onScaleEnd: map['onScaleEnd'],
onScaleStart: map['onScaleStart'],
onScaleUpdate: map['onScaleUpdate'],
onSecondaryLongPress: map['onSecondaryLongPress'],
onSecondaryLongPressCancel: map['onSecondaryLongPressCancel'],
onSecondaryLongPressDown: map['onSecondaryLongPressDown'],
onSecondaryLongPressEnd: map['onSecondaryLongPressEnd'],
onSecondaryLongPressMoveUpdate: map['onSecondaryLongPressMoveUpdate'],
onSecondaryLongPressStart: map['onSecondaryLongPressStart'],
onSecondaryLongPressUp: map['onSecondaryLongPressUp'],
onSecondaryTap: map['onSecondaryTap'],
onSecondaryTapCancel: map['onSecondaryTapChannel'],
onSecondaryTapDown: map['onSecondartyTapDown'],
onSecondaryTapUp: map['onSecondaryTapUp'],
onTap: map['onTap'],
onTapCancel: map['onTapCancel'],
onTapDown: map['onTapDown'],
onTapUp: map['onTapUp'],
onTertiaryLongPress: map['onTertiaryLongPress'],
onTertiaryLongPressCancel: map['onTertiaryLongPressCancel'],
onTertiaryLongPressDown: map['onTertiaryLongPressDown'],
onTertiaryLongPressEnd: map['onTertiaryLongPressEnd'],
onTertiaryLongPressMoveUpdate: map['onTertiaryLongPressMoveUpdate'],
onTertiaryLongPressStart: map['onTertiaryLongPressStart'],
onTertiaryLongPressUp: map['onTertiaryLongPressUp'],
onTertiaryTapCancel: map['onTertiaryTapCancel'],
onTertiaryTapDown: map['onTertiaryTapDown'],
onTertiaryTapUp: map['onTertiaryTapUp'],
onVerticalDragCancel: map['onVerticalDragCancel'],
onVerticalDragDown: map['onVerticalDragDown'],
onVerticalDragEnd: map['onVerticalDragEnd'],
onVerticalDragStart: map['onVerticalDragStart'],
onVerticalDragUpdate: map['onVerticalDragUpdate'],
supportedDevices: map['supportedDevices'] == null
? null
: Set<PointerDeviceKind>.from(
(map['supportedDevices'] as Iterable).map(
(e) => ThemeDecoder.decodePointerDeviceKind(
e,
validate: false,
)!,
),
),
);
}
return result;
}