StreamChannelHeader constructor

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

screenshot screenshot

Shows information about the current Channel.

class MyApp extends StatelessWidget {
  final StreamChatClient client;
  final Channel channel;

  MyApp(this.client, this.channel);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: StreamChat(
        client: client,
        child: StreamChannel(
          channel: channel,
          child: Scaffold(
            appBar: ChannelHeader(),
          ),
        ),
      ),
    );
  }
}

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

Make sure to have a StreamChannel ancestor 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 this behaviour via the onBackPressed callback.

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

Implementation

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