Open
Description
In my scenario, When the widget loads, I want it to automatically jump/scroll to a specific selected index in the list.
If I do this with a button trigger, it correctly scrolls to the spot in the list.
However, when I try to to do this from initState, It throws the error "Null check operator used on a null value".
final ItemScrollController itemScrollController = ItemScrollController();
final ItemPositionsListener itemPositionsListener = ItemPositionsListener.create();
initState
@override
initState(){
itemScrollController.jumpTo(index: 5);
super.initState();
}
In my widget tree?
ScrollablePositionedList.builder(
itemCount: widget.tables.length,
itemBuilder: (context, index) => ListTile(
leading: GBIcon(
hexColor: widget.tables[index].tableId == widget.currentTable.tableId
? '#FFFFFF'
: widget.block.color,
icon: widget.tables[index].icon,
size: 24),
title: Text(widget.tables[index].name),
selected: widget.tables[index].tableId == widget.currentTable.tableId,
selectedTileColor: hexStringToColor(widget.block.color),
onTap: () async {
widget.loadTable(widget.tables[index].tableId.toString());
},
),
itemScrollController: itemScrollController,
itemPositionsListener: itemPositionsListener,
)