AsyncAuthStore class

AsyncAuthStore is a pluggable AuthStore implementation that could be used with any external async persistent layer (shared_preferences, hive, local file, etc.).

Below is an example using SharedPreferences:

final prefs = await SharedPreferences.getInstance();

final store = AsyncAuthStore(
  save:    (String data) async => prefs.setString('pb_auth', data),
  initial: prefs.getString('pb_auth'),
);

final pb = PocketBase('http://example.com', authStore: store);
Inheritance

Constructors

AsyncAuthStore({required SaveFunc save, String? initial, ClearFunc? clear})

Properties

clearFunc ClearFunc?
An optional async function that is called every time when the auth store needs to be cleared.
latefinal
hashCode int
The hash code for this object.
no setterinherited
isValid bool
Loosely checks if the current AuthStore has valid auth data (eg. whether the token is expired or not).
no setterinherited
model → dynamic
Returns the saved auth model (if any).
no setterinherited
onChange Stream<AuthStoreEvent>
Stream that gets triggered on each auth store change (aka. on save() and clear() call).
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
saveFunc SaveFunc
Async function that is called every time when the auth store state needs to be persisted.
latefinal
token String
Returns the saved auth token (if any).
no setterinherited

Methods

clear() → void
Clears the previously stored token and model auth data.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
save(String newToken, dynamic newModel) → void
Saves the provided newToken and newModel auth data into the store.
override
toString() String
A string representation of this object.
inherited

Operators

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