rafalbednarczuk / curved_navigation_bar

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

Badge content not updating #94

Closed Kshitiz-Rimal closed 2 years ago

Kshitiz-Rimal commented 3 years ago

It was working fine when using BottomNavigationBar but when I switched to this, the badge content is not updating in realtime.

Badge( badgeColor: CustomColor.themeSecondary, shape: BadgeShape.circle, borderRadius: BorderRadius.circular(100), child: Icon(Icons.shopping_cart, size: 25, color: widget.selectBottomNavigationIndex == 2 ? Colors.white : CustomColor.themeColor ), badgeContent: Text(cart.toString(), style: TextStyle(color: Colors.white))),

miguel2armas commented 3 years ago

for this problem i solved it using "flutter_bloc", use the example that is in "flutter_bloc" and you will see that it works to update even when the current menu is selected

cybex-dev commented 2 years ago

Can confirm this is an issue when using a MultiProvider from the Provider package

Problem: active button does not update with state changes but all other (non active) buttons do update. See #78 too for likely the same issue.

MCVE:

  return MultiProvider(
      providers: [
        StreamProvider<int>(
          create: (context) => Stream<int>.periodic(Duration(seconds: 1), (i) => i),
          initialData: 4,
          updateShouldNotify: (previous, current) {
            print("Count = $current");
            return true;
          },
        ),
      ],
      builder: (context, child) {
        return CurvedNavigationBar(
          height: 60,
          items: [
            Text("${context.watch<int>()}"),
            Text("${context.watch<int>()}"),
            Text("${context.watch<int>()}"), // this one will remain the same, all others will constantly update
            Text("${context.watch<int>()}"),
            Text("${context.watch<int>()}"),
          ],
          onTap: (value) {
            setState(() {
              activeIndex = value;
              widget.onTabChanged(value);
            });
          },
          index: 2,
        );
      },
    );
cybex-dev commented 2 years ago

See PR #118, hopefully @rafalbednarczuk will merge PR changes soon

cybex-dev commented 2 years ago

Best solution for now is to clone/add as submodule to your project, specify the path and make sure the version in Cache\hosted\pub.dartlang.org is removed (I found it sometimes doesn't use the updated "local" path)

rafalbednarczuk commented 2 years ago

fixed in 1.0.2, please update curved_navigation_bar in pubspec.yaml to 1.0.2