flutter_inapp_chat 0.4.0 copy "flutter_inapp_chat: ^0.4.0" to clipboard
flutter_inapp_chat: ^0.4.0 copied to clipboard

A simple, complete chat system for Flutter with ready-to-use UI, image sharing, and view models, backed by Cloud Firestore, Appwrite, or Supabase.

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 Id
  • image - user image url
  • name - user display name

Chat Entity πŸ“© #

Fields
  • mainUser - logged in user
  • peers - Map of users <user ID, PeerUser>
  • backend - the ChatBackend storing this chat (FirestoreChatBackend, AppwriteChatBackend, or SupabaseChatBackend)
  • title - name of the chat (You can name group chats, can be nullable)
  • path - where the messages/chat are stored, in the form backend expects
  • onMessageSent - 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.

0
likes
160
points
77
downloads

Documentation

API reference

Publisher

verified publisheredentech.online

Weekly Downloads

A simple, complete chat system for Flutter with ready-to-use UI, image sharing, and view models, backed by Cloud Firestore, Appwrite, or Supabase.

Repository (GitHub)
View/report issues

Topics

#chat #firebase #firestore #supabase #appwrite

License

MIT (license)

Dependencies

appwrite, cloud_firestore, dash_chat_custom, firebase_core, firebase_storage, flutter, image_picker, intl, ionicons, stacked, supabase_flutter, url_launcher

More

Packages that depend on flutter_inapp_chat