9
This commit is contained in:
27
lib/09/01/main.dart
Normal file
27
lib/09/01/main.dart
Normal file
@@ -0,0 +1,27 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'pages/page_a.dart';
|
||||
|
||||
void main() {
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: 'Flutter Demo',
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: ThemeData(
|
||||
appBarTheme: AppBarTheme(
|
||||
elevation: 0,
|
||||
iconTheme: IconThemeData(color: Colors.black),
|
||||
titleTextStyle: TextStyle(color: Colors.black,fontSize: 18,fontWeight: FontWeight.bold)
|
||||
)
|
||||
),
|
||||
home: const PageA(),
|
||||
);
|
||||
}
|
||||
}
|
||||
28
lib/09/01/pages/page_a.dart
Normal file
28
lib/09/01/pages/page_a.dart
Normal file
@@ -0,0 +1,28 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'page_b.dart';
|
||||
|
||||
class PageA extends StatelessWidget {
|
||||
const PageA({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
const Color bgColor = Color(0xffCCFFFF);
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: bgColor,
|
||||
appBar: AppBar(title: const Text('A'),
|
||||
backgroundColor: bgColor,
|
||||
),
|
||||
body: Center(
|
||||
child: ElevatedButton(
|
||||
onPressed: ()=>toPageB(context),
|
||||
child: const Text('Push B'),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void toPageB(BuildContext context){
|
||||
Navigator.of(context).push(MaterialPageRoute(builder: (_)=> const PageB()));
|
||||
}
|
||||
}
|
||||
29
lib/09/01/pages/page_b.dart
Normal file
29
lib/09/01/pages/page_b.dart
Normal file
@@ -0,0 +1,29 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'page_c.dart';
|
||||
|
||||
class PageB extends StatelessWidget {
|
||||
const PageB({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
const Color bgColor = Color(0xffCCE5FF);
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: bgColor,
|
||||
appBar: AppBar(title: const Text('B',),
|
||||
backgroundColor: bgColor,
|
||||
),
|
||||
body: Center(
|
||||
child: ElevatedButton(
|
||||
onPressed: ()=>toPageC(context),
|
||||
child: const Text('Push C'),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void toPageC(BuildContext context){
|
||||
Navigator.of(context).push(MaterialPageRoute(builder: (_)=> const PageC()));
|
||||
}
|
||||
}
|
||||
26
lib/09/01/pages/page_c.dart
Normal file
26
lib/09/01/pages/page_c.dart
Normal file
@@ -0,0 +1,26 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class PageC extends StatelessWidget {
|
||||
const PageC({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
const Color bgColor = Color(0xffFFE6CD);
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: bgColor,
|
||||
appBar: AppBar(
|
||||
title: const Text('C'),
|
||||
backgroundColor: bgColor,
|
||||
leading: BackButton(
|
||||
onPressed: (){
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
),
|
||||
body: const Center(
|
||||
child: Text('到达终点'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user