AuthTokenStore class abstract

Platform-agnostic interface for storing authentication tokens.

Implementations can use any storage backend:

  • Flutter: SharedPreferences, FlutterSecureStorage
  • CLI: File system
  • Server: Database, Redis
  • Testing: In-memory

Example usage:

class SecureTokenStore implements AuthTokenStore {
  final _storage = const FlutterSecureStorage();
  static const _key = 'spacetimedb_token';

  @override
  Future<String?> loadToken() async {
    return await _storage.read(key: _key);
  }

  @override
  Future<void> saveToken(String token) async {
    await _storage.write(key: _key, value: token);
  }

  @override
  Future<void> clearToken() async {
    await _storage.delete(key: _key);
  }
}
Implementers

Constructors

AuthTokenStore()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

clearToken() Future<void>
Clear the stored token (e.g., on logout).
loadToken() Future<String?>
Load the stored authentication token, if any.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
saveToken(String token) Future<void>
Save an authentication token.
toString() String
A string representation of this object.
inherited

Operators

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