fromDynamic static method

JsonOutlinedButtonBuilder? 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>,
  "clipBehavior": <Clip>,
  "focusNode": <FocusNode>,
  "onFocusChange": <ValueChanged<bool>>,
  "onHover": <ValueChanged<bool>>,
  "onLongPress": <VoidCallback>,
  "onPressed": <VoidCallback>,
  "style": <ButtonStyle>
}

As a note, the FocusNode 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.decodeButtonStyle
  • ThemeDecoder.decodeClip

Implementation

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

  if (map != null) {
    result = JsonOutlinedButtonBuilder(
      autofocus: map['autofocus'] == null
          ? false
          : JsonClass.parseBool(
              map['autofocus'],
            ),
      clipBehavior: ThemeDecoder.decodeClip(
            map['clipBehavior'],
          ) ??
          Clip.none,
      focusNode: map['focusNode'],
      onFocusChange: map['onFocusChange'],
      onHover: map['onHover'],
      onLongPress: map['onLongPress'],
      onPressed: map['onPressed'],
      style: ThemeDecoder.decodeButtonStyle(
        map['style'],
        validate: false,
      ),
    );
  }

  return result;
}