FirebaseChatCore class
Provides access to Firebase chat data. Singleton, use FirebaseChatCore.instance to aceess methods.
Properties
- config ↔ FirebaseChatCoreConfig
-
Config to set custom names for rooms and users collections. Also
see FirebaseChatCoreConfig.
getter/setter pair
- firebaseUser ↔ User?
-
Current logged in user in Firebase. Does not update automatically.
Use
FirebaseAuth.authStateChanges
to listen to the state changes.getter/setter pair - hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
createGroupRoom(
{Role creatorRole = types.Role.admin, String? imageUrl, Map< String, dynamic> ? metadata, required String name, required List<User> users}) → Future<Room> -
Creates a chat group room with
users
. Creator is automatically added to the group.name
is required and will be used as a group name. Add an optionalimageUrl
that will be a group avatar andmetadata
for any additional custom data. -
createRoom(
User otherUser, {Map< String, dynamic> ? metadata}) → Future<Room> -
Creates a direct chat for 2 people. Add
metadata
for any additional custom data. -
createUserInFirestore(
User user) → Future< void> -
Creates
types.User
in Firebase to store name and avatar used on rooms list. -
deleteMessage(
String roomId, String messageId) → Future< void> - Removes message document.
-
deleteRoom(
String roomId) → Future< void> - Removes room document.
-
deleteUserFromFirestore(
String userId) → Future< void> -
Removes
types.User
fromusers
collection in Firebase. -
getFirebaseFirestore(
) → FirebaseFirestore -
Gets proper
FirebaseFirestore
instance. -
messages(
Room room, {List< Object?> ? endAt, List<Object?> ? endBefore, int? limit, List<Object?> ? startAfter, List<Object?> ? startAt}) → Stream<List< Message> > - Returns a stream of messages from Firebase for a given room.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
room(
String roomId) → Stream< Room> - Returns a stream of changes in a room from Firebase.
-
rooms(
{bool orderByUpdatedAt = false}) → Stream< List< Room> > -
Returns a stream of rooms from Firebase. Only rooms where current
logged in user exist are returned.
orderByUpdatedAt
is used in case you want to have last modified rooms on top, there are a couple of things you will need to do though: -
sendMessage(
dynamic partialMessage, String roomId) → void -
Sends a message to the Firestore. Accepts any partial message and a
room ID. If arbitraty data is provided in the
partialMessage
does nothing. -
setConfig(
FirebaseChatCoreConfig firebaseChatCoreConfig) → void - Sets custom config to change default names for rooms and users collections. Also see FirebaseChatCoreConfig.
-
toString(
) → String -
A string representation of this object.
inherited
-
updateMessage(
Message message, String roomId) → void - Updates a message in the Firestore. Accepts any message and a room ID. Message will probably be taken from the messages stream.
-
updateRoom(
Room room) → void - Updates a room in the Firestore. Accepts any room. Room will probably be taken from the rooms stream.
-
users(
) → Stream< List< User> > - Returns a stream of all users from Firebase.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- instance → FirebaseChatCore
-
Singleton instance.
final