asMap method Null safety

Map<String, dynamic> asMap()

Emits this instance as a Map according to the OAuth 2.0 specification.

Implementation

Map<String, dynamic> asMap() {
  final map = {
    "access_token": accessToken,
    "token_type": type,
    "expires_in":
        expirationDate!.difference(DateTime.now().toUtc()).inSeconds,
  };

  if (refreshToken != null) {
    map["refresh_token"] = refreshToken;
  }

  if (scopes != null) {
    map["scope"] = scopes!.map((s) => s.toString()).join(" ");
  }

  return map;
}