DashChat class
A complete chat UI which is inspired by react-native-gifted-chat
Highly customizable and helps developing chat UI faster
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- DashChat
Constructors
-
DashChat({Key? key, ScrollToBottomStyle? scrollToBottomStyle, double avatarMaxSize = 30.0, TextDirection inputTextDirection = TextDirection.ltr, EdgeInsets inputToolbarMargin = const EdgeInsets.all(0.0), EdgeInsets inputToolbarPadding = const EdgeInsets.all(0.0), bool shouldShowLoadEarlier = false, Widget showLoadEarlierWidget()?, Function? onLoadEarlier, bool sendOnEnter = false, TextInputAction? textInputAction, bool scrollToBottom = true, Widget scrollToBottomWidget()?, Function? onScrollToBottomPress, dynamic onQuickReply(Reply)?, EdgeInsetsGeometry quickReplyPadding = const EdgeInsets.all(0.0), BoxDecoration? quickReplyStyle, TextStyle? quickReplyTextStyle, Widget quickReplyBuilder(Reply)?, bool quickReplyScroll = false, EdgeInsetsGeometry messageContainerPadding = const EdgeInsets.only(left: 2.0, right: 2.0), ScrollController? scrollController, Color? inputCursorColor, double inputCursorWidth = 2.0, bool showInputCursor = true, int inputMaxLines = 1, BoxDecoration? inputContainerStyle, TextStyle? inputTextStyle, List<
Widget> leading = const <Widget>[], List<Widget> trailing = const <Widget>[], BoxDecoration? messageContainerDecoration, int messageContainerFlex = 1, double? height, double? width, bool readOnly = false, required List<ChatMessage> messages, dynamic onTextChange(String)?, String? text, bool inputDisabled = false, TextEditingController? textController, FocusNode? focusNode, InputDecoration? inputDecoration, TextCapitalization textCapitalization = TextCapitalization.none, bool alwaysShowSend = false, String messageIdGenerator()?, DateFormat? dateFormat, DateFormat? timeFormat, required ChatUser user, required dynamic onSend(ChatMessage), dynamic onLongPressAvatar(ChatUser)?, dynamic onLongPressMessage(ChatMessage)?, dynamic onPressAvatar(ChatUser)?, Widget avatarBuilder(ChatUser)?, bool showAvatarForEveryMessage = false, bool showUserAvatar = false, bool inverted = false, int? maxInputLength, List<MatchText> parsePatterns = const <MatchText>[], Widget messageBuilder(ChatMessage)?, Widget sendButtonBuilder(Function)?, Widget dateBuilder(String)?, Widget messageImageBuilder(String? url, [ChatMessage])?, Widget messageTextBuilder(String?, [ChatMessage])?, Widget messageTimeBuilder(String formattedTime, [ChatMessage])?, bool showTraillingBeforeSend = true, bool shouldStartMessagesFromTop = false, List<Widget> messageButtonsBuilder(ChatMessage)?, EdgeInsets messagePadding = const EdgeInsets.all(8.0), bool textBeforeImage = true, BoxDecoration messageDecorationBuilder(ChatMessage, bool?)?})
Properties
- alwaysShowSend → bool
-
Should the send button be always active it defaults to false
Usually it will only become active if some text is entered.
final
- avatarBuilder → (Widget Function(ChatUser)?)
-
avatarBuilder will override the the default avatar which uses
CircleAvatar.
final
- avatarMaxSize → double
-
sets the default AvatarContainer maxSize.
final
-
A Widget that will be shown below the MessageListView like you can
show a "tying..." at the end.
final
- dateBuilder → (Widget Function(String)?)
-
dateBuilder will override the the default time text.
final
- dateFormat → DateFormat?
-
DateFormat object for formatting date to show in MessageListView
defaults to
yyyy-MM-dd
.final - focusNode → FocusNode?
-
If provided, this focus node will be used for the text input.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- height → double?
-
Height for the Dash chat Widget
final
- inputContainerStyle → BoxDecoration?
-
TextField container style.
final
- inputCursorColor → Color?
-
Color of the input cursor defaults to theme.
final
- inputCursorWidth → double
-
Width of the text input defaults to 2.0.
final
- inputDecoration → InputDecoration?
-
Used to provide input decoration to the text as default only
to the input placeholder for the chat input
"Add Message here...".
final
- inputDisabled → bool
-
If the input TextField is disabled.
final
-
A Widget that will be shown below the ChatInputToolbar like you can
show a list of buttons like file image just like in Slack app.
final
- inputMaxLines → int
-
Max length of the input lines default to 1.
final
- inputTextDirection → TextDirection
-
Use to change the direction of the text ltr is used for
launguages that start from left like English &
rtl is used for languages like Arabic
final
- inputTextStyle → TextStyle?
-
Style for the TextField.
final
- inputToolbarMargin → EdgeInsets
-
Margin for the default input toolbar
by default it padding is set 0.0
final
- inputToolbarPadding → EdgeInsets
-
Padding for the default input toolbar
by default it padding is set 0.0
final
- inverted → bool
-
Should the messages be shown in reversed order.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
-
leading
→ List<
Widget> -
List of
Widget
to show before the TextField.final - maxInputLength → int?
-
Main input length of the input text box defaulst to no limit.
final
- messageBuilder → (Widget Function(ChatMessage)?)
-
messageBuilder will override the the default chat container which uses
and you will need to build complete message Widget it will not accept
and include any other builder functions.
final
-
messageButtonsBuilder
→ (List<
Widget> Function(ChatMessage)?) -
messageButtonsBuilder function takes a function with this
structure
List<Widget> Function()
to render the buttons inside a row.final - messageContainerDecoration → BoxDecoration?
-
Provides a custom style to the message container
takes BoxDecoration
final
- messageContainerFlex → int
-
Flex value for the messeage container defaults to 1
Made so that the message container takes as much as possible
if no height or width is passed explicity
final
- messageContainerPadding → EdgeInsetsGeometry
-
Padding for the MessageListView.
final
- messageDecorationBuilder → (BoxDecoration Function(ChatMessage, bool?)?)
-
overrides the boxdecoration of the message
can be used to override color, or customise the message container
params ChatMessage and
isUser
: boolean return BoxDecorationfinal - messageIdGenerator → (String Function()?)
-
Usually new message added by the user gets
Uuid
String Can be override by proving this parameterfinal - messageImageBuilder → (Widget Function(String? url, [ChatMessage])?)
-
messageImageBuilder will override the the default Image.
final
- messagePadding → EdgeInsets
-
Padding of the message
Default to EdgeInsets.all(8.0)
final
-
messages
→ List<
ChatMessage> -
List of messages to display in the chat container
Takes a List of
ChatMessage
final - messageTextBuilder → (Widget Function(String?, [ChatMessage])?)
-
messageTextBuilder will override the the default message text.
final
- messageTimeBuilder → (Widget Function(String formattedTime, [ChatMessage])?)
-
messageTimeBuilder will override the the default text.
final
- onLoadEarlier → Function?
-
Override the default behaviour of the onLoadEarleir Widget
or used as a callback when the listView reaches the top
final
- onLongPressAvatar → (dynamic Function(ChatUser)?)
-
onLongPressAvatar function takea a function with this structure
Function(ChatUser) will trigger when the avatar
is long pressed
final
- onLongPressMessage → (dynamic Function(ChatMessage)?)
-
onLongPressMessage function takea a function with this structure
Function(ChatMessage) will trigger when the message
is long pressed.
final
- onPressAvatar → (dynamic Function(ChatUser)?)
-
onPressAvatar function takes a function with this structure
Function(ChatUser) will trigger when the avatar
is tapped on
final
- onQuickReply → (dynamic Function(Reply)?)
-
Callback method when the quickReply was tapped on
will pass Reply as a paramter to function.
final
- onScrollToBottomPress → Function?
-
Override the default behaviour of the onScrollToBottom Widget
final
- onSend → dynamic Function(ChatMessage)
-
To function where you can make api calls and play
with the ChatMessage obeject before make calls.
final
- onTextChange → (dynamic Function(String)?)
-
If the text parameter is passed then onTextChange must also
be passed.
final
-
parsePatterns
→ List<
MatchText> -
Used to parse text to make it linkified text uses
flutter_parsed_text
takes a list of
MatchText
in order to parse Email, phone, links and can also add custom pattersn using regexfinal - quickReplyBuilder → (Widget Function(Reply)?)
-
quickReplyBuilder will override the the default QuickReply Widget.
final
- quickReplyPadding → EdgeInsetsGeometry
-
Padding for the quick reply area
by default it padding is set 0.0
final
- quickReplyScroll → bool
-
Should quick reply be horizontally scrollable
final
- quickReplyStyle → BoxDecoration?
-
Container style for the QuickReply Container BoxDecoration.
final
- quickReplyTextStyle → TextStyle?
-
TextStyle for QuickReply textstyle.
final
- readOnly → bool
-
Set the chat into read only mode, meaning no way to send messages
default to false
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scrollController → ScrollController?
-
ScrollController for the MessageListView will use the default
scrollcontroller in the Widget.
final
- scrollToBottom → bool
-
Should the scroll to bottom widget be shown
default to true.
final
- scrollToBottomStyle ↔ ScrollToBottomStyle
-
getter/setter pair
- scrollToBottomWidget → (Widget Function()?)
-
Overrides the default scrollToBottomWidget with a custom widget
final
- sendButtonBuilder → (Widget Function(Function)?)
-
sendButtonBuilder will override the the default IconButton.
final
- sendOnEnter → bool
-
Should the message be sent by hitting enter on web or text input action
Can be useful for tablet or web usage
final
- shouldShowLoadEarlier → bool
-
Should the LoadEarlier Floating widget be shown or use
load as you scroll scheme whcih will call the onLoadEarlier
function as default it is set to this scheme which is false.
false - load as you scroll scheme
true - shows a loadEarlier Widget
final
- shouldStartMessagesFromTop → bool
-
final
- showAvatarForEveryMessage → bool
-
Should the avatar be shown for every message defaulst to false.
final
- showInputCursor → bool
-
Should the input cursor be shown defaults to true.
final
- showLoadEarlierWidget → (Widget Function()?)
-
Override the default behaviour of the onScrollToBottom Widget
final
- showTraillingBeforeSend → bool
-
Should the
trailling
Widgets be shown before the send button As default it will be shown before the send button.final - showUserAvatar → bool
-
Should the user avatar be shown defaults to false and will not
show the user avatar.
final
- text → String?
-
If provided will stop using the default controller
i.e TextEditingController and will use this to update the
text input field.
final
- textBeforeImage → bool
-
Should show the text before the image in the MessageContainer
or the opposite
Default to
true
final - textCapitalization → TextCapitalization
-
Configures how the platform keyboard will select an uppercase or lowercase keyboard.
Only supports text keyboards, other keyboard types will ignore this configuration. Capitalization is locale-aware.
Defaults to TextCapitalization.none. Must not be null.
final
- textController → TextEditingController?
-
If provided, this text editing controller will be used for
the text input.
final
- textInputAction → TextInputAction?
-
Input action of the keyboard
final
- timeFormat → DateFormat?
-
DateFormat object for formatting time to show in MessageContainer
defaults to
HH:mm:ss
.final -
trailing
→ List<
Widget> -
List of
Widget
to show after the TextField.will remove the send button and will have to implement that yourself.final - user → ChatUser
-
The current user object ChatUser.
final
- width → double?
-
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → DashChatState -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of
DiagnosticsNode
objects describing this node's children.inherited -
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
getVal(
) → String? -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited