fromDynamic static method

JsonContainerBuilder? 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:

{
  "alignment": "<Alignment>",
  "clipBehavior": "<Clip>",
  "color": "<Color>",
  "constraints": "<BoxConstraints>",
  "decoration": "<BoxDecoration>",
  "foregroundDecoration": "<BoxDecoration>",
  "height": "<double>",
  "margin": "<EdgeInsetsGeometry>",
  "padding": "<EdgeInsetsGeometry>",
  "transform": "<Matrix4>",
  "transformAlignment": "<TransformAlignment>",
  "width": "<double>"
}

See also:

  • ThemeDecoder.decodeAlignment
  • ThemeDecoder.decodeBoxConstraints
  • ThemeDecoder.decodeBoxDirection
  • ThemeDecoder.decodeClip
  • ThemeDecoder.decodeColor
  • ThemeDecoder.decodeEdgeInsetsGeometry
  • ThemeDecoder.decodeMatrix4

Implementation

static JsonContainerBuilder? fromDynamic(
  dynamic map, {
  JsonWidgetRegistry? registry,
}) {
  JsonContainerBuilder? result;
  if (map != null) {
    result = JsonContainerBuilder(
      alignment: ThemeDecoder.decodeAlignment(
        map['alignment'],
        validate: false,
      ),
      clipBehavior: ThemeDecoder.decodeClip(
            map['clipBehavior'],
            validate: false,
          ) ??
          Clip.none,
      color: ThemeDecoder.decodeColor(
        map['color'],
        validate: false,
      ),
      constraints: ThemeDecoder.decodeBoxConstraints(
        map['constraints'],
        validate: false,
      ),
      decoration: ThemeDecoder.decodeBoxDecoration(
        map['decoration'],
        validate: false,
      ),
      foregroundDecoration: ThemeDecoder.decodeBoxDecoration(
        map['foregroundDecoration'],
        validate: false,
      ),
      height: JsonClass.maybeParseDouble(map['height']),
      margin: ThemeDecoder.decodeEdgeInsetsGeometry(
        map['margin'],
        validate: false,
      ) as EdgeInsets?,
      padding: ThemeDecoder.decodeEdgeInsetsGeometry(
        map['padding'],
        validate: false,
      ) as EdgeInsets?,
      transform: ThemeDecoder.decodeMatrix4(
        map['transform'],
        validate: false,
      ),
      transformAlignment: ThemeDecoder.decodeAlignment(
        map['transformAlignment'],
        validate: false,
      ),
      width: JsonClass.maybeParseDouble(map['width']),
    );
  }

  return result;
}