Home > Net >  Flutter itemScrollController at start app directly jump to index without pushing buttons
Flutter itemScrollController at start app directly jump to index without pushing buttons

Time:07-20

How can I prepare ItemScrollController _scrollController = ItemScrollController(); when the app are starting, it jumps directly to the index?

I am using the ScrollablePositionedList: https://pub.dev/packages/scrollable_positioned_list

CodePudding user response:

Try this.

@override
void initState() {
   WidgetsBinding.instance.addPostFrameCallback((_) {
   // executes after build
   _scrollController.jumpTo(index: YOUR_INDEX);
   });
   super.initState();
}
  • Related