AuthDataWatcher class

A singleton class responsible for watching and refreshing the access token when it expires. This class periodically checks if the token has expired and attempts to fetch a new one if necessary.

Constructors

AuthDataWatcher()

Properties

expiration DateTime?
The expiration time of the current access token.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
periodicTimer Timer?
Timer that triggers periodic checks for access token expiration.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
token String?
The current access token.
getter/setter pair

Methods

getNewAccessToken(String accessToken) Future<String?>
Attempts to refresh the access token using the provided accessToken. This method calls an API to request a new token and returns it via a Completer.
isAccessTokenExpired(Duration margin) bool
Checks if the access token is expired by comparing the current time with the expiration time. It accepts a margin to account for an early refresh.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
whenAccessTokenExpired(String accessToken, DateTime expiresAt, WithNewAccessToken withNewAccessToken) → void
Sets up a periodic check for the expiration of the accessToken. Once expired, it attempts to get a new token by calling getNewAccessToken. The withNewAccessToken function is called when a new token is obtained.

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

instance AuthDataWatcher
Singleton instance of AuthDataWatcher.
getter/setter pair