benyaminbeyzaie / circular_bottom_navigation

Circular bottom navigation is a bottom navigation library for flutter with circular indicator and cool animations.
BSD 3-Clause "New" or "Revised" License
654 stars 97 forks source link

Get a error when count of tabbar from 1 to 2 #20

Closed huang12zheng closed 3 years ago

huang12zheng commented 4 years ago

tabs.length change from 1 to 2, it is getting a error with follow code.

CircularBottomNavigation(
              tabs.map2TabItem(),
              controller: _navigationController,
              barHeight: bottomNavBarHeight,
              selectedCallback: (int index) {
                controller.jumpToPage(index);
              },
            )
Align(
          alignment: Alignment.bottomCenter,
          child: (tabs?.length??0) == 0 ? Container() : 
          StatefulBuilder(
            key: ValueKey(tabs.length),
            builder: (BuildContext context, setState) => CircularBottomNavigation(
              tabs.map2TabItem(),
              controller: _navigationController,
              barHeight: bottomNavBarHeight,
              selectedCallback: (int index) {
                controller.jumpToPage(index);
              },
            )
          ),
        )

The following RangeError was thrown building CircularBottomNavigation(dirty, dependencies: [MediaQuery], state: _CircularBottomNavigationState#b3126(tickers: tracking 1 ticker)):
RangeError (index): Invalid value: Only valid value is 0: 1

The relevant error-causing widget was
    CircularBottomNavigation 
lib/…/tabview/tabview_scaffold.dart:55
When the exception was thrown, this was the stack
#0      List.[]  (dart:core-patch/growable_array.dart:149:60)
#1      _CircularBottomNavigationState.build.<anonymous closure> 
package:circular_bottom_navigation/circular_bottom_navigation.dart:196
#2      ListMapView.forEach  (dart:_internal/list.dart:244:8)
#3      _CircularBottomNavigationState.build 
package:circular_bottom_navigation/circular_bottom_navigation.dart:178
#4      StatefulElement.build 
package:flutter/…/widgets/framework.dart:4069
...
huang12zheng commented 4 years ago

it maybe need a Key or use didUpdateWidget

huang12zheng commented 3 years ago

close with no reply