Search code examples
linuxfluttermacosdartscrollcontroller

Flutter Linuix & Mac OS & Web: The provided ScrollController is currently attached to more than one ScrollPosition


I used Flutter Linuix:

I had a few basic children that need to scroll a little bit so I needed a listview to enable scrolling and got this exception a smple code like this:

ListView(
  children: [
    Text(
      'data',
      style: TextStyle(fontSize: 215),
    ),
    Text(
      'data',
      style: TextStyle(fontSize: 215),
    ),
    Text(
      'data',
      style: TextStyle(fontSize: 215),
    ),
  ],
)

The following assertion was thrown while notifying status listeners for AnimationController: The provided ScrollController is currently attached to more than one ScrollPosition.


Solution

  • The solution is simple just add controllor to the listveiw like this:

    ListView(
          controller: ScrollController(),
      children: [
        Text(
          'data',
          style: TextStyle(fontSize: 215),
        ),
        Text(
          'data',
          style: TextStyle(fontSize: 215),
        ),
        Text(
          'data',
          style: TextStyle(fontSize: 215),
        ),
      ],
    )
    

    source:

    https://github.com/flutter/flutter/issues/85456