PopupMenu
sample.packages.flutter.lib.src.material.popup_menu.973.
This example shows a menu with four items, selecting between an enum's
values and setting a _selectedMenu
field based on the selection
import 'package:flutter/material.dart';
// This is the type used by the popup menu below.
enum Menu { itemOne, itemTwo, itemThree, itemFour }
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
static const String _title = 'Flutter Code Sample';
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: _title,
home: MyStatefulWidget(),
);
}
}
class MyStatefulWidget extends StatefulWidget {
const MyStatefulWidget({Key? key}) : super(key: key);
@override
State createState() => _MyStatefulWidgetState();
}
class _MyStatefulWidgetState extends State {
String _selectedMenu = '';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
actions: [
// This button presents popup menu items.
PopupMenuButton
SHARE: