Quantcast
Channel: CSDN博客移动开发推荐文章
Viewing all articles
Browse latest Browse all 5930

Flutter进阶—质感设计之弹出菜单

$
0
0

PopupMenuButton控件即弹出菜单控件,点击控件会出现菜单。

import 'package:flutter/material.dart';
class MenusDemo extends StatefulWidget {
  @override
  _MenusDemoState createState() => new _MenusDemoState();
}
class _MenusDemoState extends State<MenusDemo> {
  String _bodyStr = '显示菜单的点击';
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text('菜单演示'),
        actions: <Widget> [
          new PopupMenuButton<String>(
            onSelected: (String value) {
              setState(() {
                _bodyStr = value;
              });
            },
            itemBuilder: (BuildContext context) => <PopupMenuItem<String>>[
              new PopupMenuItem<String>(
                value: '选项一的值',
                child: new Text('选项一')
              ),
              new PopupMenuItem<String>(
                value: '选项二的值',
                child: new Text('选项二')
              )
            ]
          )
        ]
      ),
      body: new Center(
        child: new Text(_bodyStr)
      )
    );
  }
}
void main() {
  runApp(new MaterialApp(
    title: 'Flutter教程',
    home: new MenusDemo(),
  ));
}

这里写图片描述

这里写图片描述

这里写图片描述

作者:hekaiyou 发表于2016/12/27 18:37:49 原文链接
阅读:149 评论:0 查看评论

Viewing all articles
Browse latest Browse all 5930

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>