InappChatViewModel class

Drives the chat page: loading messages, listening for new ones, and sending text or image messages via ChatEntity.backend.

Inheritance

Constructors

InappChatViewModel(BuildContext context, ChatEntity chatEntity)
Creates a view model for chatEntity, using context for navigation and locale-aware formatting.

Properties

anyObjectsBusy → bool
no setterinherited
chatEntity ↔ ChatEntity
The conversation this view model manages.
getter/setter pair
chatStreamListener ↔ StreamSubscription?
The active subscription listening for new incoming messages.
getter/setter pair
context ↔ BuildContext
The build context the chat page was created with.
getter/setter pair
disposed ↔ bool
getter/setter pairinherited
hasError → bool
Returns the error existence status of the ViewModel
no setterinherited
hashCode → int
The hash code for this object.
no setterinherited
hasListeners → bool
Whether any listeners are currently registered.
no setterinherited
initialised → bool
no setterinherited
isBusy → bool
Returns the busy status of the ViewModel
no setterinherited
messageKeys ↔ List<String>
Backend document/row ids corresponding to messages, in the same order.
getter/setter pair
messages ↔ List<ChatMessage>
The messages currently loaded for the conversation, newest first.
getter/setter pair
modelError → dynamic
Returns the error status of the ViewModel
no setterinherited
onModelReadyCalled → bool
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
busy(Object? object) → bool
Returns the busy status for an object if it exists. Returns false if not present
inherited
clearErrors() → void
Clears all the errors
inherited
dispose() → void
Discards any resources used by the object.
error(Object object) → dynamic
inherited
hasErrorForKey(Object key) → bool
Returns a boolean that indicates if the ViewModel has an error for the key
inherited
initialise() → void
Loads existing messages and starts listening for new ones.
listenToNewMessages() → Future<void>
Subscribes to real-time updates and prepends newly received messages to messages.
loadAllMessages() → Future<void>
Fetches all existing messages for the conversation from the backend.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
onCameraMedia() → Future<void>
Opens the camera for the user to capture an image to send.
onFutureError(dynamic error, Object? key) → void
Function that is called when a future throws an error
inherited
onSelectMedia() → Future<void>
Opens the gallery for the user to pick an image to send.
rebuildUi() → void
Calls the builder function with this updated viewmodel
inherited
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
runBusyFuture<T>(Future<T> busyFuture, {Object? busyObject, bool throwException = false}) → Future<T>
Sets the ViewModel to busy, runs the future and then sets it to not busy when complete.
inherited
runErrorFuture<T>(Future<T> future, {Object? key, bool throwException = false}) → Future<T>
inherited
sendMessage(ChatMessage m) → void
Persists m via the backend and notifies ChatEntity.onMessageSent.
setBusy(bool value) → void
Marks the ViewModel as busy and calls notify listeners
inherited
setBusyForObject(Object? object, bool value) → void
Sets the busy state for the object equal to the value passed in and notifies Listeners If you're using a primitive type the value SHOULD NOT BE CHANGED, since Hashcode uses == value
inherited
setError(dynamic error) → void
Sets the error for the ViewModel
inherited
setErrorForModelOrObject(dynamic value, {Object? key}) → void
inherited
setErrorForObject(Object object, dynamic value) → void
Sets the error state for the object equal to the value passed in and notifies Listeners If you're using a primitive type the value SHOULD NOT BE CHANGED, since Hashcode uses == value
inherited
setInitialised(bool value) → void
Sets the initialised value for the ViewModel to true. This is called after the first initialise special ViewModel call
inherited
setOnModelReadyCalled(bool value) → void
Sets the onModelReadyCalled value to true. This is called after this first onModelReady call
inherited
skeletonData<T>({required T? realData, required T busyData, Object? busyKey}) → T
returns real data passed if neither the model is busy nor the object passed is busy
inherited
toString() → String
A string representation of this object.
inherited
uploadPhoteChat(XFile selectedXFile) → Future<void>
Uploads selectedXFile via the backend and sends it as an image message.

Operators

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