0

I want to add a Scrollbar to my ScrollablePositionedList (it's like a ListView, that let's you scroll do a specific child index on demand, from this package).
The Scrollbar displays correctly, and also updates it's position when I scroll up/down. But when I add interactive: true to the Scrollbar, it won't let me scroll, it gives me this Exception in the console when I try to scroll with the Scrollbar:

======== Exception caught by gesture ===============================================================
The following assertion was thrown while handling a gesture:
The Scrollbar's ScrollController has no ScrollPosition attached.

A Scrollbar cannot be painted without a ScrollPosition. 

The Scrollbar attempted to use the PrimaryScrollController. This ScrollController should be associated with the ScrollView that the Scrollbar is being applied to.A ScrollView with an Axis.vertical ScrollDirection on mobile platforms will automatically use the PrimaryScrollController if the user has not provided a ScrollController. To use the PrimaryScrollController explicitly, set ScrollView.primary to true for the Scrollable widget.

This is part of my code

final ItemScrollController _itemScrollController = ItemScrollController();

@override
Widget build(BuildContext context) {
  return Scrollbar(
    controller: ...? //this should be of type Scrollbar, I can't put _itemScrollController here
    thumbVisibility: true,
    thickness: 6,
    radius: Radius.circular(6),
    interactive: true,
    child: ScrollablePositionedList.builder(
      itemScrollController: _itemScrollController,
      //...
    );
}

It seems the developers of the package have not thought of this. I will also try to contact the developers, most likely share this issue on github too.

Does anyone have an idea for a workaround to get this to work?

Cedric
  • 470
  • 6
  • 20
  • other people already mentioned this in github: https://github.com/google/flutter.widgets/issues/273 – Cedric Mar 08 '23 at 09:01

0 Answers0