fromJson static method

PerlearnerUserListData? fromJson(
  1. dynamic value
)

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

Implementation

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

    return PerlearnerUserListData(
      username: mapValueOfType<String>(json, r'username')!,
      fullName: mapValueOfType<String>(json, r'full_name')!,
      enrollments: mapValueOfType<int>(json, r'enrollments')!,
      completions: mapValueOfType<int>(json, r'completions')!,
      lastActive: mapValueOfType<String>(json, r'last_active')!,
      timeSpent: mapValueOfType<String>(json, r'time_spent')!,
      engagementIndex: mapValueOfType<double>(json, r'engagement_index')!,
      performanceIndex: mapValueOfType<double>(json, r'performance_index')!,
    );
  }
  return null;
}