我想知道如何更改 的原点popUpMenu,在底部应用栏正上方启动弹出窗口,无论项目数如何。与屏幕右端对齐。类似的东西(例如)
Positioned(right: 0, bottom: bottomAppBarHeight)
Run Code Online (Sandbox Code Playgroud)
这是popUpMenu我想要实现的设计布局的截图:
这是当前放置的屏幕截图popUpMenu(请忽略其他设计差异,因为它们无关紧要):
使用的代码如下:
onPressed: () {
final RelativeRect position =
buttonMenuPosition(context);
showMenu(context: context, position: position, items: [
PopupMenuItem<int>(
value: 0,
child: Text('Working a lot harder'),
),
PopupMenuItem<int>(
value: 1,
child: Text('Working a lot less'),
),
PopupMenuItem<int>(
value: 1,
child: Text('Working a lot smarter'),
),
]);
},
Run Code Online (Sandbox Code Playgroud)
该buttonMenuPosition函数的代码:
RelativeRect buttonMenuPosition(BuildContext context) {
final bool isEnglish =
LocalizedApp.of(context).delegate.currentLocale.languageCode == 'en';
final RenderBox bar = context.findRenderObject() as RenderBox;
final …Run Code Online (Sandbox Code Playgroud)