AuthSingleton class
Process-wide accessor for the current CLAuthState instance.
Useful when code needs to read auth state from a context-less location
(background isolates, pure-Dart services, API interceptors, etc.) where
Provider.of<CLAuthState>(context) is not viable.
The singleton must be bound at app bootstrap — typically right after the CLAuthState provider is created — by calling AuthSingleton.bind. Reading authState before bind throws a StateError to surface configuration mistakes early.
Example:
final auth = MyAppAuthState();
AuthSingleton.bind(auth);
// ...later, anywhere:
final token = AuthSingleton.instance.authState.accessToken;
Properties
- authState → CLAuthState
-
The bound CLAuthState. Throws StateError if bind has not been
called yet.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- instance → AuthSingleton
-
Returns the lazily-created singleton instance.
no setter
- isBound → bool
-
Whether bind has already been called and an auth state is available.
no setter
Static Methods
-
bind(
CLAuthState state) → void - Binds the global CLAuthState instance. Must be called once at app startup before any consumer reads authState.