all examples contains README.md
- blocs
- call_bloc
- chat_bloc
- confirm_phone_bloc
- interceptors
- auth_interceptor
- repositories
- booking_repository
- presence_repository
- screens
- chat_page
- for handling navigation uses autoRoute package
- for adapting screen and font size uses sreenUtils
- for handling dependency injection uses get_it
- for handling local storage uses shared_preferences and flutter_secure_storage
- for separating logic and state management uses bloc and riverpod combined with freezed
- for handling analytics uses firebase
- agora is used as message service
Call bloc contains
- CallRepository - responsible for all actions related to the conference
- MessageRepository - responsible for adding message of end to agora on this bloc
- UserRepository - responsible for receiving information about users
- BookingRepository - responsible for booking and rating of sessions
when started, it count down a timer and check local time difference with ntp server. This bloc connects buttons and agora`s rtcEngine with handles session. When session ends bloc navigates back to chat
- enter in call
- ending session
chat bloc contains 3 repositories
- MessageRepository - responsible for sending and receiving messages from the database
- UserRepository - responsible for receiving user`s information
- ConversationRepository - responsible for changing information about conversations
and 1 manager:
- MessageBlocManager - manages creation and closing blocs for messages in chat monitors that bloc count not growing more than _maxBlocCount for avoiding overspending of memory
on started bloc gets interlocutor`s information in User entity from UserRepository, fethes amount of unread messages(result) places divider for new messages and resets amount in ConversationRepository. After that, we subcribes to receive new messages, message statuses and media updates
We subscribe to messageStatusUpdates from MessageRepository and listen to each new status from_updateStatus. We send this status to the _updateMessage method, where we take the index of our chat message from the map _chatListMessageIndexes via global or local id. Next, if our status is sent, then we take the index by the local id of the message and change the element in the map by the global id. After that, we proceed to update the message in _chatItems, changing its current status to a new one. Checking is MessageItem is needed just in case any failure occurs and the DateDividerItem gets into the method. After all these actions, we update the list of messages via ChatCommand.updateList.
When we receive new message, it is putted in a set, gets timestamp and moved to a list of messages. Then we emit new state with updated list.
When new media sends, we fetch a preview of media from MessageRepository. When media is loaded we receive a media message with id equal to preview id. Bloc deletes preview message and insert media message.
when application is paused, we add divider of current date, deactivate reading of new messages and add it in a new list of unread messages. If user resumes app, we read new messages in a list, otherwise messages remain unread
- get messege
- update status
Confirm phone bloc contains
- SignInUseCase & SignUpUseCase - responsible for sending codes and verifying codes
- FirebaseAnalytic - responsible for receiving sending events to firebaase
- ProfileRepository - responsible for receiving information about users
- SnackBarManager - responsible for showing snackbars
when started, it tries to send code and if is fails, snackbar is showed. When user enters new code, this code is checked by useCases. When user request new code, we init a timer that prohibiting a new request.
- wrong code
- send again
In Auth interceptor we check expiration of expiration of agora`s token in every request. If token is expired we log out and navigate to anboarding screen
Call bloc contains
- BookingDataSource - data source that sends bookings to server
- MessageRepository - repository that sends messages to agora
- FirebaseAnalytic - responsible for receiving sending events to firebaase
The repository is responsible for sending new booking to the server and sending a special type of messages to the agora server when the client writes to the session
Call bloc contains
- ChatClient - agora`s entry point of the Chat SDK.
The repository is responsible for providing streams of users presence streams. When we try to get a stream, repository checks if it is placed in status map. If there is no stream, then a new stream from the agora sdk is requested and the current status of the user is requested.
- Change of status
After navigation we insert into element tree blocs and riverpod and insert BlocSideEffectListener(analog of BlocBuilder wich supports additional type of event called command) and Consumer beforе page
To connect riverpod and bloc we get entity from riverpod and update it, when command is called
- Chat page