Badge content not updating
Kshitiz-Rimal opened this issue · 5 comments
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))),
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
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,
);
},
);
See PR #118, hopefully @rafalbednarczuk will merge PR changes soon
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)
fixed in 1.0.2, please update curved_navigation_bar in pubspec.yaml to 1.0.2