fix pushAndRemoveUntil demo

This commit is contained in:
toly
2024-01-11 14:55:19 +08:00
parent 72c3cc607d
commit 74f9c288ab

View File

@@ -23,7 +23,7 @@ class MyApp extends StatelessWidget {
titleTextStyle: TextStyle(color: Colors.black,fontSize: 18,fontWeight: FontWeight.bold) titleTextStyle: TextStyle(color: Colors.black,fontSize: 18,fontWeight: FontWeight.bold)
) )
), ),
home: const PageA(), home: const HomePage(),
onUnknownRoute: _onUnknownRoute, onUnknownRoute: _onUnknownRoute,
); );
} }
@@ -46,3 +46,28 @@ class MyApp extends StatelessWidget {
return null; 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');
}
}