flutter_chat_reactions 0.0.8
flutter_chat_reactions: ^0.0.8 copied to clipboard
A Flutter package to add reactions to your chat messages.
flutter_chat_reactions #
flutter_chat_reactions Enhance your Flutter chat with expressive reactions.
Need a simple and powerful way to add customizable message reactions to your Flutter chat app? Look no further than flutter_chat_reactions!
Liked some of my work? Buy me a coffee. Thanks for your support ❤️
[Demo 1] [Demo 2]
Features #
- Reaction Dialog: Upon long-pressing the chat widget, a user-friendly dialog appears, offering a range of expressive reactions.
- Compact Layout: The reactions are presented in a clean column layout, with the first child being a row containing six default reactions. A convenient '+' sign allows users to access an extended emoji container for even more reaction options.
- Context Menu: Below the message widget, users can access a context menu, adding depth to the interaction within the chat application.
- customizable Widgets: Reactions and Context Menu can be customized.
Getting started #
Add dependency to pubspec.yaml
dependencies:
flutter_chat_reactions: <latest-version>
In your dart file, import the library:
import 'package:flutter_chat_reactions/flutter_chat_reactions.dart';
Usage #
- First wrap your
Widgetwith aHeroWidget:
Hero(tag: message.id,
child: MessageWidget(message: message),
),
- Wrap your
HeroWidget with aGestureDetectororInkwellWidget:
GestureDetector(
// wrap your message widget with a [GestureDectector] or [InkWell]
onLongPress: () {
// navigate with a custom [HeroDialogRoute] to [ReactionsDialogWidget]
},
// wrap message with [Hero] widget
child: Hero(
tag: message.id,
child: MessageWidget(message: message),
),
);
- OnLonPress navigate with
HeroDialogRoutetoReactionsDialogWidgetSee example for more:
GestureDetector(
// wrap your message widget with a [GestureDectector] or [InkWell]
onLongPress: () {
// navigate with a custom [HeroDialogRoute] to [ReactionsDialogWidget]
Navigator.of(context).push(
HeroDialogRoute(
builder: (context) {
return ReactionsDialogWidget(
id: message.id, // unique id for message
messageWidget: MyMessage(message: message), // message widget
onReactionTap: (reaction) {
print('reaction: $reaction');
if (reaction == '➕') {
// show emoji picker container
} else {
// add reaction to message
}
},
onContextMenuTap: (menuItem) {
print('menu item: $menuItem');
// handle context menu item
},
);
},
),
);
},
// wrap message with [Hero] widget
child: Hero(
tag: message.id,
child: MessageWidget(message: message),
),
);
Parameters: #
| Name | Description | Required | Default value |
|---|---|---|---|
id |
Unique id for message and Hero Widget | required | - |
messageWidget |
The message widget to be displayed in the dialog | required | - |
onReactionTap |
The callback function to be called when a reaction is tapped | required | - |
onContextMenuTap |
The callback function to be called when a context menu item is tapped | required | - |
reactions |
The list of reactions to be displayed | no | like, love, haha, wow, sad, angry and plus for more |
menuItems |
The list of menu items to be displayed in the context menu | no | Reply, Copy and Delete |
widgetAlignment |
The alignment of the widget | no | aligned to center right |
menuItemsWidth |
The width of the menu items | no | 45% of the screen width |
Contributions #
All contributions are welcome!
