Created
February 3, 2020 11:56
-
-
Save ryanlid/ca11f2e0cf43f9a006ffd57ebce7f2fc to your computer and use it in GitHub Desktop.
PopupMenuButton 弹出菜单组
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(MyApp()); | |
} | |
enum ConferenceItem { AddMember, LockConference, ModifyLayout, TurnoffAll } | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: "PopupMenuButton组件示例", | |
home: Scaffold( | |
appBar: AppBar( | |
title: Text("PopupMenuButton组件示例"), | |
), | |
body: Center( | |
child: FlatButton( | |
child: PopupMenuButton( | |
onSelected: (ConferenceItem result) {}, | |
itemBuilder: (BuildContext context) => | |
<PopupMenuEntry<ConferenceItem>>[ | |
const PopupMenuItem<ConferenceItem>( | |
value: ConferenceItem.AddMember, | |
child: Text('添加成员'), | |
), | |
const PopupMenuItem<ConferenceItem>( | |
value: ConferenceItem.LockConference, | |
child: Text('锁定布局'), | |
), | |
const PopupMenuItem<ConferenceItem>( | |
value: ConferenceItem.ModifyLayout, | |
child: Text('修改布局'), | |
), | |
const PopupMenuItem<ConferenceItem>( | |
value: ConferenceItem.TurnoffAll, | |
child: Text('挂断所有'), | |
), | |
], | |
), | |
), | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment