我正在使用 MaterialApp 中的 onGenerateRoute 在我的 Flutter 应用中实现导航。
对于其中一个路由,在我按下 Appbar 中提供的返回按钮时,会出现以下错误:
E/flutter (22996): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] 未处理的异常: 失败的断言: 布尔表达式不能为空
您能帮助我理解这是什么问题吗?
我的路由设置:->
对于其中一个路由,在我按下 Appbar 中提供的返回按钮时,会出现以下错误:
E/flutter (22996): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] 未处理的异常: 失败的断言: 布尔表达式不能为空
您能帮助我理解这是什么问题吗?
我的路由设置:->
Route<dynamic> routes(RouteSettings settings) {
switch (settings.name) {
case '/':
return MaterialPageRoute<dynamic>(
builder: (BuildContext context) {
return HomePage();
},
);
break;
case '/contactlist':
return MaterialPageRoute<dynamic>(
builder: (BuildContext context) {
return FriendsList();
},
);
break;
case '/ChatroomFormAdd':
return MaterialPageRoute<dynamic>(
builder: (BuildContext context) {
return const ChatroomInfo(
mode: 'Add');
},
);
break;
case '/ChatroomFormEdit':
return MaterialPageRoute<dynamic>(
builder: (BuildContext context) {
return const ChatroomInfo(
mode: 'Edit');
},
);
break;
case '/ChatroomFormView':
return MaterialPageRoute<dynamic>(
builder: (BuildContext context) {
return const ChatroomInfo(
mode: 'View');
},
);
break;
case '/ChatroomFormApprove':
return MaterialPageRoute<dynamic>(
builder: (BuildContext context) {
return const ChatroomInfo(
mode: 'Approve');
},
);
break;
case '/errorscreen':
return MaterialPageRoute<dynamic>(
builder: (BuildContext context) {
return ErrorScreen();
},
);
break;
default:
return MaterialPageRoute<dynamic>(
builder: (BuildContext context) {
return ChatDetail(chatroomID: chatroomID);
},
);
break;
}
}
回退按钮对所有路由都有效,除了从以下路由返回时:
Navigator.of(context).pushNamed('/ChatroomFormView');