Flutter Widget之AppBar

Widget:https://flutter.io/docs/development/ui/widgets
AppBar:https://docs.flutter.io/flutter/material/AppBar-class.html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import 'package:flutter/material.dart';

class AppBarDemoPage extends StatefulWidget {
@override
State<StatefulWidget> createState() => new _AppBarDemoPageState();
}

class _AppBarDemoPageState extends State<AppBarDemoPage> with SingleTickerProviderStateMixin {
var _tabController;

@override
void initState() {
super.initState();
_tabController = new TabController(length: 6, vsync: this);
}

void _airDress() {
print('_airDress');
}

void _restitchDress() {
print('_restitchDress');
}

void _repairDress() {
print('_repairDress');
}

Widget build(BuildContext context) {
return Scaffold(
/*
appBar: AppBar(
title: Text('AppBlog.CN'),
actions: <Widget>[
IconButton(
icon: Icon(Icons.playlist_play),
tooltip: 'Air it',
onPressed: _airDress
),
IconButton(
icon: Icon(Icons.playlist_add),
tooltip: 'Restitch it',
onPressed: _restitchDress,
),
IconButton(
icon: Icon(Icons.playlist_add_check),
tooltip: 'Repair it',
onPressed: _repairDress,
),
],
),
*/
appBar: new AppBar(
title: new Text('AppBlog.CN'),
elevation: 0.7,
leading: new Icon(Icons.home),
backgroundColor: Colors.amber[500],
centerTitle: true,
actions: <Widget>[
new IconButton(
icon: new Icon(Icons.add_alarm),
tooltip: 'Add Alarm',
onPressed: () {
// do nothing
}),
new PopupMenuButton<String>(
itemBuilder: (BuildContext context) => <PopupMenuItem<String>>[
new PopupMenuItem<String>(
value: "price", child: new Text('Sort by price')),
new PopupMenuItem<String>(
value: "time", child: new Text('Sort by time')),
],
onSelected: (String action) {
switch (action) {
case "price":
// do nothing
break;
case "time":
// do nothing
break;
}
})
],
bottom: new TabBar(
isScrollable: true,
controller: _tabController,
// indicator: new UnderlineTabIndicator(),
tabs: <Widget>[
new Tab(text: "Tabs 1"),
new Tab(text: "Tabs 2"),
new Tab(text: "Tabs 3"),
new Tab(text: "Tabs 4"),
new Tab(text: "Tabs 5"),
new Tab(text: "Tabs 6"),
],
),
),
body: new TabBarView(controller: _tabController, children: <Widget>[
new Center(),
new Center(),
new Center(),
new Center(),
new Center(),
new Center(),
])
);
}
}

Flutter Widget AppBar

Powered by AppBlog.CN     浙ICP备14037229号

Copyright © 2012 - 2020 APP开发技术博客 All Rights Reserved.

访客数 : | 访问量 :