Chat app with flutter and firebase

Chat app with flutter and firebase

Sep 26, 2020

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.

Image for post

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:

Image for post

Goto Flutter_chat github repo

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–1 chat.

  2. Chat with only added friends(Privacy). New

  3. Share Pic with Gallery/Camera

  4. User online status

Image for post

Image for post

Image for post

# Support Development
Want to contribute and love this repository, consider buying me a cup of ☕️

Enjoy this post?

Buy ankeshkumar a flutter heart