fromDynamic static method

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

{
  "color": <Color>,
  "fallbackHeight": <double>,
  "fallbackWidth": <double>,
  "strokeWidth": <double>
}

See also:

  • ThemeDecoder.decodeColor

Implementation

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

  if (map != null) {
    result = JsonPlaceholderBuilder(
      color: ThemeDecoder.decodeColor(
            map['color'],
            validate: false,
          ) ??
          Color(0xFF455A64),
      fallbackHeight: JsonClass.parseDouble(
        map['fallbackHeight'],
        400.0,
      )!,
      fallbackWidth: JsonClass.parseDouble(
        map['fallbackWidth'],
        400.0,
      )!,
      strokeWidth: JsonClass.parseDouble(
        map['strokeWidth'],
        2.0,
      )!,
    );
  }

  return result;
}