fromDynamic static method

JsonListTileBuilder? 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>",
  "contentPadding": "<EdgeInsetsGeometry>",
  "dense": "<bool>",
  "enableFeedback": "<bool>",
  "enabled": "<bool>",
  "focusNode": "<Color>",
  "focusNode": "<FocusNode>",
  "horizontalTitleGap": "<double>",
  "hoverColor": "<Color>",
  "iconColor": "<Color>",
  "isThreeLine": "<bool>",
  "leading": "<JsonWidgetData>",
  "minLeadingWidth": "<double>",
  "minVerticalPadding": "<double>",
  "mouseCursor": "<MouseCursor>",
  "onLongPress": "<VoidCallback>",
  "onTap": "<VoidCallback>",
  "selectedColor": "<Color>",
  "selected": "<bool>",
  "selectedTileColor": "<Color>",
  "shape": "<ShapeBorder>",
  "splashColor": "<Color>",
  "style": "<ListTileStyle>",
  "subtitle": "<JsonWidgetData>",
  "textColor": "<Color>",
  "tileColor": "<Color>",
  "title": "<JsonWidgetData>",
  "trailing": "<JsonWidgetData>",
  "visualDensity": "<VisualDensity>"
}

As a note, the VoidCallback and FocusNode objects 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:

  • JsonWidgetData.fromDynamic
  • ThemeDecoder.decodeColor
  • ThemeDecoder.decodeEdgeInsetsGeometry
  • ThemeDecoder.decodeListTileStyle
  • ThemeDecoder.decodeMouseCursor
  • ThemeDecoder.decodeShapeBorder
  • ThemeDecoder.decodeVisualDensity

Implementation

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

  if (map != null) {
    result = JsonListTileBuilder(
      autofocus: JsonClass.parseBool(map['autofocus']),
      contentPadding: ThemeDecoder.decodeEdgeInsetsGeometry(
        map['contentPadding'],
        validate: false,
      ),
      dense: JsonClass.parseBool(map['dense']),
      enableFeedback: map['enableFeedback'] == null
          ? true
          : JsonClass.parseBool(
              map['enableFeedback'],
            ),
      enabled: map['enabled'] == null
          ? true
          : JsonClass.parseBool(
              map['enabled'],
            ),
      focusColor: ThemeDecoder.decodeColor(
        map['focusColor'],
        validate: false,
      ),
      focusNode: map['focusNode'],
      horizontalTitleGap:
          JsonClass.maybeParseDouble(map['horizontalTitleGap']),
      hoverColor: ThemeDecoder.decodeColor(
        map['hoverColor'],
        validate: false,
      ),
      iconColor: ThemeDecoder.decodeColor(
        map['iconColor'],
        validate: false,
      ),
      isThreeLine: JsonClass.parseBool(map['isThreeLine']),
      leading: JsonWidgetData.fromDynamic(
        map['leading'],
        registry: registry,
      ),
      minLeadingWidth: JsonClass.maybeParseDouble(map['minLeadingWidth']),
      minVerticalPadding:
          JsonClass.maybeParseDouble(map['minVerticalPadding']),
      mouseCursor: ThemeDecoder.decodeMouseCursor(
        map['mouseCursor'],
        validate: false,
      ),
      onLongPress: map['onLongPress'],
      onTap: map['onTap'],
      selected: JsonClass.parseBool(map['selected']),
      selectedColor: ThemeDecoder.decodeColor(
        map['selectedColor'],
        validate: false,
      ),
      selectedTileColor: ThemeDecoder.decodeColor(
        map['selectedTileColor'],
        validate: false,
      ),
      shape: ThemeDecoder.decodeShapeBorder(
        map['shape'],
        validate: false,
      ),
      splashColor: ThemeDecoder.decodeColor(
        map['splashColor'],
        validate: false,
      ),
      style: ThemeDecoder.decodeListTileStyle(
        map['style'],
        validate: false,
      ),
      subtitle: JsonWidgetData.fromDynamic(
        map['subtitle'],
        registry: registry,
      ),
      textColor: ThemeDecoder.decodeColor(
        map['textColor'],
        validate: false,
      ),
      tileColor: ThemeDecoder.decodeColor(
        map['tileColor'],
        validate: false,
      ),
      title: JsonWidgetData.fromDynamic(
        map['title'],
        registry: registry,
      ),
      trailing: JsonWidgetData.fromDynamic(
        map['trailing'],
        registry: registry,
      ),
      visualDensity: ThemeDecoder.decodeVisualDensity(
        map['visualDensity'],
        validate: false,
      ),
    );
  }

  return result;
}