Developed with π by netglade
A truly customizable sliver for app bars with the benefit of using builders. Check the storybook demo and play with it yourself.
SliverAppBarBuilder
supports various configurations:
Using the package is simple.
Just use the sliver SliverAppBarBuilder
in place of SliverAppBar
,
configure all the properties,
and enjoy.
Each builder, for content or leading/trailing actions, provides expand ratio and content/bar height, so you can easily use these values to customize your headers.
expandRatio
is a value between 1.0
when expanded and 0.0
when shrunkencontentHeight
/barHeight
are current heights of corresponding partsContent builder has additional property:
centerPadding
, when contentBelowBar
is false, is a value used to offset content to center it with barAn example of a header with title moving from under back button to its right might look like this:
CustomScrollView(
slivers: [
SliverAppBarBuilder(
barHeight: 60,
pinned: true,
leadingActions: [
(context, expandRatio, barHeight, overlapsContent) {
return SizedBox(
height: barHeight,
child: const BackButton(),
);
}
],
initialContentHeight: 150,
contentBuilder: (context, expandRatio, contentHeight, overlapsContent) {
return Container(
alignment: Alignment.centerLeft,
height: 60,
transform: Matrix4.translationValues(10 + (1 - expandRatio) * 40, 0, 0),
child: Text(
'My Title',
style: TextStyle(
fontSize: 22 + expandRatio * 10,
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
);
},
),
],
);