In section 2 chapter 3 (basic widgets) the _onTappedItem function has a Parameter that is taking in an int index, but when we call the _onTappedItem in the bottomNavigationBar we aren’t passing in any parameters to the function. How does the function know what the index is?
void _onTappedItem(int index) {
setState(() {
_selectedIndex = index;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
....
),
body: pages[_selectedIndex],
bottomNavigationBar: BottomNavigationBar(
currentIndex: _selectedIndex,
onTap: _onTappedItem,
selectedItemColor: Theme.of(context).textSelectionTheme.selectionColor,
items: <BottomNavigationBarItem>[
....
],
),
);
}