fromDynamic static method

CaptureWidgetStep fromDynamic(
  1. dynamic map
)

Creates an instance from a JSON-like map structure. This expects the following format:

{
  "backgroundColor": <String>,
  "goldenCompatible": <bool>,
  "imageId": <String>,
  "testableId": <String>,
  "timeout": <number>
}

See also:

  • JsonClass.parseDurationFromSeconds
  • ThemeDecoder.decodeColor

Implementation

static CaptureWidgetStep fromDynamic(dynamic map) {
  CaptureWidgetStep result;

  if (map == null) {
    throw Exception('[CaptureWidgetStep.fromDynamic]: map is null');
  } else {
    result = CaptureWidgetStep(
      backgroundColor: ThemeDecoder.decodeColor(map['backgroundColor']),
      goldenCompatible: map['goldenCompatible'] == null
          ? true
          : JsonClass.parseBool(map['goldenCompatible']),
      imageId: map['imageId'],
      testableId: map['testableId'],
      timeout: JsonClass.parseDurationFromSeconds(map['timeout']),
    );
  }

  return result;
}