MessageForwardSheet class

"Forward to…" picker.

Renders a modal bottom sheet listing every candidate target room (caller filters out the source room) with multi-select checkboxes and a confirm button. Returns the selected target ids on confirm, null on cancel.

Designed to be the most-configurable forwarding surface in the SDK — every visual chunk has an override (title, row, confirm button, empty state) and the empty-rooms case has both a short-circuit callback (MessageForwardSheet.show.onEmpty) AND an in-sheet builder (emptyStateBuilder). Consumers can mix-and-match.

Wraps the standard "show modal + collect selection" flow as a static helper so most call sites are a single line:

final ids = await MessageForwardSheet.show(
  context: context,
  rooms: rooms,
  theme: theme,
);
if (ids != null) adapter.messages.forward(...);
Inheritance

Constructors

MessageForwardSheet({Key? key, required List<RoomListItem> rooms, List<String> initialSelectedIds = const [], int? maxSelection, bool searchEnabled = false, String? title, WidgetBuilder? titleBuilder, MessageForwardRowBuilder? rowBuilder, String? confirmLabel, MessageForwardConfirmBuilder? confirmBuilder, WidgetBuilder? emptyStateBuilder, ChatTheme theme = ChatTheme.defaults})
const

Properties

confirmBuilder MessageForwardConfirmBuilder?
Builder for the confirm button. Replaces the default ElevatedButton. Receives the live selectedIds and an onConfirm callback to pop with that list.
final
confirmLabel String?
Label for the default confirm button. Ignored when confirmBuilder is supplied. Defaults to theme.l10n.forward.
final
emptyStateBuilder WidgetBuilder?
Widget shown INSIDE the sheet when no rooms remain to choose from (initial list empty, or search filtered everything out). Defaults to a centred text using theme.l10n.noChatsToForward. To handle the "no candidates at all" case BEFORE opening the sheet (e.g. to navigate to a "New chat" page instead of showing an empty modal), pass onEmpty to show instead.
final
hashCode int
The hash code for this object.
no setterinherited
initialSelectedIds List<String>
Rooms pre-selected when the sheet opens. Useful for "forward to the same chats as last time" UX.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
maxSelection int?
Optional cap on simultaneous selections. When the cap is reached, additional checkbox taps are silently ignored (the rebuild keeps the previous state). null = unlimited.
final
rooms List<RoomListItem>
Candidate target rooms. The caller should pre-filter out the source room (the one the message was forwarded FROM); this widget does not assume any context about the original room.
final
rowBuilder MessageForwardRowBuilder?
Per-row builder — replaces the default CheckboxListTile + avatar UI. Called once per visible room (after search filtering when enabled).
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
searchEnabled bool
When true, a search field is rendered above the list and the row list is filtered by case-insensitive substring match on the room display name as the user types.
final
theme ChatTheme
final
title String?
Sheet title text. Overridden by titleBuilder when both are supplied. Defaults to theme.l10n.forwardTo.
final
titleBuilder WidgetBuilder?
Builder for the sheet title. Replaces both the default text and the title override; useful for a row with an icon, an action, or a custom typography. The returned widget is laid out inside the sheet's top padding.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<MessageForwardSheet>
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, int wrapWidth = 65}) 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

show({required BuildContext context, required List<RoomListItem> rooms, List<String> initialSelectedIds = const [], int? maxSelection, bool searchEnabled = false, String? title, WidgetBuilder? titleBuilder, MessageForwardRowBuilder? rowBuilder, String? confirmLabel, MessageForwardConfirmBuilder? confirmBuilder, WidgetBuilder? emptyStateBuilder, MessageForwardEmptyCallback? onEmpty, ChatTheme theme = ChatTheme.defaults}) Future<List<String>?>
Convenience: builds + shows the sheet on the modal stack.