每次调用 modalroute 从命名路由检索参数时,我都会得到 null。
\n\n这是代码片段:
\n\nNavigator.pushNamed(\n context, \n VerifyCode.routeName, \n arguments: {\'code\': randValue,},\n );\nRun Code Online (Sandbox Code Playgroud)\n\n这是我检索参数的地方:
\n\nWidget build(BuildContext context) \n{\n //Get the dialog provider to display information\n alertViewModel = Provider.of<AlertViewModel>(context);\n\n //Retrieve the route argument\n final routeArgs =\n ModalRoute.of(context).settings.arguments as Map<String, int>;\n\n final securityCode = routeArgs[\'code\']; <-- Error happens here\n\n print(\'Code =\' + securityCode.toString());\n return Container()\nRun Code Online (Sandbox Code Playgroud)\n\n}
\n\n我应该从地图中获取一个整数,但我收到了错误:
\n\n \xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90 Exception Caught By widgets library \xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\nThe following NoSuchMethodError was thrown building VerifyCode(dirty, dependencies: [InheritedProvider<AlertViewModel>, _ModalScopeStatus], state: …Run Code Online (Sandbox Code Playgroud)