1

Although I add the ScrollController to the ListView, the client of the ScrollController does not appear. Result of print : ScrollController#a6158(no clients)

ScrollController sc = new ScrollController();
ListView(
  controller: sc,
  padding: const EdgeInsets.all(8.0),
  children: <Widget>[
    Container(
      height: 150,
      color: Colors.amber[600],
      child: const Center(child: Text('Entry A')),
    ),
    Container(
      height: 150,
      color: Colors.amber[500],
      child: const Center(child: Text('Entry B')),
    ),
    Container(
      height: 150,
      color: Colors.amber[100],
      child: const Center(child: Text('Entry C')),
    ),
  ],
);
print(sc.toString());
5
  • Please add more details for clarification Jul 25, 2019 at 10:39
  • Do you have a scrollcontroller listener? If you have a fixed number of items try ListView.builder and set the itemcount
    – F-1
    Jul 25, 2019 at 10:49
  • @F-1 My actual code uses ListView.builder but nothing changes. I wrote in this form for simplicity. Also there is no listener for sc
    – ahmet ay
    Jul 25, 2019 at 10:55
  • Where dif you added print(sc.toString()); after adding controller or before. It depands.
    – Sunny
    Jul 25, 2019 at 11:18
  • Just like in the code above.
    – ahmet ay
    Jul 25, 2019 at 11:20

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.