I’m trying to catch a PopScope event. I’ve tried but without success. Here is my code. I’ll simplify it a bit:
GoRoute(
path: '/group/:groupId',
builder: (context, state) {
final groupId = state.pathParameters['groupId']!;
final extras = state.extra as Map<String, dynamic>?;
logger.t('NR.goRoute: Grupo: $groupId. Extras recibidos: ${(extras == null) ? null : extras['fr']}');
return PopScope(
onPopInvokedWithResult: (didPop,_) async {
logger.w('This log is not printed');
if (!didPop & context.mounted) {
context.go('/groups'); // Navegar de vuelta a /groups
}
},
child: Group__Screen(
groupId: groupId,
groupName: extras?['groupName'] ?? '',
groupColor: extras?['groupColor'] ?? Colors.blue,
fr: extras?['fr'],
),
);
},
),
I’ve develop a button to get back, and it works fine. But for some reason, I can’t use the “back” method Android native, button or gesture.
I don’t know why it didn’t work. There is no more PopScope that can be truncate that PopScore. There is no Navigation.go() or whatelse. This is the develop of my button, that works fine.
@override
Widget build(BuildContext context) {
final bloc = context.read<Group__Bloc>();
return Scaffold(
appBar: AppBar(
title: Text(groupName),
backgroundColor: groupColor,
leading: IconButton(
icon: const Icon(Icons.arrow_back),
onPressed: () async => context.go('/groups'),
),
actions: [
IconButton(
icon: const Icon(Icons.share),
onPressed: () => _handleDeepLinkShare(context),
),
],
),
body: Column(
children:
That icon works fine. But back gesture doesn’t even print the log with Warning level.
I’m trying to use a phisical Android Pixel 7 to debug, in a Mac Air. I don’t know if it’s related with it, but I don’t know what I can do more.
Please, be gentle. I’m trying to develop an app to obtain some benefits with A LOT OF migraines. Right now I have one. 26 per month. My entire life is chaotic.
Any idea to avoid PopScope?
1