我有三个屏幕。 A,B和C。我使用以下代码推送A,B和C。 A是应用程序的第一个屏幕。
class FadeInSlideOutRoute<T> extends MaterialPageRoute<T> {
FadeInSlideOutRoute({WidgetBuilder builder, RouteSettings settings})
: super(builder: builder, settings: settings);
@override
Widget buildTransitions(BuildContext context,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child) {
if (settings.isInitialRoute)
return child;
// Fades between routes. (If you don't want any animation,
// just return child.)
return new FadeTransition(opacity: animation, child: child);
}
}
在构建方法中进行屏幕声明。
@override
Widget build(BuildContext context) {
return new MaterialApp(
debugShowCheckedModeBanner: false,
theme: new ThemeData(
primarySwatch: Colors.blue,
),
onGenerateRoute: (RouteSettings settings) {
switch (settings.name) {
case '/B':
return new FadeInSlideOutRoute(
builder: (_) => new LoginScreen(),
settings: settings,
);
case '/C':
return new FadeInSlideOutRoute(
builder: (_) => new ForgotPasswordScreen(),
settings: settings,
);
}
assert(false);
},
home: _LandingScreen(),
);
}
现在,我正在调用以下方法来推送新屏幕。
Navigator.pushNamed(context, '/B');
之后
Navigator.pushNamed(context, '/C');
问题是
当我从屏幕 C 按下Android设备时,直接进入屏幕 A 。但是应该在屏幕上 B 。请帮助大家。