How to make the badge render data dynamically from a provider #155
cyberneticspk
started this conversation in
Show and tell
Replies: 1 comment
-
You can up the badge, just return the AppBar with new .badge({/xxx/}) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello Sir,
i would like to know how can i use the badge to dynamically get the data for badge from a provider. here is how i am currently getting the data without using a badge i would like to use the badge option.
ConvexAppBar( height: 60, top: -30, curveSize: 100, style: TabStyle.titled, backgroundColor: Colors.mainColor, color: Color(0xbdb5ebFF), activeColor: Color(0xFFFFFFFF), items: [ TabItem(icon: Icons.store, title: 'Home'), TabItem(icon: Icons.person, title: 'Profile'), TabItem(icon: Icons.add, title: 'Add'), TabItem(icon: Icons.favorite_border, title: 'Favourites'), TabItem( icon: Stack( children: <Widget>[ Container( child: Icon(Icons.message, color: Color(0xbdb5ebFF)), ), Positioned( child: ChangeNotifierProvider< UserUnreadMessageProvider>( create: (BuildContext context) { userUnreadMessageProvider = UserUnreadMessageProvider(repo: userUnreadMessageRepository); if (valueHolder.loginUserId != null && valueHolder.loginUserId != '') { userUnreadMessageHolder = UserUnreadMessageParameterHolder( userId: valueHolder.loginUserId, deviceToken: valueHolder.deviceToken); userUnreadMessageProvider .userUnreadMessageCount( userUnreadMessageHolder); } return userUnreadMessageProvider; }, child: Consumer<UserUnreadMessageProvider>( builder: (BuildContext context, UserUnreadMessageProvider userUnreadMessageProvider, Widget child) { if (userUnreadMessageProvider != null && userUnreadMessageProvider .userUnreadMessage != null && userUnreadMessageProvider .userUnreadMessage.data != null) { final int sellerCount = int.parse( userUnreadMessageProvider .userUnreadMessage .data .sellerUnreadCount); final int buyerCount = int.parse( userUnreadMessageProvider .userUnreadMessage .data .buyerUnreadCount); userUnreadMessageProvider.totalUnreadCount = sellerCount + buyerCount; if (userUnreadMessageProvider .totalUnreadCount == 0) { return Container(); } else { if (userUnreadMessageProvider .totalUnreadCount > 0) { Future<dynamic>.delayed(Duration.zero, () => showMessageDialog(context)); } return Container( width: Dimens.space50, height: Dimens.space50, margin: const EdgeInsets.only( left: Dimens.space8, bottom: Dimens.space8), decoration: BoxDecoration( shape: BoxShape.circle, color: Colors.red, ), child: Align( alignment: Alignment.center, child: Text( userUnreadMessageProvider .totalUnreadCount > 9 ? '9+' : userUnreadMessageProvider .totalUnreadCount .toString(), textAlign: TextAlign.left, style: Theme.of(context) .textTheme .bodyText2 .copyWith(color: Colors.white), maxLines: 1, ), ), ); } } else { return Container(); } })), ), ], ), title: 'Messages'), ], initialActiveIndex: 2, //optional, default as 0 onTap: (int index) { final dynamic _returnValue = getIndexFromBottonNavigationIndex(index); updateSelectedIndexWithAnimation( _returnValue[0], _returnValue[1]); }, ),
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions