import 'package:flutter/material.dart'; // Entry point of the application void main() => runApp(const MyApp()); // Main application widget class MyApp extends StatelessWidget { static const String _title = 'Flutter BottomNavigationBar'; const MyApp({super.key}); @override Widget build(BuildContext context) { return const MaterialApp( title: _title, home: MyStatefulWidget(), ); } } // Stateful widget to manage the // state of the BottomNavigationBar class MyStatefulWidget extends StatefulWidget { const MyStatefulWidget({super.key}); @override _MyStatefulWidgetState createState() => _MyStatefulWidgetState(); } class _MyStatefulWidgetState extends State<MyStatefulWidget> { // Index to keep track of the selected tab int _selectedIndex = 0; // TextStyle for the text displayed in each tab static const TextStyle optionStyle = TextStyle(fontSize: 30, fontWeight: FontWeight.bold); // List of widgets to display in each tab static const List<Widget> _widgetOptions = <Widget>[ Text( 'HOME PAGE', style: optionStyle, ), Text( 'COURSE PAGE', style: optionStyle, ), Text( 'CONTACT GFG', style: optionStyle, ), ]; // Method to handle tab selection void _onItemTapped(int index) { setState(() { _selectedIndex = index; }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text( 'GeeksForGeeks', style: TextStyle( color: Colors.white, ), ), backgroundColor: Colors.green, ), body: Center( child: _widgetOptions.elementAt(_selectedIndex), ), bottomNavigationBar: BottomNavigationBar( items: const <BottomNavigationBarItem>[ BottomNavigationBarItem( icon: Icon(Icons.home), label: 'Home', ), BottomNavigationBarItem( icon: Icon(Icons.bookmark), label: 'Courses', ), BottomNavigationBarItem( icon: Icon(Icons.contact_mail), label: 'Mail', ), ], currentIndex: _selectedIndex, selectedItemColor: Colors.amber[800], onTap: _onItemTapped, ), ); } }