diff --git a/CHANGELOG.md b/CHANGELOG.md index 9bee2c8..a61398b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ ## 4.0.0 - Add a serviceBuilder to the userstory configuration - +- Add a listHeaderBuilder for showing a header at the top of the list of posts in the timeline ## 3.0.1 diff --git a/packages/flutter_timeline_view/lib/src/config/timeline_options.dart b/packages/flutter_timeline_view/lib/src/config/timeline_options.dart index e7c7c9b..b3c04d4 100644 --- a/packages/flutter_timeline_view/lib/src/config/timeline_options.dart +++ b/packages/flutter_timeline_view/lib/src/config/timeline_options.dart @@ -52,6 +52,7 @@ class TimelineOptions { this.maxContentLength, this.categorySelectorButtonBuilder, this.postOverviewButtonBuilder, + this.listHeaderBuilder, this.titleInputDecoration, this.contentInputDecoration, }); @@ -156,6 +157,11 @@ class TimelineOptions { String text, )? categorySelectorButtonBuilder; + /// This widgetbuilder is placed at the top of the list of posts and can be + /// used to add custom elements + final Widget Function(BuildContext context, String? category)? + listHeaderBuilder; + /// Builder for the post overview button /// on the timeline post overview screen final Widget Function( diff --git a/packages/flutter_timeline_view/lib/src/screens/timeline_screen.dart b/packages/flutter_timeline_view/lib/src/screens/timeline_screen.dart index 1d25524..a9d7575 100644 --- a/packages/flutter_timeline_view/lib/src/screens/timeline_screen.dart +++ b/packages/flutter_timeline_view/lib/src/screens/timeline_screen.dart @@ -223,6 +223,9 @@ class _TimelineScreenState extends State { child: Column( mainAxisSize: MainAxisSize.min, children: [ + /// Add a optional custom header to the list of posts + widget.options.listHeaderBuilder?.call(context, category) ?? + const SizedBox.shrink(), ...posts.map( (post) => Padding( padding: widget.options.postPadding,