Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BottomNavigationBar breaks when increasing number of items it contains #14466

Closed
DaveShuckerow opened this issue Feb 5, 2018 · 8 comments · Fixed by #19179
Closed

BottomNavigationBar breaks when increasing number of items it contains #14466

DaveShuckerow opened this issue Feb 5, 2018 · 8 comments · Fixed by #19179
Labels
c: crash Stack traces logged to the console f: material design flutter/packages/flutter/material repository.

Comments

@DaveShuckerow
Copy link
Contributor

DaveShuckerow commented Feb 5, 2018

I believe that the cause is that the bar's state allocates animation controllers for each item when the state is first constructed, but it doesn't create new controllers when the state updates with more items.

Steps to Reproduce

Create a nav bar with 3 items.

Increase the number of items to 4.

RangeError(index): invalid value: not in range 0..2, inclusive: 3.
## Logs
I/flutter (27323): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (27323): The following RangeError was thrown building BottomNavigationBar(dirty, state:
I/flutter (27323): _BottomNavigationBarState#68e58(tickers: tracking 3 tickers)):
I/flutter (27323): RangeError (index): Invalid value: Not in range 0..2, inclusive: 3
I/flutter (27323): 
I/flutter (27323): When the exception was thrown, this was the stack:
I/flutter (27323): #0      List.[] (dart:core-patch/dart:core/growable_array.dart:141)
I/flutter (27323): #1      _BottomNavigationBarState._createTiles (package:flutter/src/material/bottom_navigation_bar.dart:411:26)
I/flutter (27323): #2      _BottomNavigationBarState.build (package:flutter/src/material/bottom_navigation_bar.dart:477:45)
I/flutter (27323): #3      StatefulElement.build (package:flutter/src/widgets/framework.dart:3690:27)
I/flutter (27323): #4      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3602:15)
I/flutter (27323): #5      Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter (27323): #6      StatefulElement.update (package:flutter/src/widgets/framework.dart:3737:5)
I/flutter (27323): #7      Element.updateChild (package:flutter/src/widgets/framework.dart:2667:15)
I/flutter (27323): #8      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter (27323): #9      Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter (27323): #10     ProxyElement.update (package:flutter/src/widgets/framework.dart:3847:5)
I/flutter (27323): #11     Element.updateChild (package:flutter/src/widgets/framework.dart:2667:15)
I/flutter (27323): #12     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter (27323): #13     Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter (27323): #14     ProxyElement.update (package:flutter/src/widgets/framework.dart:3847:5)
I/flutter (27323): #15     Element.updateChild (package:flutter/src/widgets/framework.dart:2667:15)
I/flutter (27323): #16     RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:4317:32)
I/flutter (27323): #17     MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4703:17)
I/flutter (27323): #18     Element.updateChild (package:flutter/src/widgets/framework.dart:2667:15)
I/flutter (27323): #19     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter (27323): #20     Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter (27323): #21     ProxyElement.update (package:flutter/src/widgets/framework.dart:3847:5)
I/flutter (27323): #22     Element.updateChild (package:flutter/src/widgets/framework.dart:2667:15)
I/flutter (27323): #23     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter (27323): #24     Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter (27323): #25     StatefulElement.update (package:flutter/src/widgets/framework.dart:3737:5)
I/flutter (27323): #26     Element.updateChild (package:flutter/src/widgets/framework.dart:2667:15)
I/flutter (27323): #27     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4595:14)
I/flutter (27323): #28     Element.updateChild (package:flutter/src/widgets/framework.dart:2667:15)
I/flutter (27323): #29     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter (27323): #30     Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter (27323): #31     StatelessElement.update (package:flutter/src/widgets/framework.dart:3662:5)
I/flutter (27323): #32     Element.updateChild (package:flutter/src/widgets/framework.dart:2667:15)
I/flutter (27323): #33     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4595:14)
I/flutter (27323): #34     Element.updateChild (package:flutter/src/widgets/framework.dart:2667:15)
I/flutter (27323): #35     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter (27323): #36     Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter (27323): #37     StatefulElement.update (package:flutter/src/widgets/framework.dart:3737:5)
I/flutter (27323): #38     Element.updateChild (package:flutter/src/widgets/framework.dart:2667:15)
I/flutter (27323): #39     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter (27323): #40     Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter (27323): #41     StatefulElement.update (package:flutter/src/widgets/framework.dart:3737:5)
I/flutter (27323): #42     Element.updateChild (package:flutter/src/widgets/framework.dart:2667:15)
I/flutter (27323): #43     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter (27323): #44     Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter (27323): #45     ProxyElement.update (package:flutter/src/widgets/framework.dart:3847:5)
I/flutter (27323): #46     Element.updateChild (package:flutter/src/widgets/framework.dart:2667:15)
I/flutter (27323): #47     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter (27323): #48     Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter (27323): #49     ProxyElement.update (package:flutter/src/widgets/framework.dart:3847:5)
I/flutter (27323): #50     Element.updateChild (package:flutter/src/widgets/framework.dart:2667:15)
I/flutter (27323): #51     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter (27323): #52     Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter (27323): #53     StatefulElement.update (package:flutter/src/widgets/framework.dart:3737:5)
I/flutter (27323): #54     Element.updateChild (package:flutter/src/widgets/framework.dart:2667:15)
I/flutter (27323): #55     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter (27323): #56     Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter (27323): #57     BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2210:33)
I/flutter (27323): #58     BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:621:20)
I/flutter (27323): #59     BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:208:5)
I/flutter (27323): #60     BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
I/flutter (27323): #61     BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:930:9)
I/flutter (27323): #62     BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:842:5)
I/flutter (27323): #63     _invoke (file:///b/build/slave/Linux_Engine/build/src/flutter/lib/ui/hooks.dart:120)
I/flutter (27323): #64     _drawFrame (file:///b/build/slave/Linux_Engine/build/src/flutter/lib/ui/hooks.dart:109)
I/flutter (27323): ════════════════════════════════════════════════════════════════════════════════════════════════════

Doctor

Version of Flutter is the current g3 version.

@tfzxyinhao
Copy link

try to call setState trigger rebuild

@tegkev
Copy link

tegkev commented Apr 6, 2018

i have the same issue

@DaveShuckerow DaveShuckerow added c: crash Stack traces logged to the console f: material design flutter/packages/flutter/material repository. and removed c: crash Stack traces logged to the console labels Apr 6, 2018
@hmkrivoj
Copy link

I get the same error when creating a BottomNavigationBar with 'items' being a list of four BottomNavigationBarItems.

@AlexandreRoba
Copy link

AlexandreRoba commented May 10, 2018

I have the same error with three items. Did a full restart and then it worked.

@ghost
Copy link

ghost commented May 18, 2018

Same error with four items in hot reload. A full restart solved.

@DaveShuckerow DaveShuckerow added the c: crash Stack traces logged to the console label May 18, 2018
@HansMuller
Copy link
Contributor

Duplicate of #10322

@HansMuller HansMuller marked this as a duplicate of #10322 May 25, 2018
@DFreds
Copy link

DFreds commented Jun 19, 2018

I am also getting this issue.

This happens after I try to increase the number of items in my bottom navigation bar that starts with 4 items. This error does not occur if I decrease the number of items. Note that I am trying to set the number of items in the bottom navigation bar dynamically as the user moves about the app.

It seems there might be some sort of work around with initializing the bottom navigation bar with more items than you'll ever need (like 10), but I'm not sure how to do that without the user seeing it.

@github-actions
Copy link

github-actions bot commented Sep 2, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
c: crash Stack traces logged to the console f: material design flutter/packages/flutter/material repository.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants