Skip to content

Instantly share code, notes, and snippets.

@vijayinyoutube
Created March 31, 2020 07:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vijayinyoutube/1f78633a3317c8c9d7369a054fd99a45 to your computer and use it in GitHub Desktop.
Save vijayinyoutube/1f78633a3317c8c9d7369a054fd99a45 to your computer and use it in GitHub Desktop.
bottom navigation bar in flutter
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