t×tecexpressby TeKOcloud
DEv0.7.1
Data & views / FLUTTER

TxChat.

Interactive preview

Local message history with authors, typing indicators and send events. sent confirms local acceptance, not server delivery.

TxChat

ParameterTypeDefaultMeaning
userTxChatUserrequiredCurrent chat author.
itemsList<TxChatMessage>?nullEntries; replaced by dataSource when bound.
dataSourceObject?nullList, configuration or DataSource instance; takes precedence over items.
onItemsChangedValueChanged<List<TxChatMessage>>?nullReports items; update controlled state in the callback.
controllerTextEditingController?nullExternal text controller; the application disposes it.
initialTextString''Initial draft without an external controller.
onInputFieldTextChangedValueChanged<String>?nullReports inputFieldText; update controlled state in the callback.
onMessageEnteredValueChanged<TxChange<TxChatMessage>>?nullBefore local acceptance: TxChange<TxChatMessage>; set cancel synchronously to take over processing.
onMessageSentValueChanged<TxChatMessage>?nullProvides the locally accepted TxChatMessage; not a server delivery receipt.
onTypingStartValueChanged<TxChatUser>?nullReports the start of typing with the affected TxChatUser.
onTypingEndValueChanged<TxChatUser>?nullReports the end of typing with the affected TxChatUser.
titleString'Chat'View title.
subtitleString''Additional subtitle.
labelString'Chat'Label or accessible name.
placeholderString'Nachricht schreiben …'Hint for an empty input.
emptyTextString'Noch keine Nachrichten. Starte die Unterhaltung.'Empty state text.
disabledboolfalseDisables interaction.
readOnlyboolfalsePrevents value changes.
loadingboolfalseShows the loading state.
sendingboolfalseDisables sending during an application request.
maxLengthint4000Maximum text length.
typingUsersList<TxChatUser>const []Authors currently typing.
showAvatarbooltrueShows author avatars.
showUserNamebooltrueShows author names.
showDayHeadersbooltrueGroups messages using day headers.
showMessageTimestampbooltrueShows message timestamps.
localeString'de'Locale for date/time formatting.
heightdouble560Height; Vue numbers use pixels, Flutter uses logical pixels.
headerWidget?nullCustom header.
emptyWidget?nullCustom empty state.
messageBuilderWidget Function(BuildContext context, TxChatMessage message, bool isOwn)?nullBuilds custom content; callback arguments and return type are given in the signature.
dart
import 'package:flutter/material.dart';
import 'package:tecexpress/tecexpress.dart';

Widget example() {
  var messages = <TxChatMessage>[];
  return StatefulBuilder(
    builder: (context, setState) => TxChat(user: TxChatUser(id: 'me', name: 'Alex'), items: messages, onItemsChanged: (v) => setState(() => messages = v)),
  );
}