如何打开PopupMenuButton?

如何打开PopupMenuButton?,第1张

如何打开PopupMenuButton?

这可行,但是不美观(并且显示问题与上述Rainer的解决方案相同:

class _MyHomePageState extends State<MyHomePage> {  final GlobalKey _menuKey = new GlobalKey();  @override  Widget build(BuildContext context) {    final button = new PopupMenuButton(        key: _menuKey,        itemBuilder: (_) => <PopupMenuItem<String>>[   new PopupMenuItem<String>(       child: const Text('Doge'), value: 'Doge'),   new PopupMenuItem<String>(       child: const Text('Lion'), value: '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框架中缺少的功能。



欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/4913438.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-12
下一篇 2022-11-12

发表评论

登录后才能评论

评论列表(0条)

保存