How to show scrollbar in SliverList? - flutter

I'm using SliverAppBar and SliverList as main containers in my app.
When I try to wrap SliverList in Scrollbar widget, I get an error, and when I wrap whole CustomScrollView in Scrollbar, it overlaps SliverAppBar.
So how can I show scrollbar indicator only in my SliverList?
Thanks in advance.

Check out #JLarana's answer at
https://stackoverflow.com/a/62938436/10647220
But basically what you need to do is:
ScrollController _scrollController = ScrollController();
...
body: PrimaryScrollController(
controller: _scrollController,
child: CupertinoScrollbar(
child: CustomScrollView(
slivers:[
your slivers code here
]

If I understand your question correctly... as of Flutter 1.12 released in Dec 2019, I think this issue is currently tracked under
https://github.com/flutter/flutter/issues/13253
I'm not aware of a easy solution for this(maybe NestedScrollView will solve your problem, but it has some subtle fidelity issues so I don't want to use).

Related

How to show scroll indicator, Scrollbar on certain position of the screen? Flutter

Is there a way in Flutter to show a scroll indicator only on a specific widget?
For instance, I have the following widget tree
CustomScrollView(
slivers: [
sliverAppBar(),
sliverToBoxAdapter(), // horizontal list view
SliverList(delegate: SliverChildBuilderDelegate()) // show scrollbar only for this widget
],
),
Here is a demonstration of the iOS app Telegram, I have something similar in my app, notice when the header collapses a gray scroll indicator shows up.
Any idea on how to implement this behavior will be highly appreciated
You can use Scrollable List which provide you the nice way to fulfill your requirements

NestedScrollView persistent header sometimes looks awkward

Often when scroll is fast enough my app shows a small transparent line between scrolling view and persistent header.
Minimal reproducible code:
https://gist.github.com/Moonspeaker/0e8573ff6620a7e00b8f7b04937b51a1
This is how it looks recorded on video:
https://www.youtube.com/watch?v=DDxu1NTkaMA&feature=youtu.be
I have no clue how to fix this. The issue seems to be in Align widget with Alginment.bottomCenter. Column with MainAxisAlignment.end works the same way.
Try wrapping your SliverPersistentHeader with a SliverOverlapAbsorber
usually when working with NestedScrollView you will need to wrap the header in this object in order to not encounter rare scrolling artifacts like the red line you described.
I was not able to reproduce the issue with the change stated below.
But you could also take a look to SliverOverlapInjector and the NestedScrollView class documentation which has examples using both of these widgets
...
NestedScrollView(
headerSliverBuilder: (context, scrolling) => [
SliverOverlapAbsorber(
handle:
NestedScrollView.sliverOverlapAbsorberHandleFor(context),
sliver: SliverPersistentHeader(
delegate: _Delegate(),
pinned: true,
),
...

Horizontal Scroll Bar in flutter

I am new to flutter, I need to add an horizontal scroll bar as in the image, how can I go about in doing so. https://i.stack.imgur.com/rfsNB.png
you can test with a ListView, and using the property scrollDirection: Axis.horizontal.
You can get more info in this link:
https://flutter.dev/docs/cookbook/lists/horizontal-list
you can just wrap your widget with the Scrollbar() widget and it will do your job
for further information you can read the docs here
https://api.flutter.dev/flutter/material/Scrollbar-class.html

CustomScrollview with TabBarView that overflows

So I'm having some difficulty using the following Setup:
CustomScrollView(
slivers: [
SliverAppBar(...),
SliverToBoxAdapter(SomeRandomWidget),
SliverPersistentHeader(TabBar),
SliverFillRemaining(TabBarView)
])
So the TabBarView contains a Column on one tab, that overflows the screen. The issue is, that even though SliverFillRemaining is obviously not the right choice for the overflowing Widget but sadly as TabBarView looses the hasSize property of its children, I don't know what other Widget I could use to get the layout going. The goal is to achieve something like this (shows the current overflow):
EDIT: Here is a working example on DartPad: https://dartpad.dev/bda4cc5fd2aea292310fe05daa440760
try using extended_nested_scroll_view, maybe that's what you looking for
add floating: true, under pinned: true,

How to create a floating widget that moves as the page scrolls in Flutter

I want to create a floating widget in the ListView.builder, which will follow the scrolled position as in many web sites or another applications.
I never saw such a widget nor can find. Can anybody share with his experience or give some good idea to how create such a widget?
I suggest you take a look at FloatingActionButton widget.
You can read more about this widget from the official documentation: https://api.flutter.dev/flutter/material/FloatingActionButton-class.html
I found a couple of solution for my question.
First, Flutter already Have a widget called Scrollbar. You can wrap with him some scrollable widgets like:ListView or GridView etc.
It will give you a simple draggable widget with vertical axis on the right side.
This is an example:
Scrollbar(
child: ListView.builder(
itemCount: 50,
itemBuilder: (context, index) => ListTile(title: Text("Item= ${index + 1}"),),),
)
But you can't customize this widget's, for example height or width, and I found another custom created widget, which is added to pub.dev also. The package name is draggable_scrollbar and this was what I need. There are some styled widgets for scrollbar and custom one, that you can customize as you wish.