I already implemented NestedScrollView
and this is my result.
Before Scrolled:
After Scrolled:
The question are:
- In the Before Scrolled section, how to make the default
Live Button
is in the center ofAppBar
? - In the After Scrolled section, when the user scrolled to the top, the
Live Button
is moved from the center (default) to the right (besidesChat Button
). - In the After Scrolled section, when the user scrolled to the top, the
title
should not overlap withBack Button
,Live Button
, andChat Button
but thetitle prefix
is should to the right ofBack Button
, and thetitle suffix
should to the left ofLive Button
, andLive Button
should to the left ofChat Button
.
This is my code for building AppBar
:
Widget _customAppBar(EventEntity event) {
return SliverAppBar(
expandedHeight: 200 + _appBarHeight,
floating: false,
pinned: true,
leading: _buildNavButton(), // Back Button (Left)
actions: <Widget>[
// Live Button (Right)
event?.status != null &&
event.status == EventStatus.LIVE
? Center(child: LiveLabel(),)
: Container(),
// Chat Button (Right)
HelpButton(),
],
flexibleSpace: FlexibleSpaceBar(
centerTitle: true,
title: Text(
widget.event.name.trim(),
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 24,
),
overflow: TextOverflow.ellipsis,
maxLines: 1,
textAlign: TextAlign.center,
),
background: Hero(
tag: '--${widget.visibilityFilter} __${widget.event.id}',
child: DinoNetworkImage(
imageUrl: widget.event.image,
fit: BoxFit.contain,
),
),
),
);
}
And this is the build
method:
Widget build(BuildContext context) {
return Scaffold(
key: _scaffoldKey,
body: SafeArea(
top: true,
bottom: false,
child: Stack(
fit: StackFit.expand,
children: <Widget>[
NestedScrollView(
headerSliverBuilder: (BuildContext context,
bool innerBoxIsScrolled) {
return <Widget>[
_customAppBar(widget.event),
];
},
body: SingleChildScrollView(
....
),
),
....
],
),
),
);
}
How to make that happens with my code?