flutter PopupMenu

 https://github.com/fluttercandies/w_popup_menu

https://github.com/wanglu1209/WFlutterDemo

onTap: () async {
  final result = await showMenu(
    context: context,
    position: RelativeRect.fromLTRB(100.0, 200.0, 100.0, 100.0),
//    position: RelativeRect.fromLTRB(1000.0, 1000.0, 0.0, 10.0),
    items: >[
      new PopupMenuItem( value: 'value01', child: new Text('Item One')),
      new PopupMenuItem( value: 'value02', child: new Text('Item Two')),
      new PopupMenuItem( value: 'value03', child: new Text('Item Three')),
      new PopupMenuItem( value: 'value04', child: new Text('I am Item Four'))
    ] );
},
@override
Widget build(BuildContext context) {
  return new Scaffold(
      appBar: AppBar(
        title: Text('PopMenuDemo'),
        actions: [_NomalPopMenu()],
      ),
      body: Center(child: new Text(_bodyStr)));
}

Widget _NomalPopMenu() {
  return new PopupMenuButton(
      itemBuilder: (BuildContext context) => >[
            new PopupMenuItem(
                value: 'value01', child: new Text('Item One')),
            new PopupMenuItem(
                value: 'value02', child: new Text('Item Two')),
            new PopupMenuItem(
                value: 'value03', child: new Text('Item Three')),
            new PopupMenuItem(
                value: 'value04', child: new Text('I am Item Four'))
          ],
      onSelected: (String value) {
        setState(() { _bodyStr = value; });
      });
}

flutter PopupMenu_第1张图片

你可能感兴趣的:(flutter,dart)