我试图从它的子路由器得到TabsRouter,但它返回null(所以我猜它找不到任何相关的路由器)。尝试了一些东西,阅读了几次文档。它要么不工作,因为它应该或我不明白。
- 项目是唯一的Android和IOS,其他平台不支持.
- 使用的 Package :auto_route
AutoRoute(
path: NavRoutes.authPage,
page: AuthPage,
children: [
AutoRoute(
path: NavRoutes.loginPage,
page: LoginPage,
),
AutoRoute(
path: NavRoutes.signupPage,
page: SignUpPage,
),
],
)
class AuthView extends StatelessWidget {
const AuthView({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
final cubit = BlocProvider.of<AuthCubit>(context);
return Scaffold(
body: SafeArea(
child: AutoTabsRouter(
routes: [
const LoginPageRoute(),
SignUpPageRoute(
key: UniqueKey(),
onGooglePressed: cubit.signInGoogle,
),
],
builder: (context, child, animation) {
return FadeTransition(
opacity: animation,
child: child,
);
},
),
),
);
}
}
// Here I create `AutoTabsRouter` inside AuthView, and try to get it inside any of its child like:
context.innerRouterOf<TabsRouter>(AuthPageRoute.name)?.setActiveIndex(1);
context.innerRouterOf<TabsRouter>(LoginPageRoute.name)?.setActiveIndex(1);
AutoTabsRouter.of(context).setActiveIndex(1);
//tried a few more using innerNavKeys but it also failed.
1条答案
按热度按时间4dc9hkyq1#
你试着导航到目标选项卡了吗?