diff --git a/lib/08/02/main.dart b/lib/08/02/main.dart index 346b963..0e745f2 100644 --- a/lib/08/02/main.dart +++ b/lib/08/02/main.dart @@ -23,7 +23,7 @@ class MyApp extends StatelessWidget { titleTextStyle: TextStyle(color: Colors.black,fontSize: 18,fontWeight: FontWeight.bold) ) ), - home: const PageA(), + home: const HomePage(), onUnknownRoute: _onUnknownRoute, ); } @@ -46,3 +46,28 @@ class MyApp extends StatelessWidget { return null; } } + +class HomePage extends StatelessWidget { + const HomePage({super.key}); + @override + Widget build(BuildContext context) { + const Color bgColor = Color(0xffCCFFFF); + + return Scaffold( + backgroundColor: bgColor, + appBar: AppBar(title: const Text('主页'), + backgroundColor: bgColor, + ), + body: Center( + child: ElevatedButton( + onPressed: ()=>toPageB(context), + child: const Text('Push A'), + ), + ), + ); + } + + void toPageB(BuildContext context){ + Navigator.of(context).pushNamed('/a'); + } +}