import 'package:flutter/material.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, title: 'Scaffold Example', home: MyHomePage(), ); } } class MyHomePage extends StatefulWidget { @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { int _selectedIndex = 0; // Method to handle bottom navigation bar item taps void _onItemTapped(int index) { setState(() { _selectedIndex = index; }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Scaffold Example'), foregroundColor: Colors.white, backgroundColor: Colors.green, ), body: Center( child: Text( 'Selected Index: $_selectedIndex', style: TextStyle(fontSize: 24, color: Colors.black), ), ), floatingActionButton: FloatingActionButton( onPressed: () { ScaffoldMessenger.of(context).showSnackBar( SnackBar(content: Text('Floating Action Button Pressed')), ); }, child: Icon( Icons.add, color: Colors.white, ), backgroundColor: Colors.green, ), drawer: Drawer( child: ListView( padding: EdgeInsets.zero, children: <Widget>[ DrawerHeader( decoration: BoxDecoration( color: Colors.green, ), child: Text( 'GeeksforGeeks', style: TextStyle( color: Colors.white, fontSize: 24, ), ), ), ListTile( title: Text('Item 1'), onTap: () { // Handle item 1 tap Navigator.pop(context); }, ), ListTile( title: Text('Item 2'), onTap: () { // Handle item 2 tap Navigator.pop(context); }, ), ], ), ), endDrawer: Drawer( child: ListView( padding: EdgeInsets.zero, children: <Widget>[ DrawerHeader( decoration: BoxDecoration( color: Colors.blue, ), child: Text( 'End Drawer', style: TextStyle( color: Colors.white, fontSize: 24, ), ), ), ListTile( title: Text('End Drawer Item 1'), onTap: () { Navigator.pop(context); }, ), ], ), ), bottomNavigationBar: BottomNavigationBar( items: const <BottomNavigationBarItem>[ BottomNavigationBarItem( icon: Icon(Icons.home), label: 'Home', ), BottomNavigationBarItem( icon: Icon(Icons.search), label: 'Search', ), BottomNavigationBarItem( icon: Icon(Icons.person), label: 'Profile', ), ], currentIndex: _selectedIndex, selectedItemColor: Colors.green, onTap: _onItemTapped, ), persistentFooterButtons: <Widget>[ TextButton( onPressed: () {}, child: Text('Footer Button 1'), ), TextButton( onPressed: () {}, child: Text('Footer Button 2'), ), ], backgroundColor: Colors.white, resizeToAvoidBottomInset: false, drawerScrimColor: Colors.black.withOpacity(0.5), ); } }