import
'package:flutter/material.dart'
;
void
main() => runApp(MyApp());
class
MyApp extends StatelessWidget {
static
const
String _title =
'Flutter Code Sample'
;
@override
Widget build(BuildContext context) {
return
MaterialApp(
title: _title,
home: MyStatefulWidget(),
);
}
}
class
MyStatefulWidget extends StatefulWidget {
MyStatefulWidget({Key key}) : super(key: key);
@override
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();
}
class
_MyStatefulWidgetState extends State<MyStatefulWidget> {
int
_selectedIndex = 0;
static
const
TextStyle optionStyle =
TextStyle(fontSize: 30, fontWeight: FontWeight.bold);
static
const
List<Widget> _widgetOptions = <Widget>[
Text(
'HOME PAGE'
,
style: optionStyle,
),
Text(
'COURSE PAGE'
,
style: optionStyle,
),
Text(
'CONTACT GFG'
,
style: optionStyle,
),
];
void
_onItemTapped(
int
index) {
setState(() {
_selectedIndex = index;
});
}
@override
Widget build(BuildContext context) {
return
Scaffold(
appBar: AppBar(
title:
const
Text(
'GeeksForGeeks'
),
backgroundColor: Colors.green,
),
body: Center(
child: _widgetOptions.elementAt(_selectedIndex),
),
bottomNavigationBar: BottomNavigationBar(
items:
const
<BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.home),
title: Text(
'Home'
),
),
BottomNavigationBarItem(
icon: Icon(Icons.bookmark),
title: Text(
'Courses'
),
),
BottomNavigationBarItem(
icon: Icon(Icons.contact_mail),
title: Text(
'Mail'
),
),
],
currentIndex: _selectedIndex,
selectedItemColor: Colors.amber[800],
onTap: _onItemTapped,
),
);
}
}