controller property

ScrollController controller
final

The ScrollController used to implement Scrollbar dragging.

introduced in iOS 13.

If nothing is passed to controller, the default behavior is to automatically enable scrollbar dragging on the nearest ScrollController using PrimaryScrollController.of.

If a ScrollController is passed, then scrollbar dragging will be enabled on the given ScrollController. A stateful ancestor of this CupertinoScrollbar needs to manage the ScrollController and either pass it to a scrollable descendant or use a PrimaryScrollController to share it.

Here is an example of using the controller parameter to enable scrollbar dragging for multiple independent ListViews:

{@inject-html}

final ScrollController _controllerOne = ScrollController();
final ScrollController _controllerTwo = ScrollController();

build(BuildContext context) { return Column( children: <Widget> Container( height: 200, child: CupertinoScrollbar( controller: _controllerOne, child: ListView.builder( controller: _controllerOne, itemCount: 120, itemBuilder: (BuildContext context, int index) =&gt; Text(&#39;item $index&#39;), ), ), ), Container( height: 200, child: CupertinoScrollbar( controller: _controllerTwo, child: ListView.builder( controller: _controllerTwo, itemCount: 120, itemBuilder: (BuildContext context, int index) =&gt; Text(&#39;list 2 item $index&#39;), ), ), ), , ); }

{@end-inject-html}

Implementation

final ScrollController controller