fromDynamic static method

JsonFloatingActionButtonBuilder? 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>,
  "backgroundColor": <Color>,
  "clipBehavior": <Clip>,
  "disabledElevation": <double>,
  "elevation": <double>,
  "enableFeedback": <bool>,
  "focusColor": <Color>,
  "focusElevation": <double>,
  "focusNode": <FocusNode>,
  "foregroundColor": <Color>,
  "heroTag": <Object>,
  "highlightElevation": <double>,
  "hoverColor": <Color>,
  "hoverElevation": <double>,
  "isExtended": <bool>,
  "materialTapTargetSize": <MaterialTapTargetSize>,
  "mini": <bool>,
  "mouseCursor": <MouseCursor>,
  "onPressed": <VoidCallback>,
  "shape": <ShapeBorder>,
  "splashColor": <Color>,
  "tooltip": <String>
}

As a note, the FocusNode, Object, 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.decodeClip
  • ThemeDecoder.decodeColor
  • ThemeDecoder.decodeMaterialTapTargetSize
  • ThemeDecoder.decodeMouseCursor
  • ThemeDecoder.decodeShapeBorder

Implementation

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

  if (map != null) {
    result = JsonFloatingActionButtonBuilder(
      autofocus: JsonClass.parseBool(
        map['autofocus'],
      ),
      backgroundColor: ThemeDecoder.decodeColor(
        map['backgroundColor'],
        validate: false,
      ),
      clipBehavior: ThemeDecoder.decodeClip(
            map['clipBehavior'],
            validate: false,
          ) ??
          Clip.none,
      disabledElevation: JsonClass.parseDouble(
        map['disabledElevation'],
      ),
      elevation: JsonClass.parseDouble(
        map['elevation'],
      ),
      enableFeedback: map['enableFeedback'] == null
          ? null
          : JsonClass.parseBool(map['enableFeedback']),
      focusColor: ThemeDecoder.decodeColor(
        map['focusColor'],
        validate: false,
      ),
      focusElevation: JsonClass.parseDouble(
        map['focusElevation'],
      ),
      focusNode: map['focusNode'],
      foregroundColor: ThemeDecoder.decodeColor(
        map['foregroundColor'],
        validate: false,
      ),
      heroTag: map['heroTag'] ??
          FloatingActionButton(
            onPressed: null,
          ).heroTag,
      highlightElevation: JsonClass.parseDouble(
        map['highlightElevation'],
      ),
      hoverColor: ThemeDecoder.decodeColor(
        map['hoverColor'],
        validate: false,
      ),
      hoverElevation: JsonClass.parseDouble(
        map['hoverElevation'],
      ),
      isExtended: JsonClass.parseBool(
        map['isExtended'],
      ),
      materialTapTargetSize: ThemeDecoder.decodeMaterialTapTargetSize(
        map['materialTapTargetSize'],
        validate: false,
      ),
      mini: JsonClass.parseBool(map['mini']),
      mouseCursor: ThemeDecoder.decodeMouseCursor(
        map['mouseCursor'],
        validate: false,
      ),
      onPressed: map['onPressed'],
      shape: ThemeDecoder.decodeShapeBorder(
        map['shape'],
        validate: false,
      ),
      splashColor: ThemeDecoder.decodeColor(
        map['splashColor'],
        validate: false,
      ),
      tooltip: map['tooltip'],
    );
  }

  return result;
}