Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rafalbednarczuk/89a04aa303bff0644e617905afabe3eb to your computer and use it in GitHub Desktop.
Save rafalbednarczuk/89a04aa303bff0644e617905afabe3eb to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
import 'package:curved_navigation_bar/curved_navigation_bar.dart';
void main() => runApp(MaterialApp(home: BottomNavBar()));
class BottomNavBar extends StatefulWidget {
@override
_BottomNavBarState createState() => _BottomNavBarState();
}
class _BottomNavBarState extends State<BottomNavBar> {
Widget _body = Text("Body0");
@override
Widget build(BuildContext context) {
return Scaffold(
bottomNavigationBar: CurvedNavigationBar(
initialIndex: 0,
items: <Widget>[
Icon(Icons.add, size: 30),
Icon(Icons.list, size: 30),
Icon(Icons.compare_arrows, size: 30),
Icon(Icons.call_split, size: 30),
Icon(Icons.perm_identity, size: 30),
],
color: Colors.white,
buttonBackgroundColor: Colors.white,
backgroundColor: Colors.blueAccent,
animationCurve: Curves.easeInOut,
animationDuration: Duration(milliseconds: 600),
onTap: (index) {
_changeBody(index);
},
),
body: Container(
color: Colors.blueAccent,
child: Center(child: _body),
));
}
void _changeBody(int index) {
switch(index){
case 0:
setState(() {
_body = Text("Body0");
});
break;
case 1:
setState(() {
_body = Text("Body1");
});
break;
case 2:
setState(() {
_body = Text("Body2");
});
break;
case 3:
setState(() {
_body = Text("Body3");
});
break;
case 4:
setState(() {
_body = Text("Body4");
});
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment