StreamThreadHeader constructor

const StreamThreadHeader({
  1. Key? key,
  2. required Message parent,
  3. bool showBackButton = true,
  4. VoidCallback? onBackPressed,
  5. Widget? title,
  6. Widget? subtitle,
  7. bool? centerTitle,
  8. Widget? leading,
  9. List<Widget>? actions,
  10. VoidCallback? onTitleTap,
  11. bool showTypingIndicator = true,
  12. Color? backgroundColor,
  13. double elevation = 1,
})

screenshot screenshot

Shows information about the current message thread.

class ThreadPage extends StatelessWidget {
  final Message parent;

  ThreadPage({
    Key key,
    this.parent,
  }) : super(key: key);

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

Usually you would use this widget as an AppBar inside a Scaffold. However you can also use it as a normal widget.

A StreamChannel ancestor is required in order to provide the information about the channel.

Every part of the widget uses a StreamBuilder to render the channel information as soon as it updates.

By default the widget shows a backButton that calls Navigator.pop. You can disable this button using the showBackButton property. Alternatively, you can override the behavior with onBackPressed.

The UI is rendered based on the first ancestor of type StreamChatTheme and the ChannelTheme.channelHeaderTheme property. Modify it to change the widget's appearance.

Implementation

const StreamThreadHeader({
  super.key,
  required this.parent,
  this.showBackButton = true,
  this.onBackPressed,
  this.title,
  this.subtitle,
  this.centerTitle,
  this.leading,
  this.actions,
  this.onTitleTap,
  this.showTypingIndicator = true,
  this.backgroundColor,
  this.elevation = 1,
}) : preferredSize = const Size.fromHeight(kToolbarHeight);