I've been trying to figure out how to add a Scrollbar Widget to a CustomScrollView. One would usually just have to wrap a ListView or ScrollView with a Scrollbar Widget, pass in the same ScrollController and boom, it's rendered.
Here is a minimal code block.
CustomScrollView(
slivers: [
SliverAppBar(
title: Hero(
tag: 'title',
child: RichText(
text: TextSpan(
children: [
TextSpan(
text: 'Not',
style: TextStyle( fontSize: 20, fontWeight: FontWeight.w500),
),
TextSpan(
text: '3s',
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w500),
)
],
),
),
),
),
SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
return Container(); })));
I got it.
Create a _scrollController.
Wrap the CustomScrollView() in a ScrollBar() Widget.
Set the controller: parameter of BOTH CustomerScrollView and ScrollBar as the _scrollController.
final _scrollController = ScrollController();
return Scaffold(
body: Scrollbar(
controller: _scrollController,
isAlwaysShown: true,
child: CustomScrollView(
controller: _scrollController,
slivers: <Widget> [
...
Modify as you need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With