final button = new PopupMenubutton( itemBuilder: (_) => <PopupMenuItem<String>>[ new PopupMenuItem<String>( child: const Text('Doge'),value: 'Doge'),new PopupMenuItem<String>( child: const Text('lion'),value: 'lion'),],onSelected: _doSomething);final tile = new ListTile(Title: new Text('Doge or lion?'),trailing: button);
我想通过点击图块来打开按钮的菜单.
解决方法 这可行,但不够优雅(并且与Rainer的解决方案具有相同的显示问题:class _MyHomePageState extends State<MyHomePage> { final GlobalKey _menuKey = new GlobalKey(); @overrIDe @R_404_5537@ build(BuildContext context) { final button = new PopupMenubutton( key: _menuKey,itemBuilder: (_) => <PopupMenuItem<String>>[ new PopupMenuItem<String>( child: const Text('Doge'),new PopupMenuItem<String>( child: const Text('lion'),onSelected: (_) {}); final tile = new ListTile(Title: new Text('Doge or lion?'),trailing: button,onTap: () { // This is a Hack because _PopupMenubuttonState is private. dynamic state = _menuKey.currentState; state.showbuttonMenu(); }); return new Scaffold( body: new Center( child: tile,),); }}
我怀疑你实际要求的是类似于https://github.com/flutter/flutter/issues/254或https://github.com/flutter/flutter/issues/8277跟踪的内容 – 将标签与控件相关联并使标签可点击的能力 – 并且是Flutter框架中缺少的功能.
总结以上是内存溢出为你收集整理的dart – 如何打开PopupMenuButton?全部内容,希望文章能够帮你解决dart – 如何打开PopupMenuButton?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)