当前位置:网站首页>Getting started with the shutter AppBar
Getting started with the shutter AppBar
2022-06-23 05:07:00 【Susceptible to cold】
Achieve the effect diagram
Main code
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leading: new Icon(Icons.arrow_back_ios),
title: new Text(widget.title),
backgroundColor: Colors.blue,
centerTitle: true,
actions: <Widget>[
// Unhide menu
new IconButton(
icon: new Icon(Icons.add_alarm),
tooltip: 'Add Alarm',
onPressed: () {},
),
// The hidden menu
new PopupMenuButton<String>(
itemBuilder: (BuildContext context) => <PopupMenuItem<String>>[
this.getNewMenuItem(Icons.add_a_photo, ' menu 1', '1'),
this.getNewMenuItem(Icons.add_location, ' menu 2', '2'),
this.getNewMenuItem(Icons.audiotrack, ' menu 3', '3'),
],
onSelected: (String action) {
switch (action) {
case '1':
{
print(' menu 1');
}
break;
case '2':
{
print(' menu 2');
}
break;
case '3':
{
print(' menu 3');
}
break;
default:
}
},
)
],
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'Hi',
),
],
),
),
);
}
getNewMenuItem(IconData icon, String text, String id) {
return new PopupMenuItem<String>(
value: id,
child: new Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
new Icon(
icon,
color: Colors.blue,
),
new Text(text)
],
),
);
}
}Complete code
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter The title bar ',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter The title bar '),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leading: new Icon(Icons.arrow_back_ios),
title: new Text(widget.title),
backgroundColor: Colors.blue,
centerTitle: true,
actions: <Widget>[
// Unhide menu
new IconButton(
icon: new Icon(Icons.add_alarm),
tooltip: 'Add Alarm',
onPressed: () {},
),
// The hidden menu
new PopupMenuButton<String>(
itemBuilder: (BuildContext context) => <PopupMenuItem<String>>[
this.getNewMenuItem(Icons.add_a_photo, ' menu 1', '1'),
this.getNewMenuItem(Icons.add_location, ' menu 2', '2'),
this.getNewMenuItem(Icons.audiotrack, ' menu 3', '3'),
],
onSelected: (String action) {
switch (action) {
case '1':
{
print(' menu 1');
}
break;
case '2':
{
print(' menu 2');
}
break;
case '3':
{
print(' menu 3');
}
break;
default:
}
},
)
],
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'Hi',
),
],
),
),
);
}
getNewMenuItem(IconData icon, String text, String id) {
return new PopupMenuItem<String>(
value: id,
child: new Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
new Icon(
icon,
color: Colors.blue,
),
new Text(text)
],
),
);
}
}边栏推荐
- Non return to zero code NRZ
- How to use data to tell a wonderful story?
- 开发一年不到,来面试居然敢开口要20K,面完连8K都不想给~
- 元数据管理Apache Atlas编译(内嵌式)部署及遇到各种错误记录
- 功能测试人员如何做到花一个月的时间进阶自动化软件测试工程师
- 【OFDM通信】基于matlab OFDM多用户资源分配仿真【含Matlab源码 1902期】
- 微信小程序;AI智能配音助手
- Separate use of alertmanager alarms and use of Prometheus configuration alarm rules
- 使用PX4的ECL进行多传感器数据融合的后处理
- 七年码农路
猜你喜欢

Brief ideas and simple cases of JVM tuning - why do you need JVM tuning?

Receive incoming files and download (simple usage) a tag

Cve-2019-14287 (sudo right raising)

【Proteus仿真】Arduino UNO+PCF8574+LCD1602+MPX4250电子秤

功能测试人员如何做到花一个月的时间进阶自动化软件测试工程师

DO280OpenShift命令及故障排查--常见故障排除和章节实验

超越芯片和AI,硬科技资本为什么越来越“硬核”?

Separate use of alertmanager alarms and use of Prometheus configuration alarm rules

How to solve multi-channel customer communication problems in independent stations? This cross-border e-commerce plug-in must be known!

Notepad++ find replace group replace retain
随机推荐
Openwrt directory structure
centos7安装postgresql8.2.15及存储过程创建
Banner banner
Thinkphp6 linked table query without associated ID (2 tables) is mainly the application of select
Dsp7 environment
Abnova fluorescent dye 510-m streptavidin scheme
Const understanding II
ICer技能01正则匹配
入行软件测试5年,跳槽3次,我摸透了软件测试这一行
Abnova actn4 purified rabbit polyclonal antibody instructions
Icer Skill 02makefile script Running VCS Simulation
单行或多行文本溢出,省略号代替
MVVM has become history, and Google has fully turned to MVI
ApiPost接口测试的用法之------Get
MySQL存储过程
Unity中,如何在【编辑器】和【运行时】状态下读写一个ScriptableObject对象
Cloud native database is in full swing, and the future can be expected
Shadertoy basic teaching 01. Circle drawing (explanation of smoothstep() function)
Separate use of alertmanager alarms and use of Prometheus configuration alarm rules
如何更好地组织最小 WEB API 代码结构