zoukankan      html  css  js  c++  java
  • flutter PopupMenuButton弹出式菜单列表

    import 'package:flutter/material.dart';
    
    class PopupMenuButtonDemo extends StatefulWidget {
      @override
      _PopupMenuButtonDemoState createState() => _PopupMenuButtonDemoState();
    }
    
    class _PopupMenuButtonDemoState extends State<PopupMenuButtonDemo> {
      String _currentMenuItem = 'Home';
      
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(
            title: Text('PopupMenuButtonDemo'),
            elevation: 0.0,
          ),
          body: Container(
            padding: EdgeInsets.all(16.0),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    Text(_currentMenuItem),
                    PopupMenuButton(
                      onSelected: (value) {
                        print(value);
                        setState(() {
                          _currentMenuItem = value;
                        });
                      },
                      itemBuilder: (BuildContext context) => [
                        PopupMenuItem(
                          value: 'Home',
                          child: Text('Home'),
                        ),
                        PopupMenuItem(
                          value: 'Discover',
                          child: Text('Discover'),
                        ),
                        PopupMenuItem(
                          value: 'Community',
                          child: Text('Community'),
                        ),
                      ],
                    ),
                  ],
                ),
              ],
            ),
          )
        );
      }
    }

    文档:https://api.flutter.dev/flutter/material/PopupMenuButton-class.html

    效果;

  • 相关阅读:
    Day1-CSS-下拉菜单
    scau 1138 代码等式
    SCAU-1076 K尾相等数
    勾股数专题-SCAU-1079 三角形-18203 神奇的勾股数(原创)
    SCAU-1144 数星星-HDU-1166-树状数组的应用
    NodeJs Fs模块
    Node核心模块
    flutter环境配置
    纯CSS制作图形效果
    CSS3选择器
  • 原文地址:https://www.cnblogs.com/loaderman/p/11345081.html
Copyright © 2011-2022 走看看