fromJson static method
Returns a new ModemNetworkBearersStats instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static ModemNetworkBearersStats? 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 "ModemNetworkBearersStats[$key]" is missing from JSON.');
assert(json[key] != null,
'Required key "ModemNetworkBearersStats[$key]" has a null value in JSON.');
});
return true;
}());
return ModemNetworkBearersStats(
duration: json[r'duration'] == null
? null
: num.parse(json[r'duration'].toString()),
rxBytes: json[r'rx-bytes'] == null
? null
: num.parse(json[r'rx-bytes'].toString()),
txBytes: json[r'tx-bytes'] == null
? null
: num.parse(json[r'tx-bytes'].toString()),
attempts: json[r'attempts'] == null
? null
: num.parse(json[r'attempts'].toString()),
failedAttempts: json[r'failed-attempts'] == null
? null
: num.parse(json[r'failed-attempts'].toString()),
totalDuration: json[r'total-duration'] == null
? null
: num.parse(json[r'total-duration'].toString()),
totalRxBytes: json[r'total-rx-bytes'] == null
? null
: num.parse(json[r'total-rx-bytes'].toString()),
totalTxBytes: json[r'total-tx-bytes'] == null
? null
: num.parse(json[r'total-tx-bytes'].toString()),
);
}
return null;
}