insertMessage abstract method
Inserts a new message
into the list, optionally at a specific index
.
The index
refers to the position in the underlying content list (where 0
is typically the oldest message and messages.length - 1
is the newest).
- To add a new message that should appear at the visual end of the chat
(bottom for both normal and reversed lists), call this method without an
index
or withindex
equal to the current number of messages. The controller will typically append the message. - To prepend messages (e.g., loading older history that should appear at the
visual top), pass
index: 0
.
Implementation
Future<void> insertMessage(Message message, {int? index});