Skip to content

Flutter package that provides a prebuilt, feature-rich chat screen designed to simplify development while offering powerful capabilities

License

Notifications You must be signed in to change notification settings

yajatkaul/ChatEase

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

19 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ChatEase: A Prebuilt Feature-Rich Chat Screen for Flutter

Pub Popularity Pub Version License

ChatEase is a Flutter package that provides a prebuilt, feature-rich chat screen designed to simplify development while offering powerful capabilities. With ChatView, you can easily integrate messaging, voice recordings, media sharing, and more into your application, ensuring a seamless and engaging user experience.

Features πŸš€

Pub Points

  • Rich Messaging: Send and receive text messages effortlessly.
  • Voice Messaging: Record and send voice messages with an interactive waveform visualization.
  • Media Sharing: Share images, videos, and other media assets with ease.
  • Profile Customization: Personalize user profiles with profile pictures and names.
  • Extensibility: Add your custom logic with callbacks for sending messages, assets, and voice recordings.

Demo πŸŽ₯

Demo

Installation πŸ”§

  1. Add the dependency to your pubspec.yaml file:

    dependencies:
      chatease: ^latest
  2. Fetch the dependencies:

    flutter pub get

Permissions πŸ“œ

Android

Add the following permissions to your AndroidManifest.xml file:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

iOS

Update your Info.plist file with the following permissions to match the functionality:

<key>NSCameraUsageDescription</key>
<string>Allow access to capture photos and videos.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Allow access to select photos and videos.</string>
<key>NSMicrophoneUsageDescription</key>
<string>Allow access to record audio.</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>Allow saving media to the photo library.</string>

Ensure you also enable Background Modes for audio recording if needed.

Usage πŸ§‘β€πŸ’»

  1. Import the package:
    import 'package:chatease/chatview.dart';
  2. Use the ChatView widget in your application:
     ChatView(
     messages: conversation,  // List of messages
     conversationId: "123",   // Unique conversation ID
     profilePic: "https://example.com/profile.jpg",
     userName: "User",
     clientId: "1234",        // Current user's ID
     onMessageSend: (message) {
       debugPrint(message);
       setState(() {
         conversation.add(newMessage); // Add new message to the conversation
       });
     },
     onAssetSend: (assets) {
       // Handle media asset sending
     },
     onVMSend: (audio) {
       // Handle voice message sending
     },
    );

Example πŸ₯Ό

import 'package:chatease/chatview.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MainApp());
}

class MainApp extends StatefulWidget {
  const MainApp({super.key});

  @override
  State<MainApp> createState() => _MainAppState();
}

class _MainAppState extends State<MainApp> {
  List<dynamic> conversation = [
    {
      "userId": {
        "profilePic":
            "https://www.shutterstock.com/image-vector/anime-boy-black-hair-hoodie-600nw-2078861473.jpg",
        "_id": "1234"
      },
      "message": "Hello",
      "type": "MESSAGE"
    },
    {
      "userId": {
        "profilePic":
            "https://www.shutterstock.com/image-vector/anime-boy-black-hair-hoodie-600nw-2078861473.jpg",
        "_id": "1234"
      },
      "message":
          "https://i.pinimg.com/originals/a8/2c/4b/a82c4b062593c35f4ebcf1617e83cacd.png",
      "type": "IMAGE"
    },
    // {
    //   "userId": {
    //     "profilePic":
    //         "https://www.shutterstock.com/image-vector/anime-boy-black-hair-hoodie-600nw-2078861473.jpg",
    //     "_id": "1234"
    //   },
    //   "message":
    //       "https://videos.pexels.com/video-files/4830364/4830364-uhd_1440_2732_25fps.mp4",
    //   "type": "VIDEO"
    // },
    {
      "userId": {
        "profilePic":
            "https://www.shutterstock.com/image-vector/anime-boy-black-hair-hoodie-600nw-2078861473.jpg",
        "_id": "1234"
      },
      "message": "https://download.samplelib.com/mp3/sample-3s.mp3",
      "type": "VOICE"
    },
  ];

  Map<String, Object> newMessage = {
    "userId": {
      "profilePic":
          "https://www.shutterstock.com/image-vector/anime-boy-black-hair-hoodie-600nw-2078861473.jpg",
      "_id": "1235"
    },
    "message": "Sure",
    "type": "MESSAGE"
  };

  final ScrollController _scrollController = ScrollController();

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
          body: ChatView(
              scrollController: _scrollController,
              messages: conversation,
              conversationId: "1",
              image:
                  "https://www.shutterstock.com/image-vector/anime-boy-black-hair-hoodie-600nw-2078861473.jpg",
              name: "Adam",
              clientId: "1235",
              onMessageSend: (message) {
                debugPrint(message);
                setState(() {
                  conversation.add(newMessage);
                });
              },
              onAssetSend: (assets) {},
              onVMSend: (audio) {})),
    );
  }
}

Dependencies πŸ› οΈ

ChatEase leverages the following packages to provide its rich feature set:

Contributing 🀝

We welcome contributions! If you'd like to improve the package or fix issues:

  1. Fork the repository.
  2. Create a new branch: git checkout -b feature-name.
  3. Commit your changes: git commit -m 'Add feature-name'.
  4. Push to the branch: git push origin feature-name.
  5. Open a Pull Request.

License πŸ“

This project is licensed under the MIT License.

Happy coding with ChatEase! πŸŽ‰

About

Flutter package that provides a prebuilt, feature-rich chat screen designed to simplify development while offering powerful capabilities

Topics

Resources

License

Stars

Watchers

Forks