insertMessage abstract method

Future<void> insertMessage(
  1. Message message, {
  2. int? index,
})

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 with index 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});