I use the showMenu
function to show menus with dialog.My code is
const width = 100.0; const height = 40.0; await showMenu( items: [ PopupMenuItem(padding: EdgeInsets.zero, child: Container(width: width, height: height, color: Colors.blue, child: const Text('test 1'))), PopupMenuItem(padding: EdgeInsets.zero, child: Container(width: width, height: height, color: Colors.blue, child: const Text('test 2'))), ], context: context, position: const RelativeRect.fromLTRB(0, 0, 0, 0), constraints: const BoxConstraints(maxWidth: width, maxHeight: height * 2), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5)), color: Colors.red, );
I tried to fit it by setting the maxWidth
and maxHeight
of the constraints
property in the showMenu
, the horizontal is working but the vertical still has space between menus.