flutter_chat
Want to create a chat app with so ease, or want to add chat in existing project.
You can make your chat app within minutes.
Create a new Flutter application, and add Firebase to your application.
Firebase configuration:
Enable Authentication, by enable sign-in method Google.
Enable Cloud FireStore ,and add rules
rules_version = ‘2’;
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write;
}
}
}
Note: security rules are defined as public, just for testing. change it when go to production
Enable Realtime Database
add rules:
{
“rules”: {
“.read”: true,
“.write”: true
}
}
We use realtime database for check user online status.
Enable Storage
add rules:
Now add dependency on flutter project:
Add this to your package’s pubspec.yaml file:
flutter_chat: ^1.1.0
Create a Stateful widget class and call the method in body
within initState():
-> ChatData.init(“app name”,context);
and in body of Widget build:
-> ChatData.widgetWelcomeScreen(context)
e.g. Create a class and call Flutter chat init screen, like below
class WelcomeScreen extends StatefulWidget {
static const String id = "welcome_screen";
@override
_WelcomeScreenState createState() => _WelcomeScreenState();
}
class _WelcomeScreenState extends State<WelcomeScreen> {
@override
void initState() {
super.initState();
ChatData.init("Just Chat",context);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: ChatWidget.getAppBar(),
backgroundColor: Colors.white,
body: ChatWidget.widgetWelcomeScreen(context));
}
}
Now call WelcomeScreen from main.dart.
Now run the app and enjoy.
Features:
1–1 chat.
Chat with only added friends(Privacy). New
Share Pic with Gallery/Camera
User online status