Closed sgehrman closed 4 years ago
I got the same problem
Are you using the dontShowTheSameItemSelected? (The default value is true, need to add selectedItem option to the Menu Button if it is true the dontShowTheSameItemSelected)
I am just using only the required values..
On Tue, 16 Jun 2020 at 18:49, Lucas Buchalla Sesti notifications@github.com wrote:
Are you using the dontShowTheSameItemSelected? (The default value is true, need to add selectedItem option to the Menu Button)
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/huextrat/menu_button/issues/11#issuecomment-644741314, or unsubscribe https://github.com/notifications/unsubscribe-auth/AESL7ZFWQZLF76JNJAPWDQDRW5S6LANCNFSM4N7PEK7Q .
Can you show your menu button code?
okay wait a second
@lucas-sesti I have used same code that has given in the How to use section of menu button in pub.dev just to check everything is okay or not.. but its now working.. with those error message
menu button code:
MenuButton( child: button,// Widget displayed as the button items: ['button1','button2'],// List of your items topDivider: true, popupHeight: 200, // This popupHeight is optional. The default height is the size of items scrollPhysics: AlwaysScrollableScrollPhysics(), // Change the physics of opened menu (example: you can remove or add scroll to menu) itemBuilder: (value) => Container( width: 83, height: 40, alignment: Alignment.centerLeft, padding: const EdgeInsets.symmetric(horizontal: 16), child: Text(value) ),// Widget displayed for each item toggledChild: Container( color: Colors.white, child: button,// Widget displayed as the button, ), divider: Container( height: 1, color: Colors.grey, ), onItemSelected: (value) { selectedItem = value; // Action when new item is selected }, decoration: BoxDecoration( border: Border.all(color: Colors.grey[300]), borderRadius: const BorderRadius.all(Radius.circular(3.0)), color: Colors.white ), onMenuButtonToggle: (isToggle) { print(isToggle); }, ),
button code:
final Widget button = SizedBox( width: 83, height: 40, child: Padding( padding: const EdgeInsets.only(left: 16, right: 11), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Flexible( child: Text( selectedItem, style: TextStyle(color: Colors.yellow), overflow: TextOverflow.ellipsis, ), ), SizedBox( width: 12, height: 17, child: FittedBox( fit: BoxFit.fill, child: Icon( Icons.arrow_drop_down, color: Colors.grey, ) ) ), ], ), ), );
and the error:
flutter: 'package:menu_button/menu_button.dart': Failed assertion: line 45 pos 16: flutter: '!dontShowTheSameItemSelected || selectedItem != null': is not true. flutter: flutter: Either the assertion indicates an error in the framework itself, or we should provide substantially flutter: more information in this error message to help you determine and fix the underlying cause. flutter: In either case, please report this assertion by filing a bug on GitHub: flutter: https://github.com/flutter/flutter/issues/new?template=BUG.md flutter:
Ok I can reproduce the issue thanks.
You'll have to pass selectedItem
property to avoid this kind of error.
And on my side there is a modification to do in the library but it will cause breaking change for current user. I'll try to find a better solution to not require selectedItem
value
@huextrat If change the dontShowTheSameItem to default false, its the solution i guess
@lucas-sesti Yes that what I'm thinking but all the user using dontShowTheSameItem currently will have to pass it to true after the next update :/
I'm gonna do a new release solving the problem (1.2.0
) in the afternoon. Thanks for contribution
Please upgrade to menu_button: 1.2.0
there is a fix for this issue.
I was running with "All Exceptions" mode in the VSCode debugger.
These exceptions fail, and you have the same one twice in a row.
In menu_button.dart
44: assert(!dontShowTheSameItemSelected || selectedItem != null), 45: assert(!dontShowTheSameItemSelected || selectedItem != null);