fromDynamic static method

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

{
  "animationDuration": <int; millis>,
  "borderOnForeground": <bool>,
  "borderRadius": <BorderRadius>,
  "clipBehavior": <Clip>,
  "color": <Color>,
  "elevation": <double>,
  "margin": <EdgeInsetsGeometry>,
  "materialType": <MaterialType>,
  "padding": <EdgeInsetsGeometry>,
  "shadowColor": <Color>,
  "shape": <ShapeBorder>,
  "textStyle": <TextStyle>
}

See also:

  • ThemeDecoder.decodeBorderRadius
  • ThemeDecoder.decodeClip
  • ThemeDecoder.decodeColor
  • ThemeDecoder.decodeEdgeInsetsGeometry
  • ThemeDecoder.decodeMaterialType
  • ThemeDecoder.decodeShapeBorder
  • ThemeDecoder.decodeTextStyle

Implementation

static JsonMaterialBuilder? fromDynamic(
  dynamic map, {
  JsonWidgetRegistry? registry,
}) {
  JsonMaterialBuilder? result;
  if (map != null) {
    result = JsonMaterialBuilder(
      animationDuration: JsonClass.parseDurationFromMillis(
          map['animationDuration'], kThemeChangeDuration)!,
      borderOnForeground: map['borderOnForeground'] == null
          ? true
          : JsonClass.parseBool(
              map['borderOnForeground'],
            ),
      borderRadius: ThemeDecoder.decodeBorderRadius(
        map['borderRadius'],
        validate: false,
      ),
      clipBehavior: ThemeDecoder.decodeClip(
            map['clipBehavior'],
            validate: false,
          ) ??
          Clip.none,
      color: ThemeDecoder.decodeColor(
        map['color'],
        validate: false,
      ),
      elevation: JsonClass.parseDouble(map['elevation'], 0)!,
      margin: ThemeDecoder.decodeEdgeInsetsGeometry(
        map['margin'],
        validate: false,
      ),
      materialType: ThemeDecoder.decodeMaterialType(
            map['type'],
            validate: false,
          ) ??
          MaterialType.canvas,
      padding: ThemeDecoder.decodeEdgeInsetsGeometry(
        map['padding'],
        validate: false,
      ),
      shadowColor: ThemeDecoder.decodeColor(
            map['color'],
            validate: false,
          ) ??
          const Color(0xFF000000),
      shape: ThemeDecoder.decodeShapeBorder(
        map['shape'],
        validate: false,
      ),
      textStyle: ThemeDecoder.decodeTextStyle(
        map['textStyle'],
        validate: false,
      ),
    );
  }

  return result;
}