No need for onGenerateRoute
. Simply use
var exampleArgument = 'example string';
Navigator.pushNamed(
context,
ImagesScreen.routeName,
arguments: {'exampleArgument': exampleArgument},
);
and extract the arguments as follows:
@override
Widget build(BuildContext context) {
final arguments = ModalRoute.of(context).settings.arguments as Map;
if (arguments != null) print(arguments['exampleArgument']);
return Scaffold(...);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…