MessageInput class

Inactive state

screenshot screenshot

Focused state

screenshot screenshot

Widget used to enter the message and add attachments

class ChannelPage extends StatelessWidget {
  const ChannelPage({
    Key key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: ChannelHeader(),
      body: Column(
        children: <Widget>[
          Expanded(
            child: MessageListView(
              threadBuilder: (_, parentMessage) {
                return ThreadPage(
                  parent: parentMessage,
                );
              },
            ),
          ),
          MessageInput(),
        ],
      ),
    );
  }
}

You usually put this widget in the same page of a MessageListView as the bottom widget.

The widget renders the ui based on the first ancestor of type StreamChatTheme. Modify it to change the widget appearance.

Inheritance

Constructors

MessageInput({Key? key, void onMessageSent(Message)?, FutureOr<Message> preMessageSending(Message)?, Message? parentMessage, Message? editMessage, double maxHeight = 150, TextInputType keyboardType = TextInputType.multiline, bool disableAttachments = false, Message? initialMessage, TextEditingController? textEditingController, List<Widget> actions = const [], ActionsLocation actionsLocation = ActionsLocation.left, Map<String, AttachmentThumbnailBuilder>? attachmentThumbnailBuilders, FocusNode? focusNode, Message? quotedMessage, VoidCallback? onQuotedMessageCleared, SendButtonLocation sendButtonLocation = SendButtonLocation.outside, bool autofocus = false, bool hideSendAsDm = false, Widget? idleSendButton, Widget? activeSendButton, bool showCommandsButton = true, @Deprecated('''Use `userMentionsTileBuilder` instead. Will be removed in future release''') MentionTileBuilder? mentionsTileBuilder, UserMentionTileBuilder? userMentionsTileBuilder, int maxAttachmentSize = _kDefaultMaxAttachmentSize, VideoQuality compressedVideoQuality = VideoQuality.DefaultQuality, int compressedVideoFrameRate = 30, ErrorListener? onError, int attachmentLimit = 10, AttachmentLimitExceedListener? onAttachmentLimitExceed, ActionButtonBuilder? attachmentButtonBuilder, ActionButtonBuilder? commandButtonBuilder, List<OverlayOptions> customOverlays = const [], bool mentionAllAppUsers = false, bool? shouldKeepFocusAfterMessage})
Instantiate a new MessageInput
const

Properties

actions List<Widget>
List of action widgets
final
actionsLocation ActionsLocation
The location of the custom actions
final
activeSendButton Widget?
Send button widget in an active state
final
attachmentButtonBuilder ActionButtonBuilder?
Builder for customizing the attachment button.
final
attachmentLimit int
A limit for the no. of attachments that can be sent with a single message.
final
attachmentThumbnailBuilders Map<String, AttachmentThumbnailBuilder>?
Map that defines a thumbnail builder for an attachment type
final
autofocus bool
Autofocus property passed to the TextField
final
commandButtonBuilder ActionButtonBuilder?
Builder for customizing the command button.
final
compressedVideoFrameRate int
Frame rate to use when compressing the videos
final
compressedVideoQuality VideoQuality
Video quality to use when compressing the videos
final
customOverlays List<OverlayOptions>
List of options for showing overlays
final
disableAttachments bool
If true the attachments button will not be displayed
final
editMessage Message?
Message to edit
final
focusNode FocusNode?
The focus node associated to the TextField
final
hashCode int
The hash code for this object.
no setterinherited
hideSendAsDm bool
Hide send as dm checkbox
final
idleSendButton Widget?
Send button widget in an idle state
final
initialMessage Message?
Message to start with
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
keyboardType TextInputType
The keyboard type assigned to the TextField
final
maxAttachmentSize int
Max attachment size in bytes Defaults to 20 MB do not set it if you're using our default CDN
final
maxHeight double
Maximum Height for the TextField to grow before it starts scrolling
final
mentionAllAppUsers bool
When enabled mentions search users across the entire app.
final
mentionsTileBuilder MentionTileBuilder?
Customize the tile for the mentions overlay.
final
onAttachmentLimitExceed AttachmentLimitExceedListener?
A callback for when the attachmentLimit is exceeded.
final
onError ErrorListener?
A callback for error reporting
final
onMessageSent → (void Function(Message)?)
Function called after sending the message
final
onQuotedMessageCleared VoidCallback?
final
parentMessage Message?
Parent message in case of a thread
final
preMessageSending → (FutureOr<Message> Function(Message)?)
Function called right before sending the message Use this to transform the message
final
quotedMessage Message?
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sendButtonLocation SendButtonLocation
The location of the send button
final
shouldKeepFocusAfterMessage bool?
Defines if the MessageInput loses focuses after a message is sent. The default behaviour keeps focus until a command is enabled.
final
showCommandsButton bool
Use this property to hide/show the commands button
final
textEditingController TextEditingController?
The text controller of the TextField
final
userMentionsTileBuilder UserMentionTileBuilder?
Customize the tile for the mentions overlay.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() MessageInputState
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
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

Static Methods

of(BuildContext context) MessageInputState
Use this method to get the current StreamChatState instance