A package that used the power of firebase to create a chat SDK.
Motivation behind this project was to create an all in one sdk that would make it easier for developers to create a chat app. Using this SDK developers can focus on the basic functionality of their app rather then worrying about setting up and developing a chat server.
The project is still in development phase but you are welcome to use it in your app and contribute to the project if you needed some more features or if you would like to improve something.
Demo
await FlutterFirebaseChatSDK.initializeApp()
to your main()
methodvoid main() async {
WidgetsFlutterBinding.ensureInitialized();
await FlutterFirebaseChatSDK.initializeApp();
runApp(MyApp());
}
FlutterFirebaseObservableApp
widget so that the SDK could monitor the status of the app which is needed to update the online status of the user. So for example your main app widget could be:class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: FlutterFirebaseObservableApp(
child: FlutterFirebaseChatSDK.instance.isUserLoggedIn ? Home() : Login(),
),
);
}
}
It is also a good idea from security purposes to perform some operations from the server and not give access to client for them. One of the example for this is the addFriend
function which calls a firebase functions and invokes the firebase admin SDK to add a new friend and create a chat group with current user and the given friend id.
Use this link to setup firebase CLI on your system and firebase functions in your project and then add code from lib/firebase/firebase-functions.js
to the index.js
file of your firebase functions project and run npm install uuidv4
to install uuidv4 dependency.
The project also uses firebase collection group so add the following rules to your CloudFirestore rules
match /{path=**}/Channels/{channelId} {
allow read, write: if request.auth != null
}
Once the above steps are followed run
flutter pub get
in the base folder and in example folder, then you can directly run the example project on a device or a simulator.
google_sign_in
flutter_hooks
toast
dash_chat
image_picker
flutter_native_image
If you have any issues building or running example project please consider following installation instructions for these dependencies before creating opening an issue.
If you found this project helpful or you learned something from the source code and want to thank me, consider buying me a cup of ☕️
If you found this project useful, then please consider giving it a ⭐️ on Github and sharing it with your friends via social media.
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.