Flutter “no ScrollPosition attached” SOLVED

════════════ Exception caught by animation library ════════════════
The Scrollbar's ScrollController has no ScrollPosition attached.

The solution to this problem turned out to be, to assign the same scroll controller that I have assigned to the ListView.builder to the Scrollbar !

This problem didn’t exist not long ago, but since the solution is simple, here is a sample code snippet !

So the code to fix was simply this

Widget _buildParticipantDisplay() {
return Scrollbar(
interactive: true,
controller: scrollController,
child: ListView.builder(
itemCount: participants.length,
controller: scrollController,
itemExtent: 60,
itemBuilder: (context, index) {
return ListTile(
contentPadding: EdgeInsets.symmetric(horizontal: 50),
title: Text('participant: ${index + 1}'),
trailing: Text(participants[index]),
);
},
),
);
}

Leave a Reply

Your email address will not be published. Required fields are marked *