fromJson static method

StepView? fromJson(
  1. dynamic value
)

Returns a new StepView instance and imports its values from value if it's a Map, null otherwise.

Implementation

// ignore: prefer_constructors_over_static_methods
static StepView? fromJson(dynamic value) {
  if (value is Map) {
    final json = value.cast<String, dynamic>();

    // Ensure that the map contains the required keys.
    // Note 1: the values aren't checked for validity beyond being non-null.
    // Note 2: this code is stripped in release mode!
    assert(() {
      requiredKeys.forEach((key) {
        assert(json.containsKey(key), 'Required key "StepView[$key]" is missing from JSON.');
        assert(json[key] != null, 'Required key "StepView[$key]" has a null value in JSON.');
      });
      return true;
    }());

    return StepView(
      args: mapCastOfType<String, Object>(json, r'args') ?? const {},
      automatable: mapValueOfType<bool>(json, r'automatable'),
      available: mapValueOfType<bool>(json, r'available'),
      blockedBy: json[r'blockedBy'] is Iterable
          ? (json[r'blockedBy'] as Iterable).cast<String>().toList(growable: false)
          : const [],
      deps: json[r'deps'] is Iterable
          ? (json[r'deps'] as Iterable).cast<String>().toList(growable: false)
          : const [],
      detail: mapValueOfType<String>(json, r'detail'),
      draft: mapValueOfType<String>(json, r'draft'),
      draftInto: mapValueOfType<String>(json, r'draftInto'),
      enabled: mapValueOfType<bool>(json, r'enabled'),
      id: mapValueOfType<String>(json, r'id'),
      section: mapValueOfType<String>(json, r'section'),
      signal: mapValueOfType<String>(json, r'signal'),
      source_: mapValueOfType<String>(json, r'source'),
      state: mapValueOfType<String>(json, r'state'),
      title: mapValueOfType<String>(json, r'title'),
      tool: mapValueOfType<String>(json, r'tool'),
    );
  }
  return null;
}