fromDynamic static method

JsonInkWellBuilder? fromDynamic(
  1. dynamic map, {
  2. JsonWidgetRegistry? registry,
})

Builds the builder from a Map-like dynamic structure. This expects the JSON format to be of the following structure:

{
  "autofocus": <bool>,
  "borderRadius": <BorderRadius>,
  "canRequestFocus": <bool>,
  "customBorder": <ShapeBorder>,
  "enableFeedback": <bool>,
  "excludeFromSemantics": <bool>,
  "focusColor": <Color>,
  "focusNode": <FocusNode>,
  "highlightColor": <Color>,
  "hoverColor": <Color>,
  "mouseCursor": <MouseCursor>,
  "onDoubleTap": <GestureTapCallback>,
  "onFocusChange": <ValueChanged<bool>>,
  "onHighlightChanged": <ValueChanged<bool>>,
  "onHover": <ValueChanged<bool>>,
  "onLongPress": <GestureLongPressCallback>,
  "onTap": <GestureTapCallback>,
  "onTapCancel": <GestureTapCancelCallback>,
  "onTapDown": <GestureTapDownCallback>,
  "overlayColor": <MaterialStatePropertyColor>,
  "radius": <double>,
  "splashColor": <Color>,
  "splashFactory": <InteractiveInkFeatureFactory>
}

As a note, the FocusNode, GestureTapCallback, GestureLongPressCallback, GestureTapCancelCallback, GestureTapDownCallback, ValueCallback<bool>, 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.decodeBorderRadius
  • ThemeDecoder.decodeColor
  • ThemeDecoder.decodeInteractiveInkFeatureFactory
  • ThemeDecoder.decodeMouseCursor
  • ThemeDecoder.decodeShapeBorder

Implementation

static JsonInkWellBuilder? fromDynamic(
  dynamic map, {
  JsonWidgetRegistry? registry,
}) {
  JsonInkWellBuilder? result;

  if (map != null) {
    result = JsonInkWellBuilder(
      autofocus: JsonClass.parseBool(map['autofocus']),
      borderRadius: ThemeDecoder.decodeBorderRadius(
        map['borderRadius'],
        validate: false,
      ),
      canRequestFocus: map['canRequestFocus'] == null
          ? true
          : JsonClass.parseBool(map['canRequestFocus']),
      customBorder: ThemeDecoder.decodeShapeBorder(
        map['customBorder'],
        validate: false,
      ),
      enableFeedback: map['enableFeedback'] == null
          ? true
          : JsonClass.parseBool(map['enableFeedback']),
      excludeFromSemantics: JsonClass.parseBool(map['excludeFromSemantics']),
      focusColor: ThemeDecoder.decodeColor(
        map['focusColor'],
        validate: false,
      ),
      focusNode: map['focusNode'],
      highlightColor: ThemeDecoder.decodeColor(
        map['highlightColor'],
        validate: false,
      ),
      hoverColor: ThemeDecoder.decodeColor(
        map['hoverColor'],
        validate: false,
      ),
      mouseCursor: ThemeDecoder.decodeMouseCursor(
        map['mouseCursor'],
        validate: false,
      ),
      onDoubleTap: map['onDoubleTap'],
      onFocusChange: map['onFocusChange'],
      onHighlightChanged: map['onHighlightChanged'],
      onHover: map['onHover'],
      onLongPress: map['onLongPress'],
      onTap: map['onTap'],
      onTapCancel: map['onTapCancel'],
      onTapDown: map['onTapDown'],
      overlayColor: ThemeDecoder.decodeMaterialStatePropertyColor(
        map['overlayColor'],
        validate: false,
      ),
      radius: JsonClass.parseDouble(map['radius']),
      splashColor: ThemeDecoder.decodeColor(
        map['splashColor'],
        validate: false,
      ),
      splashFactory: ThemeDecoder.decodeInteractiveInkFeatureFactory(
        map['splashFactory'],
        validate: false,
      ),
    );
  }

  return result;
}