Commit 34148734 by 杜長金

11

parent c81a4d10
...@@ -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.
); );
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment