导航到 ResultsPage() 时出现黑屏错误
Black screen error on navigating to ResultsPage()
enter image description here
我目前正在研究这个 flutter 应用程序示例,如图所示 above.But 当我点击“计算”导航到下一个屏幕时,出现黑屏,如下所示
enter image description here
这是 GitHub 回购 link:https://github.com/batman007db/bmiCalculatorApp
需要帮助!
在导航中,经常会误输入页面的 url。
以下是我最喜欢的导航步骤:
1)将url作为到达页面的静态成本添加(以避免错误类型)
static const routeName = '/your-page';
2) 验证您在主页上的路线是否正确:
routes: {
YourPage.routeName: (ctx) => YourPage(),
},
3) 确保调用正确的函数:
Navigator.of(context).pushReplacementNamed(YourPage.routeName);
// use pushNamed if u want to be able to go back or pushReplacementNamed if u don't want to allow going back.
4) 检查您是否已在导航页面中导入 YourPage:
试试这个,错误在你的 FloatingActionButton
Widget build(BuildContext context) {
return FloatingActionButton(
heroTag: null, // here
child: Icon(icon , color: Colors.white,),
backgroundColor: Color(0xFF4C4F5E),
onPressed: onPress,
);
}
enter image description here
我目前正在研究这个 flutter 应用程序示例,如图所示 above.But 当我点击“计算”导航到下一个屏幕时,出现黑屏,如下所示
enter image description here
这是 GitHub 回购 link:https://github.com/batman007db/bmiCalculatorApp 需要帮助!
在导航中,经常会误输入页面的 url。
以下是我最喜欢的导航步骤:
1)将url作为到达页面的静态成本添加(以避免错误类型)
static const routeName = '/your-page';
2) 验证您在主页上的路线是否正确:
routes: {
YourPage.routeName: (ctx) => YourPage(),
},
3) 确保调用正确的函数:
Navigator.of(context).pushReplacementNamed(YourPage.routeName);
// use pushNamed if u want to be able to go back or pushReplacementNamed if u don't want to allow going back.
4) 检查您是否已在导航页面中导入 YourPage:
试试这个,错误在你的 FloatingActionButton
Widget build(BuildContext context) {
return FloatingActionButton(
heroTag: null, // here
child: Icon(icon , color: Colors.white,),
backgroundColor: Color(0xFF4C4F5E),
onPressed: onPress,
);
}