copyWith method

Token copyWith({
  1. String? accessToken,
  2. String? refreshToken,
  3. DateTime? expiresAt,
  4. List<String>? scopes,
  5. Map<String, dynamic>? metadata,
  6. bool clearRefreshToken = false,
  7. 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,
  Map<String, dynamic>? metadata,
  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,
    metadata: metadata ?? this.metadata,
  );
}