rafalbednarczuk / curved_navigation_bar

Animated Curved Navigation Bar in Flutter
BSD 2-Clause "Simplified" License
683 stars 240 forks source link

How to dynamically add a tab #66

Closed deathleader closed 4 years ago

deathleader commented 4 years ago

Hi, i'm trying to add a tab dynamically but the result is that the tab show right all icon and when i click on them the bar show me the correct view but is like the index is wrong!

example: https://ibb.co/Wt6PVnf https://ibb.co/4pF8yTx ` class _BottomNavBarState extends State { int _page = 0;

GlobalKey _bottomNavigationKey = GlobalKey(); _checkUtente() async { var id = await storage.read(key: "id"); if (id == "7") { setState(() { listaTab.add( Icon(Icons.people, size: 30, color: Colors.white)); }); } }

List listaTab = [ Icon(Icons.exposure, size: 30, color: Colors.white), Icon(Icons.list, size: 30, color: Colors.white),

]; final pages = [Temperatura(), Lista(), Gruppo()]; @override void initState() { super.initState(); _checkUtente(); }

@override Widget build(BuildContext context) { return Scaffold( bottomNavigationBar: CurvedNavigationBar( key: _bottomNavigationKey, index: 0, height: 50.0, items: listaTab, color: Colors.blueAccent, buttonBackgroundColor: Colors.blueAccent, backgroundColor: Colors.white, animationCurve: Curves.easeInOut, animationDuration: Duration(milliseconds: 600), onTap: (index) { setState(() { _page = index; }); }, ), body: pages[_page], ); } } `

rafalbednarczuk commented 4 years ago

https://github.com/rafalbednarczuk/curved_navigation_bar/blob/master/example/example.dart Look at this example

deathleader commented 4 years ago

https://github.com/rafalbednarczuk/curved_navigation_bar/blob/master/example/example.dart Look at this example

In this way i can set a tab with a button press, but this isn't my problem... If u saw the example link, i'm able to add a tab and show the correct page! The problem is when i add a tab, when i click on the bar the "render" go crazy!

Can u show me how to add a tab dynamically? Thanks Luca.

rafalbednarczuk commented 4 years ago

It's not possible at the moment to add additional button navigation bar