We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I am using you this function:
itemBuilder: (BuildContext context, MenuItem menuItem, bool isSelected) { return Container( color: isSelected ? Theme.of(context).accentColor.withOpacity(0.7) : Colors.transparent, padding: EdgeInsets.fromLTRB(24, 16, 24, 16), child: Text( menuItem.title, style: Theme.of(context).textTheme.subhead.copyWith( color: isSelected ? Colors.black87 : Colors.white70), ), ); }
But isSelected is always return true for the only first position even I am updating the "selectedMenuItemId".
Here is the whole code for the menu:
menuView: MenuView( menu: menu, headerView: headerView(context), animation: false, alignment: Alignment.topLeft, color: Theme.of(context).primaryColor, selectedItemId: selectedMenuItemId, onMenuItemSelected: (String itemId) { selectedMenuItemId = itemId; }, itemBuilder: (BuildContext context, MenuItem menuItem, bool isSelected) { return Container( color: isSelected ? Theme.of(context).accentColor.withOpacity(0.7) : Colors.transparent, padding: EdgeInsets.fromLTRB(24, 16, 24, 16), child: Text( menuItem.title, style: Theme.of(context).textTheme.subhead.copyWith( color: isSelected ? Colors.black87 : Colors.white70), ), ); }),
Please let me know how fix it.
The text was updated successfully, but these errors were encountered:
Try replace this,
onMenuItemSelected: (String itemId) { selectedMenuItemId = itemId; },
with this one,
onMenuItemSelected: (String itemId) { setState(()=>selectedMenuItemId = itemId); },
Sorry, something went wrong.
No branches or pull requests
I am using you this function:
itemBuilder:
(BuildContext context, MenuItem menuItem, bool isSelected) {
return Container(
color: isSelected
? Theme.of(context).accentColor.withOpacity(0.7)
: Colors.transparent,
padding: EdgeInsets.fromLTRB(24, 16, 24, 16),
child: Text(
menuItem.title,
style: Theme.of(context).textTheme.subhead.copyWith(
color: isSelected ? Colors.black87 : Colors.white70),
),
);
}
But isSelected is always return true for the only first position even I am updating the "selectedMenuItemId".
Here is the whole code for the menu:
menuView: MenuView(
menu: menu,
headerView: headerView(context),
animation: false,
alignment: Alignment.topLeft,
color: Theme.of(context).primaryColor,
selectedItemId: selectedMenuItemId,
onMenuItemSelected: (String itemId) {
selectedMenuItemId = itemId;
},
itemBuilder:
(BuildContext context, MenuItem menuItem, bool isSelected) {
return Container(
color: isSelected
? Theme.of(context).accentColor.withOpacity(0.7)
: Colors.transparent,
padding: EdgeInsets.fromLTRB(24, 16, 24, 16),
child: Text(
menuItem.title,
style: Theme.of(context).textTheme.subhead.copyWith(
color: isSelected ? Colors.black87 : Colors.white70),
),
);
}),
Please let me know how fix it.
The text was updated successfully, but these errors were encountered: