fluttercommunity / flutter-draggable-scrollbar

Draggable Scrollbar - A scrollbar that can be dragged for quickly navigation through a vertical list. Additional option is showing label next to scrollthumb with information about current item. Maintainer: @marica27
https://pub.dev/packages/draggable_scrollbar
MIT License
441 stars 77 forks source link

how to use draggable scrollbar with sliver list ? #4

Open nitneuq33000 opened 6 years ago

nitneuq33000 commented 6 years ago

hello , I tried to add the draggable scrollbar but I don't think how to use in out of your example. currently I use sliver list like this

new CustomScrollView ( slivers: [ SliverAppBar( automaticallyImplyLeading: false, elevation: 2.0, expandedHeight: 125.0, backgroundColor:Colors.grey.shade50, flexibleSpace: FlexibleSpaceBar( background: new Image.asset('assets/logo.png') ), ), SliverList ( delegate: SliverChildListDelegate (

[ ...] Have you an idea to implement this plugin in my exemple ? just need the more basic scrollbar. thank you
Maadhav commented 4 years ago

Did you find anything?

goldy1992 commented 4 years ago

This should be a feature request for the flutter team. At the moment this is not possible as a ScrollController can only be attached to one ScrollView. You cannot add the CustomScrollView's controller to the DraggableScrollbar as you will get the following exception:

ScrollController attached to multiple scroll views.

from the following method in ScrollScontroller:

  /// Returns the attached [ScrollPosition], from which the actual scroll offset
  /// of the [ScrollView] can be obtained.
  ///
  /// Calling this is only valid when only a single position is attached.
  ScrollPosition get position {
    assert(_positions.isNotEmpty, 'ScrollController not attached to any scroll views.');
    assert(_positions.length == 1, 'ScrollController attached to multiple scroll views.');
    return _positions.single;
  }

It looks like the flutter team need to design a solution for this use case.

deckerst commented 4 years ago

I don't think you need to pass the ScrollView controller to the DraggableScrollbar to achieve this. You just need to pass a CustomScrollView as a child. In my project I have something along these lines (without setting the scrollview controller):

    DraggableScrollbar(
      controller: myScrollController,
      child: CustomScrollView(
        slivers: [
          ...
        ],
      ),
    ),

That said, I forked this project a long time ago because of other issues. Feel free to try it

goldy1992 commented 4 years ago

@deckerst, have you published your version of draggable_scrollbar, or should I check it out locally?

deckerst commented 4 years ago

@goldy1992 please check it out locally.

goldy1992 commented 4 years ago

@deckerst there is still an issue on your version of the repo, but I cannot make an issue on your repo.

The problem is when you want the DraggableScrollbar to have the controller of a parent NestedScrollView.

The use case would be:

Without the DraggableScrollbar a normal ListView can control the parent NestedScrollView as expected.

However a DraggableScrollbar expects a child ScrollController

vauvenal5 commented 3 years ago

Hi! Any news on this issue?

atsince commented 1 month ago

use SuperSliverList replace SliverList https://pub.dev/packages/super_sliver_list