Bottom navigation bar item underline selected icon

Solution 1:

Try using 'TabBar' and use onTap as onChanged since they are both of type ValueChanged<int>

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key}) : super(key: key);

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage>
    with SingleTickerProviderStateMixin {
  late final TabController controller;

  @override
  void initState() {
    controller = TabController(length: 4, vsync: this);
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      bottomNavigationBar: TabBar(
        controller: controller,
        unselectedLabelColor: Colors.grey,
        labelColor: Colors.blue,
        onTap: (index) {},
        tabs: const [
          Tab(icon: Icon(Icons.menu_rounded)),
          Tab(icon: Icon(Icons.piano)),
          Tab(icon: Icon(Icons.car_rental_rounded)),
          Tab(icon: Icon(Icons.settings_rounded)),
        ],
      ),
    );
  }
}

Solution 2:

Using Tabbar with DefaultTabController you can get your desired result. I'm sharing a reference code you can customize it as per your need.

 return  DefaultTabController(
          length: 4,
          child: Scaffold(
            body: TabBarView(
              children: [
                Center(
                  child: Text("1st Screen"),
                ),
                Center(
                  child: Text("2nd Screen"),
                ),
                Center(
                  child: Text("3rd Screen"),
                ),
                Center(
                  child: Text("4th Screen"),
                ),
              ],
            ),
            bottomNavigationBar: TabBar(
              labelColor: Colors.red,
                tabs: [
              Tab(child: Icon(Icons.more_vert_sharp),),
              Tab(child: Icon(Icons.local_play_sharp),),
              Tab(child: Icon(Icons.directions_car),),
              Tab(child: Icon(Icons.home),),
            ]),
          ),
        );