This commit is contained in:
toly
2023-09-22 09:15:11 +08:00
parent d456e3c523
commit e95c34018e
132 changed files with 8527 additions and 17 deletions

View File

@@ -1,27 +0,0 @@
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(),
);
}
}

View File

@@ -1,28 +0,0 @@
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).pushReplacement(MaterialPageRoute(builder: (_)=> const PageB()));
}
}

View File

@@ -1,29 +0,0 @@
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).pushReplacement(MaterialPageRoute(builder: (_)=> const PageC()));
}
}

View File

@@ -1,21 +0,0 @@
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,
),
body: const Center(
child: Text('到达终点'),
),
);
}
}

View File

@@ -1,48 +0,0 @@
import 'package:flutter/material.dart';
import 'pages/page_a.dart';
import 'pages/page_b.dart';
import 'pages/page_c.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(),
onUnknownRoute: _onUnknownRoute,
);
}
Route? _onUnknownRoute(RouteSettings settings) {
String? name = settings.name;
Widget? page ;
if(name=='/a'){
page = const PageA();
}
if(name=='/b'){
page = const PageB();
}
if(name=='/c'){
page = const PageC();
}
if(page!=null){
return MaterialPageRoute(builder: (_)=> page!,settings: settings);
}
return null;
}
}

View File

@@ -1,28 +0,0 @@
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).pushNamed('/a');
}
}

View File

@@ -1,29 +0,0 @@
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).pushNamed('/c');
}
}

View File

@@ -1,36 +0,0 @@
import 'package:flutter/material.dart';
import 'page_d.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,
),
body: Center(
child: ElevatedButton(
onPressed: ()=>toPageD(context),
child: const Text('Push D Remove Until A'),
),
),
);
}
void toPageD(BuildContext context){
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute<void>(builder: (BuildContext context) => const PageD()),
ModalRoute.withName('/a'),
);
}
}

View File

@@ -1,22 +0,0 @@
import 'package:flutter/material.dart';
import 'package:iroute/06/02/pages/page_a.dart';
class PageD extends StatelessWidget {
const PageD({super.key});
@override
Widget build(BuildContext context) {
const Color bgColor = Color(0xffFFCCFF);
return Scaffold(
backgroundColor: bgColor,
appBar: AppBar(
title: const Text('D'),
backgroundColor: bgColor,
),
body: Center(
child: const Text('到达终点'),
),
);
}
}