v0.0.21dash_chat_2
Flutter 最完整的聊天 UI。易于使用、高度可定制且功能齐全
Flutter 最完整的聊天 UI。易于使用、高度可定制且功能齐全
^3.3.1{"sdk":"flutter"}^0.7.1^2.2.1^0.19.0^6.0.10^2.2.5^3.0.1{"sdk":"flutter"}以下为英文项目原文快照,最新内容请访问 GitHub。
https://firebasestorage.googleapis.com/v0/b/molteo-40978.appspot.com/o/DashChat.png?alt=media&token=b1adb9b0-c601-4a33-89b7-2cb722647401
Easy to use, highly customizable and fully featured
License Pub version Contributors
https://firebasestorage.googleapis.com/v0/b/molteo-40978.appspot.com/o/Screenshot1.png?alt=media&token=b77546dc-8fea-4aab-ac1b-3de5a2a90654 https://firebasestorage.googleapis.com/v0/b/molteo-40978.appspot.com/o/Screenshot2.png?alt=media&token=2bf2ac8e-cb6e-44e7-876d-8c6a7959819e
You need another feature? you can use the customProperties field of the models, it allows you to pass other data to the library that you can then use inside custom builders to implement any feature you need.
Of course, if you think this feature can be useful to other people, feel free to open an issue/pull-request to discuss including it "natively" in the package.
import 'package:dash_chat_2/dash_chat_2.dart';
import 'package:flutter/material.dart';
class Basic extends StatefulWidget {
@override
_BasicState createState() => _BasicState();
}
class _BasicState extends State<Basic> {
ChatUser user = ChatUser(
id: '1',
firstName: 'Charles',
lastName: 'Leclerc',
);
List<ChatMessage> messages = <ChatMessage>[
ChatMessage(
text: 'Hey!',
user: user,
createdAt: DateTime.now(),
),
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Basic example'),
),
body: DashChat(
currentUser: user,
onSend: (ChatMessage m) {
setState(() {
messages.insert(0, m);
});
},
messages: messages,
),
);
}
}
You can run the example project to see more complex ways of using the package
ChatUser currentUser - required: Basically "you", we need to know who is the current user to put their messages to right side
Function(ChatMessage message) onSend - required: Function to call when the user sends a message, that's where you handle the logic to send the message to your backend and append the list of messages
List<ChatMessage> messages - required: The list of messages of the channel, you would usually not load all the messages at once but use the onLoadEarlier param of MessageListOptions to trigger a lazy loading
InputOptions inputOptions - optional: Options to customize the behaviour and design of the chat input
MessageOptions messageOptions - optional: Options to customize the behaviour and design of the messages
MessageListOptions messageListOptions - optional: Options to customize the behaviour and design of the overall list of message
QuickReplyOptions quickReplyOptions - optional: Options to customize the behaviour and design of the quick replies
ScrollToBottomOptions scrollToBottomOptions - optional: Options to customize the behaviour and design of the scroll-to-bottom button
readOnly - optional (default to false): Option to make the chat read only, it will hide the input field
List<ChatUser> typingUsers - optional: List of users currently typing in the chat
You can browse the full Dart documentation here: Documentation
If you found this project useful, then please consider giving it a ⭐️ on Github: https://github.com/SebastienBtr/Dash-Chat-2
If you have any suggestions for including a feature or if something doesn't work, feel free to open a Github issue or to open a pull request, you are more than welcome to contribute!
Thanks to Fayeed who created the v1 of this package: https://github.com/fayeed/dash_chat and made that possible!