ChatController class

Controller of the Routes.chats page.

Inheritance

Constructors

ChatController(ChatId id, ChatService _chatService, CallService _callService, AuthService _authService, UserService _userService, AbstractSettingsRepository _settingsRepository, ContactService _contactService, {ChatItemId? itemId, BuildContext onContext()?})

Properties

active RxBool
Indicator whether the application is active.
final
background Rx<Uint8List?>
Returns the Uint8List of the background.
no setter
callPosition CallButtonsPosition?
Returns the CallButtonsPosition currently set.
no setter
canGoBack RxBool
Indicator whether the return FAB should be visible.
final
canGoDown RxBool
Indicator whether the down FAB should be visible.
final
chat RxChat?
RxChat of this page.
getter/setter pair
edit Rx<MessageFieldController?>
MessageFieldController for editing a ChatMessage.
final
elements RxObsSplayTreeMap<ListElementId, ListElement>
RxObsSplayTreeMap of the ListElements to display.
final
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
no setterinherited
hasNext RxBool
Indicates whether a next page of the elements is exists.
no setter
hasPrevious RxBool
Indicates whether a previous page of the elements is exists.
no setter
highlighted Rx<ListElementId?>
ListElementId of an item from the elements that should be highlighted.
final
horizontalScrollTimer Rx<Timer?>
Timer for discarding any vertical movement in a FlutterListView of ChatItems when non-null.
final
id ChatId
ID of this Chat.
getter/setter pair
initialized bool
Checks whether the controller has already been initialized.
no setterinherited
initIndex int
Index of a ChatItem in a FlutterListView that should be visible on initialization.
getter/setter pair
initOffset double
Offset that should be applied to a FlutterListView on initialization.
getter/setter pair
isClosed bool
Checks whether the controller has already been closed.
no setterinherited
isDraggingItem RxBool
Indicator whether any ChatItemWidget is being dragged right now.
final
itemId ChatItemId?
ID of the ChatItem to scroll to initially in this ChatView.
final
keepPositionOffset Rx<double>
Keep position offset of the FlutterListViewDelegate.
final
listController → FlutterListViewController
FlutterListViewController of a messages FlutterListView.
final
listeners int
no setterinherited
me UserId?
Returns MyUser's UserId.
no setter
monolog ChatId
Returns ChatId of the Chat-monolog of the currently authenticated MyUser, if any.
no setter
moreKey GlobalKey<State<StatefulWidget>>
GlobalKey of the more ContextMenuRegion button.
final
nextLoading RxBool
Indicates whether a next page of the elements is loading.
no setter
onContext BuildContext Function()?
Callback, called to retrieve the BuildContext that ChatView is built onto.
final
onDelete InternalFinalCallback<void>
Internal callback that starts the cycle of this controller.
finalinherited
onStart InternalFinalCallback<void>
Called at the exact moment the widget is allocated in memory. It uses an internal "callable" type, to avoid any @overrides in subclases. This method should be internal and is required to define the lifetime cycle of the subclass.
finalinherited
previousLoading RxBool
Indicates whether a previous page of the elements is loading.
no setter
query RxnString
Reactive current query of the search field used for debouching.
final
reason TextFieldState
TextFieldState for blocking reason.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scrollOffset Offset
Summarized Offset of an ongoing scroll.
getter/setter pair
TextFieldState of the ChatMessages searching.
final
searching RxBool
Indicator whether searching is being active right now.
final
selected RxList<ListElement>
ListElements selected during selecting mode.
final
selecting RxBool
Indicator whether the elements selection mode is enabled.
final
selection Rx<SelectedContent?>
SelectedContent of a SelectionArea within this ChatView.
final
send MessageFieldController
MessageFieldController for sending a ChatMessage.
latefinal
settings Rx<ApplicationSettings?>
Returns the ApplicationSettings.
no setter
showLoaders RxBool
Indicator whether the LoaderElements should be displayed.
final
showSticky RxBool
Indicator whether sticky header should be visible or not.
final
status Rx<RxStatus>
Status of a chat fetching.
getter/setter pair
stickyIndex RxnInt
Sticky element index of a FlutterListView currently being visible.
final
unreadMessages int
Count of ChatItems unread by the authenticated MyUser in this chat.
getter/setter pair
user RxUser?
Returns RxUser being recipient of this chat.
no setter
welcomeMessage WelcomeMessage?
Returns the WelcomeMessage of this chat, if any.
no setter

Methods

$configureLifeCycle() → void
inherited
addListener(GetStateUpdate listener) Disposer
Register a closure to be called when the object notifies its listeners.
inherited
addListenerId(Object? key, GetStateUpdate listener) Disposer
inherited
addToContacts() Future<void>
Adds the user to the contacts list of the authenticated MyUser.
addToHistory(ChatItem item) → void
Adds the provided item to the _history.
animateTo(ChatItemId itemId, {ChatItem? item, ChatItemQuote? reply, ChatItemQuote? forward, bool ignoreElements = false, bool offsetBasedOnBottom = true, bool addToHistory = true, double offset = 50}) Future<void>
Animates listController to a ChatItem identified by the provided item and its reply or forward.
animateToBack() Future<void>
Animates listController to the _itemToReturnTo.
animateToBottom() Future<void>
Animates listController to the last _history, if any, or the last ChatItem in the RxChat.messages otherwise.
block() Future<void>
Blocks the user for the authenticated MyUser.
calculateGallery(ChatItem? item) Paginated<ChatItemId, Rx<ChatItem>>
Returns a Paginated of ChatItems containing a collection of all the media files of this chat.
call(bool withVideo) Future<void>
Starts a ChatCall in this Chat withVideo or without.
clearChat() Future<void>
Clears all the ChatItems of the chat.
closeEditing() → void
Closes the editing if any.
copyText(String text) → void
Puts a text into the clipboard and shows a snackbar.
deleteMessage(ChatItem item) Future<void>
Deletes the specified ChatItem posted by the authenticated MyUser.
dispose() → void
inherited
disposeId(Object id) → void
To dispose an id from future updates(), this ids are registered by GetBuilder() or similar, so is a way to unlink the state change with the Widget from the Controller.
inherited
downloadFile(ChatItem item, FileAttachment attachment) Future<void>
Downloads the provided FileAttachment, if not downloaded already, or otherwise opens it or cancels the download.
downloadMedia(List<Attachment> attachments, {String? to}) Future<void>
Downloads the provided image or video attachments.
downloadMediaAs(List<Attachment> attachments) Future<void>
Downloads the provided image or video attachments using save as dialog.
dropCall() Future<void>
Drops the call in the Chat identified by the id.
dropFiles(PerformDropEvent event) Future<void>
Adds the specified event files to the send field.
editMessage(ChatItem item) → void
Starts the editing of the specified item, if allowed.
favoriteChat() Future<void>
Marks the chat as favorited.
getItem(ChatItemId id) FutureOr<Rx<ChatItem>?>
Returns a reactive ChatItem by the provided id.
getUser(UserId id) FutureOr<RxUser?>
Returns a reactive User from UserService by the provided id.
hideChat() Future<void>
Hides the chat.
hideChatItem(ChatItem item) Future<void>
Hides the specified ChatItem for the authenticated MyUser.
joinCall() Future<void>
Joins the call in the Chat identified by the id.
leaveGroup() Future<void>
Removes me from the chat.
muteChat() Future<void>
Mutes the chat.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyChildrens() → void
inherited
onClose() → void
Called before onDelete method. onClose might be used to dispose resources used by the controller. Like closing events, or streams before the controller is destroyed. Or dispose objects that can potentially create some memory leaks, like TextEditingControllers, AnimationControllers. Might be useful as well to persist some data on disk.
override
onInit() → void
Called immediately after the widget is allocated in memory. You might use this to initialize something for the controller.
override
onReady() → void
Called 1 frame after onInit(). It is the perfect place to enter navigation events, like snackbar, dialogs, or a new route, or async request.
override
readChat(ChatItem? item) Future<void>
Marks the chat as read for the authenticated MyUser until the item inclusively.
refresh() → void
inherited
refreshGroup(Object id) → void
inherited
removeFromContacts() Future<void>
Removes the user from the contacts list of the authenticated MyUser.
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that the object notifies.
inherited
removeListenerId(Object id, VoidCallback listener) → void
inherited
resendItem(ChatItem item) Future<void>
Resends the specified ChatItem.
saveToGallery(List<Attachment> attachments, ChatItem item) Future<void>
Saves the provided attachments to the gallery.
switchToMessages() → void
toggleSearch([bool? value]) → void
Enables or disabled searching of the ChatItems of this Chat.
toString() String
A string representation of this object.
inherited
unblock() Future<void>
Removes a User being a recipient of this chat from the blocklist.
unfavoriteChat() Future<void>
Removes the chat from the favorites.
unmuteChat() Future<void>
Unmutes the chat.
update([List<Object>? ids, bool condition = true]) → void
Rebuilds GetBuilder each time you call update(); Can take a List of ids, that will only update the matching GetBuilder( id: ), ids can be reused among GetBuilders like group tags. The update will only notify the Widgets, if condition is true.
inherited
updateDraft() → void
Updates RxChat.draft with the current values of the send field.
updateTyping() → void
Keeps ChatService.keepTyping subscription, if message field is not empty, or cancels it otherwise.

Operators

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

Constants

editMessageTimeout → const Duration
Interval of a ChatMessage since its creation within which this ChatMessage is allowed to be edited.
groupForwardThreshold → const Duration
Maximum Duration between some ChatForwards to consider them grouped.
lastItemBottomOffset → const double
Bottom offset to apply to the last ListElement in the elements.
loaderHeight → const double
Height of a LoaderElement displayed in the message list.