-
Notifications
You must be signed in to change notification settings - Fork 214
feat: ✨ Add headerSlivers support to ChatList for advanced pinned headers
#429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,6 +56,7 @@ class ChatList extends StatefulWidget { | |
| this.chatBuilder, | ||
| this.appbar, | ||
| this.loadMoreChats, | ||
| this.headerSlivers, | ||
| this.header, | ||
| this.footer, | ||
| this.isLastPage, | ||
|
|
@@ -83,6 +84,12 @@ class ChatList extends StatefulWidget { | |
| /// If set to `true`, pagination will not trigger loading more chats. | ||
| final ValueGetter<bool>? isLastPage; | ||
|
|
||
| /// List of sliver headers to be displayed at the top of the chat list. | ||
| /// | ||
| /// Each widget in this list must be a sliver widget that builds a | ||
| /// [RenderSliver] (e.g. [SliverAppBar], [SliverPersistentHeader], etc.) | ||
| final List<Widget>? headerSlivers; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The parameter type List? accepts any widget, but only sliver widgets (those that build a RenderSliver) are valid inside a CustomScrollView. Passing a non-sliver widget (e.g. Container) will throw a cryptic runtime exception. |
||
|
|
||
| /// Header widget to be displayed at the top of the chat list. | ||
| final Widget? header; | ||
|
|
||
|
|
@@ -179,6 +186,7 @@ class _ChatListState extends State<ChatList> { | |
| ), | ||
| ), | ||
| ), | ||
| ...?widget.headerSlivers, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The headerSlivers are inserted after searchConfig but before header. A SliverAppBar passed here will render between the search field and the chat list, which feels unintuitive. The existing appbar param already handles the top-most position. |
||
| if (widget.header case final header?) SliverToBoxAdapter(child: header), | ||
| StreamBuilder<List<ChatListItem>>( | ||
| stream: _controller.chatListStream, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
headerSliversis typed asList<Widget>, butCustomScrollView.sliversonly accepts widgets that build aRenderSliver. If a consumer passes a regular box widget (e.g.Container) it will throw at runtime. Consider tweaking the dartdoc to explicitly state each entry must be a sliver widget (or should be wrapped inSliverToBoxAdapter) to avoid misuse.