fromJson static method
Returns a new ClientRegistrationResponse instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static ClientRegistrationResponse? 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'client_id'), 'Required key "ClientRegistrationResponse[client_id]" is missing from JSON.');
assert(json[r'client_id'] != null, 'Required key "ClientRegistrationResponse[client_id]" has a null value in JSON.');
assert(json.containsKey(r'client_name'), 'Required key "ClientRegistrationResponse[client_name]" is missing from JSON.');
assert(json[r'client_name'] != null, 'Required key "ClientRegistrationResponse[client_name]" has a null value in JSON.');
assert(json.containsKey(r'redirect_uris'), 'Required key "ClientRegistrationResponse[redirect_uris]" is missing from JSON.');
assert(json[r'redirect_uris'] != null, 'Required key "ClientRegistrationResponse[redirect_uris]" has a null value in JSON.');
assert(json.containsKey(r'registration_access_token'), 'Required key "ClientRegistrationResponse[registration_access_token]" is missing from JSON.');
assert(json[r'registration_access_token'] != null, 'Required key "ClientRegistrationResponse[registration_access_token]" has a null value in JSON.');
assert(json.containsKey(r'client_id_issued_at'), 'Required key "ClientRegistrationResponse[client_id_issued_at]" is missing from JSON.');
assert(json[r'client_id_issued_at'] != null, 'Required key "ClientRegistrationResponse[client_id_issued_at]" has a null value in JSON.');
return true;
}());
return ClientRegistrationResponse(
clientId: mapValueOfType<String>(json, r'client_id')!,
clientSecret: mapValueOfType<String>(json, r'client_secret'),
clientName: mapValueOfType<String>(json, r'client_name')!,
redirectUris: json[r'redirect_uris'] is Iterable
? (json[r'redirect_uris'] as Iterable).cast<String>().toList(growable: false)
: const [],
grantTypes: json[r'grant_types'] is Iterable
? (json[r'grant_types'] as Iterable).cast<String>().toList(growable: false)
: const [],
responseTypes: json[r'response_types'] is Iterable
? (json[r'response_types'] as Iterable).cast<String>().toList(growable: false)
: const [],
scope: mapValueOfType<String>(json, r'scope'),
tokenEndpointAuthMethod: mapValueOfType<String>(json, r'token_endpoint_auth_method'),
registrationAccessToken: mapValueOfType<String>(json, r'registration_access_token')!,
registrationClientUri: mapValueOfType<String>(json, r'registration_client_uri'),
clientIdIssuedAt: mapValueOfType<int>(json, r'client_id_issued_at')!,
);
}
return null;
}