fromJson static method

ModemNetworkModem? fromJson(
  1. dynamic value
)

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

Implementation

// ignore: prefer_constructors_over_static_methods
static ModemNetworkModem? 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 "ModemNetworkModem[$key]" is missing from JSON.');
        assert(json[key] != null,
            'Required key "ModemNetworkModem[$key]" has a null value in JSON.');
      });
      return true;
    }());

    return ModemNetworkModem(
      currentCapabilities:
          ModemCapability.listFromJson(json[r'currentCapabilities']) ??
              const [],
      supportedCapabilities:
          ModemCapability.listFromJson(json[r'supportedCapabilities']) ??
              const [],
      manufacturer: mapValueOfType<String>(json, r'manufacturer'),
      model: mapValueOfType<String>(json, r'model'),
      revision: mapValueOfType<String>(json, r'revision'),
      carrierConfiguration:
          mapValueOfType<String>(json, r'carrierConfiguration'),
      carrierConfigurationRevision:
          mapValueOfType<String>(json, r'carrierConfigurationRevision'),
      hardwareRevision: mapValueOfType<String>(json, r'hardwareRevision'),
      deviceIdentifier: mapValueOfType<String>(json, r'deviceIdentifier'),
      equipmentIdentifier:
          mapValueOfType<String>(json, r'equipmentIdentifier'),
      stateFailedReason: mapValueOfType<String>(json, r'stateFailedReason'),
      state: mapValueOfType<String>(json, r'state'),
      accessTechnologies:
          ModemAccessTechnology.listFromJson(json[r'accessTechnologies']) ??
              const [],
      signalQuality: mapValueOfType<String>(json, r'signalQuality'),
      supportedModes:
          ModemMode.listFromJson(json[r'supportedModes']) ?? const [],
      currentModes: ModemMode.listFromJson(json[r'currentModes']) ?? const [],
      supportedBands:
          ModemBand.listFromJson(json[r'supportedBands']) ?? const [],
      currentBands: ModemBand.listFromJson(json[r'currentBands']) ?? const [],
    );
  }
  return null;
}