Created
March 31, 2020 07:10
-
-
Save vijayinyoutube/1f78633a3317c8c9d7369a054fd99a45 to your computer and use it in GitHub Desktop.
bottom navigation bar in flutter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:curved_navigation_bar/curved_navigation_bar.dart'; | |
import 'package:flutter/material.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
debugShowCheckedModeBanner: false, | |
home: MyPage(), | |
); | |
} | |
} | |
class MyPage extends StatefulWidget { | |
@override | |
_MyPageState createState() => _MyPageState(); | |
} | |
class _MyPageState extends State<MyPage> { | |
String page = ""; | |
GlobalKey _bottomNavigationKey = GlobalKey(); | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
bottomNavigationBar: CurvedNavigationBar( | |
key: _bottomNavigationKey, | |
items: <Widget>[ | |
Icon(Icons.category, size: 30), | |
Icon(Icons.business_center, size: 30), | |
Icon(Icons.person, size: 30), | |
], | |
onTap: (index) { | |
setState(() { | |
switch (index) { | |
case 0: | |
page = "Welcome to Category"; | |
break; | |
case 1: | |
page = "Welcome to Business"; | |
break; | |
case 2: | |
page = "Welcome to Profile"; | |
break; | |
default: | |
page = "Welcome"; | |
} | |
}); | |
}), | |
body: Container( | |
color: Colors.blueAccent, | |
child: Center( | |
child: Container( | |
child: Text(page), | |
), | |
)), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment