CurrentUserProfile class

The signed-in user's own profile.

Kept alive for the session and persisted on native so the profile can load from cache on cold start. Web fetches it again after a browser reload. The network result remains authoritative on every platform.

Every mutation below re-reads the profile from the server rather than patching state locally. That is not caution for its own sake: the server derives fields the client does not send - it stamps avatarUrl itself on upload, complete with the cache-buster - so a locally patched copy would diverge from what every other client sees.

Annotations
  • @Riverpod.new(keepAlive: true)
  • @JsonPersist.new()

Constructors

CurrentUserProfile()

Properties

future Future<Profile>
Obtains a Future that resolves with the first state value that is not AsyncLoading.
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
key String
The default key used by persist.
no setterinherited
ref → Ref
The Ref associated with this notifier.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
state ↔ AsyncValue<Profile>
The value currently exposed by this notifier.
getter/setter pairinherited

Methods

build() Future<Profile>
listenSelf(void listener(AsyncValue<Profile>? previous, AsyncValue<Profile> next), {void onError(Object error, StackTrace stackTrace)?}) → RemoveListener
Listens to changes on the value exposed by this provider.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
persist(FutureOr<Storage<String, String>> storage, {String? key, String encode(Profile state)?, Profile decode(String encoded)?, StorageOptions options = const StorageOptions()}) → PersistResult
A variant of persist, for JSON-specific encoding.
inherited
refresh() → void
Refreshes the profile from the server.
runBuild() → WhenComplete?
Executes Notifier.build.
inherited
toString() String
A string representation of this object.
inherited
update(FutureOr<Profile> cb(Profile previousState), {FutureOr<Profile> onError(Object err, StackTrace stackTrace)?}) Future<Profile>
A function to update state from its previous value, while abstracting loading/error cases for state.
inherited
updateProfileFields({String? username, String? displayName}) Future<void>
Applies whichever of username and displayName actually changed.
updateShouldNotify(AsyncValue<Profile> previous, AsyncValue<Profile> next) bool
A method invoked when the state exposed by this Notifier changes. It compares the previous and new value, and return whether listeners should be notified.
inherited
uploadAvatar(Uint8List bytes) Future<void>
Uploads bytes as the user's new avatar.

Operators

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