Skip to content

A Flutter package for sending text messages, featuring a "scroll to bottom" button and real-time unread message count display.

License

Notifications You must be signed in to change notification settings

Dr-CodE-Software-Company/chat_text_package

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ChatText

chat5

A Flutter package for sending text messages, featuring a "scroll to bottom" button and real-time unread message count display.

Created by mohamed abd elgwad

Installing

  1. Add dependency to pubspec.yaml
dependencies:
  chat_text_package: <latest-version>
  1. Import the package
import 'package:chat_text_package/chat_text_package.dart';
  1. Adding a ChatScreen widget.
ChatScreen(
                  messages: messages,
                  scrollController: scrollController,
                  otherUserName: 'Mohamed Abd El.Gwad',
                  textHint: 'Enter your message',
                  otherUserImage:
                      'https://www.euroschoolindia.com/wp-content/uploads/2023/08/cartoons-for-kids.jpg',
                  onSubmitMessage: (msg) {
                    messages.insert(
                        0,
                        Message(
                            id: 1,
                            body: msg,
                            fromLoggedUser: true,
                            createdAt: '2024-12-11 03:45 PM'));
                    setState(() {});
                  })
  1. Adding a messageList with Message class.
List<Message> messageList = [
  Message(
        id: 1,
        body: 'messsage',
        fromLoggedUser: false,
        createdAt: '2024-12-11 03:45 PM')),
   Message(
        id: 2,
        body: 'messsage',
        fromLoggedUser: true,
        createdAt: '2024-12-11 03:45 PM'),
];
  1. Adding a ScrollController to ChatScreen for pagination and scroll to bottom.
ScrollController scrollController = ScrollController();
ChatScreen(
scrollController: scrollController)
  1. Adding a onSubmitMessage : When you press the send message button, this function is called.
 onSubmitMessage: (String msg) {
        messages.insert(
          0,
          Message(
              id: 1,
              body: msg,
              fromLoggedUser: true,
              createdAt: '2024-12-11 03:45 PM'));
      setState(() {});
    };  
}
  1. Adding an appbar : if you need to add the default appBar to ChatScreen , you must add otherUserName, otherUserImage, or both.
ChatScreen(
  otherUserName: 'Mohamed Abd El.Gwad',
  otherUserImage:
      'https://www.euroschoolindia.com/wp-content/uploads/2023/08/cartoons-for-kids.jpg',                
)

if you need use custom appBar , don't add otherUserName or otherUserImage

  1. If you want to display the number of unread messages when a real time message arrives and chat is scrolling up.
int unreadMsgRealTime =0;
ChatScreen(            
unreadMsgRealTime : unreadMsgRealTime                          
 )

Main Contributors


Mohamed abd elgwad

Ahmed fayek

About

A Flutter package for sending text messages, featuring a "scroll to bottom" button and real-time unread message count display.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published