我想传递我在这个导航器中内置的屏幕onTap
onTap: () => Navigator.push(context,
MaterialPageRoute(builstrong textder: (context) => QuestionPaperScreen()))
有一个QuestionPaperScreen(),我想在这里传递一个屏幕,它作为函数调用上的变量接收我该怎么做呢?
在QuestionPaperScreen中,您可以定义一个变量并根据需要标记它,并从这个屏幕传递它
class QuestionPaperScreen extends StatelessWidget {
final String routeName;
const QuestionPaperScreen({Key? key, required this.routeName}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container();
}
}
然后点击
onTap: (){
Navigator.push(context, MaterialPageRoute(builder: (_)=>QuestionPaperScreen(routeName:'/routeNameHere')));//pass the route name that you received from a function here
},