chaty 1.0.3
chaty: ^1.0.3 copied to clipboard
A firebase chat widget.
Chaty #
Chaty is a Firebase-powered chat widget designed for seamless integration into Flutter applications. It provides a robust and customizable chat interface with features like real-time messaging, media sharing, and notifications.
Features #
- Real-time Messaging: Send and receive messages instantly using Firebase Firestore.
- Media Sharing: Share images, videos, audio, and documents.
- Push Notifications: Get notified of new messages even when the app is in the background.
- Customizable UI: Easily customize chat bubbles, input fields, and more.
- Typing Indicators: Show when the other user is typing.
- Unread Message Count: Keep track of unread messages.
- Message Deletion: Delete messages with confirmation.
- Cross-Platform Support: Works on Android, iOS, Web, and Desktop.
Getting Started #
Prerequisites #
- Ensure you have Flutter installed. Follow the Flutter installation guide.
- Set up a Firebase project and enable Firestore.
Setting Up Firebase #
- Go to the Firebase Console.
- Click on Add Project and follow the steps to create a new project.
- Once the project is created, navigate to the Project Settings.
- Under the General tab, add your app:
- For Android, download the
google-services.jsonfile and place it in theandroid/appdirectory. - For iOS, download the
GoogleService-Info.plistfile and place it in theios/Runnerdirectory.
- For Android, download the
- Enable Firestore:
- Go to the Firestore Database section in the Firebase Console.
- Click on Create Database.
- Choose a Start in production mode or Start in test mode based on your requirements.
- Select a Cloud Firestore location and click Enable.
Installation #
- Add Chaty to your
pubspec.yaml:dependencies: chaty: ^1.0.0 - Run the following command to install the package:
flutter pub get
Usage #
To integrate Chaty into your Flutter app:
- Import the necessary components:
import 'package:chaty/ui/chat_screen.dart'; import 'package:chaty/models/message.dart'; - Use the
ChatScreenwidget:ChatScreen( senderId: 'user1', receiverId: 'user2', mediaUploaderFunction: (mediaPath) async { // function that upload the mediapath and return the URL return 'uploaded_media_url'; }, );
For more examples, check the /example folder.
Example #
Here is a minimal example to get started:
import 'package:flutter/material.dart';
import 'package:chaty/ui/chat_screen.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
home: ChatScreen(
senderId: 'user1',
receiverId: 'user2',
mediaUploaderFunction: (mediaPath) async {
// Simulate media upload
return 'uploaded_media_url';
},
),
);
}
}
Additional Information #
- Contributing: Contributions are welcome! Feel free to submit issues or pull requests.
- License: This project is licensed under the MIT License. See the LICENSE file for details.
- Support: For any issues or feature requests, please open an issue on GitHub.
Happy coding!