auto_route_library
auto_route_library copied to clipboard
nested tab router bug
I have a problem with nested tabs. When I enter the program and want to exit the program, it seems that the home screen has been run twice. I uploaded the video of this problem
i used 2.4.2 version and flutter version 2.5.2
https://files.fm/u/dkdud8ajs
@masoudk2000 it seemed to me like you closed your App? what are you expecting to happen?
@Milad-Akarie Yes. I want to close my app. But if you notice, I exit twice to close the program. But after closing the program, you will see that another page is open.
@masoudk2000 you mean when you hit the back button it takes to homeTab before exiting?
@Milad-Akarie No. When I exit the app, another home page is open behind the app. It looks like the app has been run twice.
@masoudk2000 please share you TabsRouter or AutoTabsRouter setup.
@Milad-Akarie
@MaterialAutoRouter(
routes: <AutoRoute>[
CupertinoRoute(page: SplashPage, path: 'splash', initial: true),
CupertinoRoute(
page: DashboardPage,
path: 'dashboard',
children: [
AutoRoute(
page: EmptyRouterPage,
name: 'HomeTab',
path: 'home',
children: [
AutoRoute(
path: '',
page: HomePage,
),
CupertinoRoute(
page: CoursePage,
path: 'course',
name: 'CourseRoute',
),
CupertinoRoute(
page: PageModelPage,
path: 'page_model',
name: 'PageModelRoute',
),
CupertinoRoute(
page: WebViewPage,
path: 'webview_page',
name: 'WebviewRoute',
),
CupertinoRoute(
page: PaymentResultPage,
path: 'payment_result',
name: 'PaymentResultRoute',
),
CupertinoRoute(
page: QaDetailPage,
path: 'qa_detail',
name: 'QaDetailRoute',
),
CupertinoRoute(
page: PaymentDetailPage,
path: 'payment_detail',
name: 'PaymentDetailRoute',
),
CupertinoRoute(
page: MessageDetailPage,
path: 'message_detail',
name: 'MessageDetailRoute',
),
MaterialRoute(
page: EmptyPage,
path: 'empty',
name: 'EmptyRoute',
),
RedirectRoute(path: '*', redirectTo: ''),
],
),
AutoRoute(
page: EmptyRouterPage,
path: 'login',
name: 'LoginTab',
children: [
AutoRoute(
page: LoginPage,
path: '',
),
AutoRoute(
page: VerificationPage,
path: 'verification',
name: 'VerificationTab',
),
RedirectRoute(path: '*', redirectTo: ''),
]),
AutoRoute(
page: EmptyRouterPage,
path: 'messages',
name: 'MessageListTab',
children: [
AutoRoute(
page: MessageListPage,
path: '',
),
CupertinoRoute(
page: MessageDetailPage,
path: 'message_detail',
name: 'MessageDetailRoute',
),
CupertinoRoute(
page: QaDetailPage,
path: 'qa_detail',
name: 'QaDetailRoute',
),
CupertinoRoute(
page: PaymentDetailPage,
path: 'payment_detail',
name: 'PaymentDetailRoute',
),
CupertinoRoute(
page: CoursePage,
path: 'course',
name: 'CourseRoute',
),
CupertinoRoute(
page: PaymentResultPage,
path: 'payment_result',
name: 'PaymentResultRoute',
),
MaterialRoute(
page: EmptyPage,
path: 'empty',
name: 'EmptyRoute',
),
RedirectRoute(path: '*', redirectTo: ''),
],
),
AutoRoute(
page: EmptyRouterPage,
name: 'CourseListTab',
path: 'courses',
children: [
CupertinoRoute(
page: CourseListPage,
path: '',
),
CupertinoRoute(
page: CoursePage,
path: 'course',
name: 'CourseRoute',
),
CupertinoRoute(
page: PaymentResultPage,
path: 'payment_result',
name: 'PaymentResultRoute',
),
MaterialRoute(
page: EmptyPage,
path: 'empty',
name: 'EmptyRoute',
),
RedirectRoute(path: '*', redirectTo: ''),
],
),
AutoRoute(
page: EmptyRouterPage,
name: 'PostTab',
path: 'post_list',
children: [
CupertinoRoute(
page: PostPage,
path: '',
),
CupertinoRoute(
page: PostDetailPage,
path: 'post_detail',
name: 'PostDetailRoute',
),
MaterialRoute(
page: EmptyPage,
path: 'empty',
name: 'EmptyRoute',
),
RedirectRoute(path: '*', redirectTo: ''),
],
),
AutoRoute(
page: EmptyRouterPage,
name: 'ProfileTab',
path: 'profile',
children: [
CupertinoRoute(
page: ProfilePage,
path: '',
),
CupertinoRoute(
page: CoursePage,
path: 'course',
name: 'CourseRoute',
),
CupertinoRoute(
page: QaListPage,
path: 'qa_list',
name: 'QaListRoute',
),
CupertinoRoute(
page: CourseListPage,
name: 'CourseListRoute',
path: 'course_list',
),
CupertinoRoute(
page: PaymentListPage,
path: 'payment_list',
name: 'PaymentListRoute',
),
CupertinoRoute(
page: PaymentDetailPage,
path: 'payment_detail',
name: 'PaymentDetailRoute',
),
CupertinoRoute(
page: QaDetailPage,
path: 'qa_detail',
name: 'QaDetailRoute',
),
CupertinoRoute(
page: EditProfilePage,
path: 'edit_profile',
name: 'EditProfileRoute',
),
CupertinoRoute(
page: InvitationPage,
path: 'invitation',
name: 'InvitationRoute',
),
CupertinoRoute(
page: DownloadsPage,
path: 'download_list',
name: 'DownloadsRoute',
),
CupertinoRoute(
page: DownloadDetailsPage,
path: 'download_detail',
name: 'DownloadDetailsRoute',
),
CupertinoRoute(
page: PaymentResultPage,
path: 'payment_result',
name: 'PaymentResultRoute',
),
AdaptiveRoute(
page: EmptyPage,
path: 'empty',
name: 'EmptyRoute',
),
RedirectRoute(path: '*', redirectTo: ''),
],
),
],
),
CupertinoRoute(
page: ImagePage,
name: 'ImageRoute',
),
CupertinoRoute(
page: PdfViewerPage,
name: 'PdfViewerRoute',
),
CupertinoRoute(
page: DownloadDetailsPage,
name: 'RootDownloadDetailsRoute',
),
],
)
class $RootRouter {}
return MaterialApp.router(
routeInformationParser: router.defaultRouteParser(),
debugShowCheckedModeBanner: false,
title: 'common.app_name'.tr(),
theme: theme,
routerDelegate: router.delegate(),
/// Localization Part
locale: Locale(currentLocale.languageCode.split('_').first),
supportedLocales: locales,
localizationsDelegates: delegates,
);
AutoTabsScaffold(
lazyLoad: false,
routes: const [
HomeTab(),
CourseListTab(),
PostTab(),
ProfileTab()
],
builder: (context, child, animation) =>
BlocListener<DownloaderBloc, DownloaderState>(
listener: (context, state) => state.maybeWhen(
orElse: () => null,
downloadStarted: (_, __) =>
ViewHelper().displaySnackBar(
context: context,
message: 'download.download_started'.tr(),
actionLable: 'download.show_download'.tr(),
onTapAction: () => AutoRouter.of(context)
.root
.push(const RootDownloadDetailsRoute()),
),
),
child: Column(
children: [
Expanded(
child: Stack(
children: [
FadeTransition(
opacity: animation,
child: child,
),
_getNotificationWidget(),
],
),
),
MiniPlayerWidget(),
],
),
),
bottomNavigationBuilder: (_, tabRouter) {
NavigationBarManager().setRouter(tabRouter);
return GNav(
duration: _duration,
padding: const EdgeInsets.symmetric(horizontal: 1000),
gap: 8,
curve: Curves.easeOutExpo,
selectedIndex: NavigationBarManager().getCurrentIndex(),
mainAxisAlignment: MainAxisAlignment.spaceAround,
onTabChange: (int index) =>
NavigationBarManager().setCurrentIndex(index),
tabs: NavigationBarManager().getTabItems(),
);
})
@Milad-Akarie Were you able to find the problem? I really got into trouble
@masoudk2000 actually you setup looks fine, could you share your exit App logic?
This is probably the same bug and some provided samples
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions