Inapp Chatπ₯π¬
A simple, complete chat system for Flutter with ready-to-use UI, image sharing, and view models β backed by Cloud Firestore, Appwrite, or Supabase, your choice.
βοΈ Getting started
Add Inapp Chat to your project by following the instructions on the install page, then import the core package plus the backend you want to use:
import 'package:flutter_inapp_chat/inapp_chat.dart';
import 'package:flutter_inapp_chat/backends/firestore_chat_backend.dart';
// or: 'package:flutter_inapp_chat/backends/appwrite_chat_backend.dart'
// or: 'package:flutter_inapp_chat/backends/supabase_chat_backend.dart'
Importing only the backend(s) you use keeps cloud_firestore/
firebase_storage, appwrite, and supabase_flutter out of your build
unless you actually reference them β package:flutter_inapp_chat/inapp_chat.dart
itself stays backend-agnostic.
You can open chat page either via Material route or directly push the chat page
await openChatPage(BuildContext context, ChatEntity chatEntity);
or
InappChat().chatPageWidget(chatEntity)
π± Example
Opening chat
final chatEntity = ChatEntity(
onMessageSent: (message, chatEntity){
//
},
mainUser: mainUser,
peers: peers,
backend: FirestoreChatBackend(),
path: chatPath,
title: "FIFA 2022 Games",
);
//WAY 1
Navigator.push(
context,
InappChat().chatPageWidget(chatEntity),
);
//WAY 2
await openChatPage(context, chatEntity);
...
π Backends
Every backend implements the same ChatBackend interface (load history,
stream new messages, send a message, upload an image), so switching
providers only means constructing a different one and handing it to
ChatEntity.backend. path identifies where a conversation's messages live,
in whatever form the chosen backend expects.
Firestore
ChatEntity(
backend: FirestoreChatBackend(),
path: "sport/football/2022/worldcup", // Firestore collection path
...
);
Messages are stored in the <path>/Activity subcollection. Requires
cloud_firestore and firebase_storage to be configured for your app
(Firebase.initializeApp(...)).
Appwrite
ChatEntity(
backend: AppwriteChatBackend(
endpoint: "https://cloud.appwrite.io/v1",
projectId: "<project-id>",
databaseId: "<database-id>",
bucketId: "<bucket-id>",
),
path: "worldcup-2022", // Appwrite table id
...
);
Each conversation is a table in databaseId, with one row per message and a
timestamp string column (ISO 8601). Enable Realtime for the table.
Supabase
ChatEntity(
backend: SupabaseChatBackend(bucketName: "chat-images"),
path: "worldcup_2022", // Supabase table name
...
);
Requires Supabase.initialize(url: ..., anonKey: ...) to have run first.
Each conversation is a Postgres table with an id (uuid, default
gen_random_uuid()) primary key and a timestamp timestamptz column
(default now()), with Realtime enabled.
Models π¦
Peer User π¨
Fields
id- user Idimage- user image urlname- user display name
Chat Entity π©
Fields
mainUser- logged in userpeers- Map of users<user ID, PeerUser>backend- theChatBackendstoring this chat (FirestoreChatBackend,AppwriteChatBackend, orSupabaseChatBackend)title- name of the chat (You can name group chats, can benullable)path- where the messages/chat are stored, in the formbackendexpectsonMessageSent- callback for when the message is saved
License βοΈ
Issues and feedback π
If you have any suggestion for including a feature or if something doesn't work, feel free to open a Github issue for us to have a discussion on it.
Libraries
- backends/appwrite_chat_backend
- An Appwrite-backed ChatBackend implementation.
- backends/chat_backend
- The backend-agnostic ChatBackend interface implemented by
FirestoreChatBackend,AppwriteChatBackend, andSupabaseChatBackend. - backends/firestore_chat_backend
- A Cloud Firestore-backed ChatBackend implementation.
- backends/supabase_chat_backend
- A Supabase-backed ChatBackend implementation.
- inapp_chat
- A simple, complete chat system for Flutter, pluggable across Cloud Firestore, Appwrite, and Supabase.
- models/chat.model
- The wire format used to persist a chat message via a ChatBackend.
- models/chat_entity
- Describes a chat conversation: its participants, backend, and behavior.
- models/peer_user
- A chat participant, independent of any backend.
- services/inappchat.service
- The InappChat entry point for opening the chat UI.
- services/inappchat.utils
- Conversion helpers between backend documents/rows and
dash_chat_customchat models. - view_models/inapp_chat.vm
- The view model driving
InappChatPage. - views/inapp_chat.page
- The chat screen widget rendered by InappChat.