Open SametSahin10 opened 1 year ago
+
Users who are having this issue, what's the value of android:launchMode
in your AndroidManifext.xml
? If it's singleTask
, try changing it to singleTop
and check if the issue gets resolved.
Are you having the issue? @AlexandrMolecule Can you try my suggestion above?
Hey @SametSahin10 is this documented somewhere or did you just tried it your self?
My coworker made some changes in AndroidManifest.xml
and the issue got resolved. I'm trying to isolate the change that fixed the issue.
Have the same problem, but launchMode is singleTop
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
I have the same issue: pressing the hardware back button closes the application, and I can't intercept this behavior (Android 13.1; android:launchMode="singleTop" in AndroidManifest.xml; auto_route v6.4.0). I tried working with RootBackButtonDispatcher
and AutoRouterDelegate
, but debug breakpoints didn't even stop in them. Maybe I did it in the wrong place?
I tried to intercept the event here:
Widget build(BuildContext context) {
final router = ref.watch(routerProvider).rootRouter;
MaterialApp.router(
debugShowCheckedModeBanner: false,
routerConfig: router.config(),
// routerConfig: RouterConfig(
// routeInformationProvider: router.routeInfoProvider(),
// routeInformationParser: router.defaultRouteParser(),
// routerDelegate: router.delegate(),
// ),
);
}
Here is how my app_router.dart
looks. MainRoute
is a TabsRouter
.
@AutoRouterConfig(replaceInRouteName: 'View|RouterView,Route')
class AppRouter extends _$AppRouter {
@override
final List<AutoRoute> routes = [
AutoRoute(
path: '/first-page',
page: FirstRoute.page,
initial: !EnvConfig.mainRouteInPriority,
guards: [LogoutGuard()],
),
AutoRoute(
path: '/local-auth',
page: LocalAuthRoute.page,
guards: [AuthGuard()],
initial: EnvConfig.mainRouteInPriority,
),
AutoRoute(
path: '/main',
page: MainRoute.page,
guards: [AuthGuard(), PushNotificationsGuard()],
children: [
RedirectRoute(
path: '',
redirectTo: 'home',
),
AutoRoute(
path: 'home',
page: HomeRouter.page,
children: [
AutoRoute(path: '', page: HomeRoute.page),
],
),
AutoRoute(
path: 'support',
page: SupportRouter.page,
children: [
AutoRoute(
path: '',
page: SupportRoute.page,
),
AutoRoute(
path: 'ticket-creating-first-step',
page: TicketCreatingFirstStepRoute.page,
),
AutoRoute(
path: 'ticket-creating-second-step',
page: TicketCreatingSecondStepRoute.page,
),
AutoRoute(
path: 'chat',
page: SupportChatRoute.page,
),
],
),
],
),
];
}
Main page with tabs:
Widget build(BuildContext context, ref) {
return AutoTabsScaffold(
routes: TabData.values.map((e) => e.route).toList(),
bottomNavigationBuilder: (_, tabsRouter) {
return BottomAppBar(...);
},
);
}
RouterView for the support tab:
@RoutePage(name: 'SupportRouter')
class SupportRouterView extends ConsumerWidget {
const SupportRouterView({super.key});
@override
Widget build(BuildContext context, ref) {
final routerKeys = ref.watch(routerProvider).tabRouterKeys;
return AutoRouter(
key: routerKeys[TabData.support],
);
}
}
Facing the same issue on Android 13. Could it be related to this? https://developer.android.com/about/versions/12/behavior-changes-all#back-press
It looks like cause of issue is the https://developer.android.com/guide/navigation/custom-back/predictive-back-gesture, you can find related discussion here https://github.com/flutter/flutter/issues/109513.
As a temporary solution, I've removed
android:enableOnBackInvokedCallback="true"
from manifest
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
Same problem on Android 14, reported in detail on #1788
EDIT: the problem is gone using @Kuzmenko solution
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
I have the same issue, but in my case the issue goes away when extending FlutterActivity
instead of FlutterFragmentActivity
.
Does this have anything to do with this issue?
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
The system back button closes the app on Android when it's supposed go back to the previous page. The issue does not occur on Android 10. It occurs on Android 13. I have run my app on an Android 10 device and pressed the system back button. The
didPopRoute
on RootBackButtonDispatcher has been called. I've run the app on my Android 13 device and pressed the system back button but thedidPopRoute
hasn't been called. What could be the issue here?I'm using:
flutter doctor -v