UserRepository class

The repository responsible for fetching, caching, and broadcasting the authenticated driver's profile.

Fetches UserModel data from the API, persists it to SecureStorage for offline fallback, and broadcasts updates on the user stream. Also keeps the Sentry user context in sync so error reports include user identity.

Callers should prefer AuthRepository.resolveUser over calling this class directly in most cases.

Constructors

UserRepository({required UserService userService, required SecureStorage secureStorage, required AppLogger logger})
Creates a UserRepository.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
user Stream<UserModel>
A stream that emits the current UserModel whenever it changes.
no setter

Methods

clearUser() Future<void>
Deletes the stored user from SecureStorage, clears the Sentry user context, and emits UserModel.empty on the user stream.
dispose() → void
Closes the user stream controller and releases resources.
getCachedUser() Future<UserModel?>
The UserModel currently persisted in SecureStorage, or null if none exists.
getUser({bool notify = true}) Future<UserModel>
Fetches the current user from the API, persists the result, and optionally broadcasts it on the user stream.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
updateUser(UserModel user) Future<void>
Persists user to SecureStorage, updates the Sentry user context, and broadcasts the new value on the user stream.

Operators

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