copyWith method

Token copyWith({
  1. String? accessToken,
  2. String? refreshToken,
  3. DateTime? expiresAt,
  4. List<String>? scopes,
  5. bool clearRefreshToken = false,
  6. bool clearExpiresAt = false,
})

Returns a copy with the supplied fields replaced.

Use clearRefreshToken / clearExpiresAt to explicitly null those fields (regular null arguments are treated as "no change").

Implementation

Token copyWith({
  String? accessToken,
  String? refreshToken,
  DateTime? expiresAt,
  List<String>? scopes,
  bool clearRefreshToken = false,
  bool clearExpiresAt = false,
}) {
  return Token(
    accessToken: accessToken ?? this.accessToken,
    refreshToken:
        clearRefreshToken ? null : (refreshToken ?? this.refreshToken),
    expiresAt: clearExpiresAt ? null : (expiresAt ?? this.expiresAt),
    scopes: scopes ?? this.scopes,
  );
}