当前位置:网站首页>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)
],
),
);
}
}边栏推荐
- ICer技能02makefile脚本自跑vcs仿真
- Thinkphp6 linked table query without associated ID (2 tables) is mainly the application of select
- 微信小程序:星际旅行飞船乘坐票制作生成
- Usage of apipost interface test ------ get
- 接收传来得文件并下载(简单用法)a标签
- dolphinscheduler 2.0.5 spark 任务测试总结(源码优化)
- [OFDM communication] simulation of OFDM multi-user resource allocation based on MATLAB [including Matlab source code 1902]
- 实战| 记一次借Viper来多重内网渗透
- centos7安装postgresql8.2.15及存储过程创建
- Wechat applet example development: run
猜你喜欢

Unity中,如何在【编辑器】和【运行时】状态下读写一个ScriptableObject对象

Magnetoresistive saturation

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

美团好文:从预编译的角度理解Swift与Objective-C及混编机制

【图论】—— 二分图

dolphinscheduler海豚调度升级代码改造-UpgradeDolphinScheduler

Icer Skill 02makefile script Running VCS Simulation

TabControl style of WPF basic control

2022-06-22:golang选择题,以下golang代码输出什么?A:3;B:1;C:4;D:编译失败。 package main import ( “fmt“ ) func mai

The solution to prompt "this list creation could be rewritten as a list literal" when adding elements to the list using the append() method in pychart
随机推荐
QT elidedtext only works for Chinese conformity, but not for English
Brief ideas and simple cases of JVM tuning - why do you need JVM tuning?
Go learning record II (window)
Abnova fluorescent dye 510-m streptavidin scheme
Abnova acid phosphatase (wheat germ) instructions
Precautions for running high-frequency and high-speed signal lines near PCB board - basic principles for high-frequency and high-speed signal design
轮播图的实现
How to make social media the driving force of cross-border e-commerce? This independent station tool cannot be missed!
微信小程序:凑单满减计算神器
微信小程序;AI智能配音助手
怎样利用数据讲一个精彩故事?
云原生数据库如荼如火,未来可期
teqc进行GNSS数据质量分析时生成的s文件介绍
[graph theory] - bipartite graph
ApiPost接口测试的用法之------Get
2022-06-22:golang选择题,以下golang代码输出什么?A:3;B:1;C:4;D:编译失败。 package main import ( “fmt“ ) func mai
微信小程序:土味情话恋爱话术
微信小程序:全新趣味测试
Course design C for freshmen -- clothing management system
Flask基础:环境搭建+配置+URL与试图之间的映射+重定向+数据库连接