fromJson static method

PageUsersOnlineResponse? fromJson(
  1. dynamic value
)

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

Implementation

// ignore: prefer_constructors_over_static_methods
static PageUsersOnlineResponse? 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'nextAfterUserId'), 'Required key "PageUsersOnlineResponse[nextAfterUserId]" is missing from JSON.');
      assert(json.containsKey(r'nextAfterName'), 'Required key "PageUsersOnlineResponse[nextAfterName]" is missing from JSON.');
      assert(json.containsKey(r'totalCount'), 'Required key "PageUsersOnlineResponse[totalCount]" is missing from JSON.');
      assert(json[r'totalCount'] != null, 'Required key "PageUsersOnlineResponse[totalCount]" has a null value in JSON.');
      assert(json.containsKey(r'anonCount'), 'Required key "PageUsersOnlineResponse[anonCount]" is missing from JSON.');
      assert(json[r'anonCount'] != null, 'Required key "PageUsersOnlineResponse[anonCount]" has a null value in JSON.');
      assert(json.containsKey(r'users'), 'Required key "PageUsersOnlineResponse[users]" is missing from JSON.');
      assert(json[r'users'] != null, 'Required key "PageUsersOnlineResponse[users]" has a null value in JSON.');
      assert(json.containsKey(r'status'), 'Required key "PageUsersOnlineResponse[status]" is missing from JSON.');
      assert(json[r'status'] != null, 'Required key "PageUsersOnlineResponse[status]" has a null value in JSON.');
      return true;
    }());

    return PageUsersOnlineResponse(
      nextAfterUserId: mapValueOfType<String>(json, r'nextAfterUserId'),
      nextAfterName: mapValueOfType<String>(json, r'nextAfterName'),
      totalCount: mapValueOfType<double>(json, r'totalCount')!,
      anonCount: mapValueOfType<double>(json, r'anonCount')!,
      users: PageUserEntry.listFromJson(json[r'users']),
      status: APIStatus.fromJson(json[r'status'])!,
    );
  }
  return null;
}