# How is \_onTappedItem parameter passed?

**URL:** <https://forums.kodeco.com/t/how-is-ontappeditem-parameter-passed/158087>\
**Category:** Flutter Apprentice\
**Created:** [November 20, 2021, 5:16am UTC](https://forums.kodeco.com/t/how-is-ontappeditem-parameter-passed/158087 "2021-11-20T05:16:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fjam](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/fjam/32/100875_2.png) [@fjam](https://forums.kodeco.com/u/fjam)\
**Post date:** [November 20, 2021, 5:16am UTC](https://forums.kodeco.com/t/how-is-ontappeditem-parameter-passed/158087/1 "2021-11-20T05:16:49Z")

</div>

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?

```auto
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>[
          ....
        ],
      ),
    );
  }

```

---

<div class="post-metadata">

**Author:** ![jomoka](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/jomoka/32/109828_2.png) [@jomoka](https://forums.kodeco.com/u/jomoka)\
**Post date:** [November 21, 2021, 4:49am UTC](https://forums.kodeco.com/t/how-is-ontappeditem-parameter-passed/158087/2 "2021-11-21T04:49:30Z")

</div>

Think of \_onTappedItem the function you trigger when someone taps on a tab bar item! onTap will return the index to \_onTappedItem
