getx
getx copied to clipboard
canPop in PopScope not working on iOS
Describe the bug When setting canPop to false in a page's PopScope, and navigating to that page with Get.to(popGesture: false, Page()), I am still able to swipe to go back on iOS. The back button navigation is blocked, but not the gesture.
I followed the advice in #3071, but it doesn't seem to work. Works if I use standard Flutter navigation (canPop: false).
**Reproduction code example:
import 'package:flutter/material.dart';
import 'package:get/get.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return GetMaterialApp(
popGesture: false,
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatelessWidget {
final String title;
const MyHomePage({super.key, required this.title});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
ElevatedButton(
onPressed: () => Get.to(popGesture: false, () => const Page2()),
child: const Text('Go to page 2'),
),
],
),
),
);
}
}
class Page2 extends StatelessWidget {
const Page2({super.key});
@override
Widget build(BuildContext context) {
return PopScope(
canPop: false,
child: Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: const Text('Page 2'),
),
body: const Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('Page 2'),
],
),
),
),
);
}
}
To Reproduce Steps to reproduce the behavior:
- Run above sample on iOS simulator.
- Click on 'Go to page 2'
- Swipe to go back
Expected behavior Back navigation with gesture should be disabled.
Flutter Version: Tested on master and 3.22.2
Getx Version: 4.6.6
Describe on which device you found the bug: iOS simulator
Minimal reproduce code See above.
Have you solved the problem? I have the same problem
You can try the old api,WillPopScope
Has anyone found a fix for this yet. Still not working on iOS
Has anyone found a fix for this yet. Still not working on iOS
It's not working on flutter 3.22 and GetX 4.6.6.
The workaround is either downgrade flutter, or using native router, Navigator.of(context) to handler this case. And with the native router, you have to handle the GetX lifecycle manually, with initializing and disposing controllers.
You can try the old api,WillPopScope
It's work. The Getx has the parameter popGesture in the GetPage class, but it does not work!
Any update of this issue?
You can try the old api,WillPopScope
Not working for me. flutter 3.22.2 and GetX 4.6.6. When i change from PopScope to WillPopScope, cannot pop even return true
I meet the same problem.
- Flutter 3.24.2
- GetX 4.6.6
It does works at Flutter 3.16.x
Btw, Google request all app update with 3.22.x or later for Google Play.
CupertinoPageRoute by default prioritizes handling the system back gesture (swipe-to-go-back), which may bypass the logic of WillPopScope or PopScope. (From ChatGPT), so transition of page can't be set to Transition.cupertino.
Same Issue. Anyone fix it?
Using the latest version 4.7.2, this problem is resolved
Can I get solution?
here is my code which in working in android but not in ios
From screenA Get.to(() => const ScreenB());
ScreenB willpopscope not working and also not trigerring any functions inside popscope.
Using the latest version 4.7.2, this problem is resolved
not working