Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
flutter-demo
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘博华
flutter-demo
Commits
34148734
Commit
34148734
authored
Apr 07, 2022
by
杜長金
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
11
parent
c81a4d10
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
59 deletions
+18
-59
lib/main.dart
+18
-59
No files found.
lib/main.dart
View file @
34148734
...
@@ -11,7 +11,6 @@ class MyApp extends StatelessWidget {
...
@@ -11,7 +11,6 @@ class MyApp extends StatelessWidget {
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
MaterialApp
(
return
MaterialApp
(
title:
'Flutter Demo'
,
theme:
ThemeData
(
theme:
ThemeData
(
// This is the theme of your application.
// This is the theme of your application.
//
//
...
@@ -22,9 +21,9 @@ class MyApp extends StatelessWidget {
...
@@ -22,9 +21,9 @@ class MyApp extends StatelessWidget {
// or simply save your changes to "hot reload" in a Flutter IDE).
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
// is not restarted.
primarySwatch:
Colors
.
blue
,
primarySwatch:
Colors
.
red
,
),
),
home:
const
MyHomePage
(
title:
'
Flutter Demo Home Page
'
),
home:
const
MyHomePage
(
title:
'
我的訂單
'
),
);
);
}
}
}
}
...
@@ -48,68 +47,28 @@ class MyHomePage extends StatefulWidget {
...
@@ -48,68 +47,28 @@ class MyHomePage extends StatefulWidget {
}
}
class
_MyHomePageState
extends
State
<
MyHomePage
>
{
class
_MyHomePageState
extends
State
<
MyHomePage
>
{
int
_counter
=
0
;
List
tabs
=
[
"全部"
,
"待付款"
,
"點評/投票"
];
void
_incrementCounter
()
{
setState
(()
{
// This call to setState tells the Flutter framework that something has
// changed in this State, which causes it to rerun the build method below
// so that the display can reflect the updated values. If we changed
// _counter without calling setState(), then the build method would not be
// called again, and so nothing would appear to happen.
_counter
++;
});
}
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
// This method is rerun every time setState is called, for instance as done
return
new
DefaultTabController
(
// by the _incrementCounter method above.
length:
tabs
.
length
,
//
child:
new
Scaffold
(
// The Flutter framework has been optimized to make rerunning build methods
// fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets.
return
Scaffold
(
appBar:
AppBar
(
appBar:
AppBar
(
// Here we take the value from the MyHomePage object that was created by
...
//省略无关代码
// the App.build method, and use it to set our appbar title.
bottom:
TabBar
(
//生成Tab菜单
title:
Text
(
widget
.
title
),
tabs:
tabs
.
map
((
e
)
=>
Tab
(
text:
e
)).
toList
()
),
),
),
body:
Center
(
...
//省略无关代码
// Center is a layout widget. It takes a single child and positions it
body:
new
TabBarView
(
// in the middle of the parent.
children:
tabs
.
map
((
e
)
{
//分别创建对应的Tab页面
child:
Column
(
return
Container
(
// Column is also a layout widget. It takes a list of children and
alignment:
Alignment
.
center
,
// arranges them vertically. By default, it sizes itself to fit its
child:
Text
(
e
,
textScaleFactor:
5
),
// children horizontally, and tries to be as tall as its parent.
);
//
}).
toList
(),
// Invoke "debug painting" (press "p" in the console, choose the
// "Toggle Debug Paint" action from the Flutter Inspector in Android
// Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
// to see the wireframe for each widget.
//
// Column has various properties to control how it sizes itself and
// how it positions its children. Here we use mainAxisAlignment to
// center the children vertically; the main axis here is the vertical
// axis because Columns are vertical (the cross axis would be
// horizontal).
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
const
Text
(
'You have pushed the button this many times:'
,
),
Text
(
'
$_counter
'
,
style:
Theme
.
of
(
context
).
textTheme
.
headline4
,
),
],
),
),
),
),
floatingActionButton:
FloatingActionButton
(
onPressed:
_incrementCounter
,
tooltip:
'Increment'
,
child:
const
Icon
(
Icons
.
add
),
),
// This trailing comma makes auto-formatting nicer for build methods.
);
);
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment