fromJson static method

ParticipantSeriesTimeframe? fromJson(
  1. dynamic value
)

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

Implementation

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

    return ParticipantSeriesTimeframe(
      maxPoints: mapValueOfType<int>(json, r'max_points')!,
      since: mapDateTime(json, r'since', r'')!,
      stepSeconds: mapValueOfType<int>(json, r'step_seconds')!,
      until: mapDateTime(json, r'until', r'')!,
    );
  }
  return null;
}