fromDynamic method

Test fromDynamic (
  1. dynamic map,
  2. {bool ignoreImages: false}
)

Creates a test from a map-like object. The map must support the [] operator if it is not null.

This expects a JSON-like object in the following form:

{
  "active": <bool>,
  "name": <String>,
  "steps": <List<TestStep>>,
  "suiteName": <String>,
  "timestamp": <number; millis since epoch>,
  "version": <number>
}

Implementation

static Test fromDynamic(
  dynamic map, {
  bool ignoreImages = false,
}) {
  Test result;

  if (map != null) {
    result = Test(
      active:
          map['active'] == null ? true : JsonClass.parseBool(map['active']),
      name: map['name'],
      steps: JsonClass.fromDynamicList(
          map['steps'],
          (map) => TestStep.fromDynamic(
                map,
                ignoreImages: ignoreImages,
              )),
      suiteName: map['suiteName'],
      timestamp: JsonClass.parseUtcMillis(
        map['timestamp'],
        DateTime.now().millisecondsSinceEpoch,
      ),
      version: JsonClass.parseInt(map['version'], 1),
    );
  }

  return result;
}