路由生命周期状态
This commit is contained in:
72
lib/11/main.dart
Normal file
72
lib/11/main.dart
Normal file
@@ -0,0 +1,72 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:iroute/11/transition.dart';
|
||||
|
||||
import 'color_page.dart';
|
||||
|
||||
void main() {
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: 'Flutter Demo',
|
||||
localizationsDelegates: GlobalMaterialLocalizations.delegates,
|
||||
supportedLocales: const [
|
||||
Locale('zh', 'CN'),
|
||||
],
|
||||
locale: const Locale('zh', 'CN'),
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: ThemeData(
|
||||
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
|
||||
useMaterial3: true,
|
||||
),
|
||||
home: const HomePage(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class HomePage extends StatefulWidget {
|
||||
const HomePage({super.key});
|
||||
|
||||
@override
|
||||
State<HomePage> createState() => _HomePageState();
|
||||
}
|
||||
|
||||
class _HomePageState extends State<HomePage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Cose 酷色"),
|
||||
),
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: _toColorHome,
|
||||
child: Text('打开颜色界面'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _toColorHome() {
|
||||
Route route = PageRouteBuilder<void>(
|
||||
barrierColor: Colors.white,
|
||||
pageBuilder: (_, __, ___) => const ColorPage(),
|
||||
transitionsBuilder: kSlideBottomToTopWithSecondary,
|
||||
);
|
||||
Navigator.push(context, route);
|
||||
// Navigator.pushReplacement(context, route);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user