import
'package:flutter/material.dart'
;
void
main() {
runApp(MyApp());
}
class
MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class
_MyAppState extends State<MyApp> {
List<Widget> _spaces = <Widget>[
Text(
'Home Page'
,
style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold)),
Text(
'Search Page'
,
style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold)),
Text(
'Account Page'
,
style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold)),
];
int
_index = 0;
@override
Widget build(BuildContext context) {
return
MaterialApp(
debugShowCheckedModeBanner:
false
,
title:
'Geeks For Geeks'
,
theme: ThemeData(
primarySwatch: Colors.green,
),
darkTheme: ThemeData.dark(),
home: Scaffold(
appBar: AppBar(
leading: Icon(Icons.backspace),
title: Text(
"Geeks for Geeks"
),
centerTitle:
true
,
),
bottomNavigationBar: BottomNavigationBar(
currentIndex: _index,
onTap: (newIndex) {
setState(() {
_index = newIndex;
print(
'$_index'
);
});
},
items: [
BottomNavigationBarItem(
label:
"Home"
,
icon: Icon(Icons.home),
),
BottomNavigationBarItem(
label:
"Search"
,
icon: Icon(Icons.search),
),
BottomNavigationBarItem(
label:
"Account"
,
icon: Icon(Icons.person),
),
],
),
body: Center(child: _spaces.elementAt(_index)),
),
);
}
}