Closed florianjs closed 5 years ago
I use the rflutter_alert 1.0.2 to show a dialog box when the user click on the back button:
bool myInterceptor(bool stopDefaultButtonEvent) { //TODO apk-release : back button don't work print("BACK BUTTON!"); // Do some stuff. Alert( context: context, title: "Do you want to close the app?", buttons: [ DialogButton( onPressed: () { Navigator.pop(context); exit(0); }, child: Text("Yes", style: TextStyle(fontWeight: FontWeight.bold, color: Colors.white),), ), DialogButton(onPressed: (){ Navigator.pop(context); }, child: Text('No', style: TextStyle(fontWeight: FontWeight.bold, color: Colors.white),),) ], ).show(); return false; }
Could you please include your flutter doctor?
@marcglasberg
Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel stable, v1.5.4-hotfix.2, on Microsoft Windows [version 10.0.18362.175], locale fr-FR)
[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3) [√] Android Studio (version 3.4) [√] VS Code (version 1.35.1) [!] Connected device ! No devices available
! Doctor found issues in 1 category.
@Icesofty You are not using this package as you should. You are not supposed to return false
, but true
instead, since you want the BackButtonInterceptor
to stop the default button event. The package rflutter_alert
is preventing the app from closing somehow. That's why your code worked (at least in debug), but it was not supposed to. I'd suggest you re-read the back_button_interceptor documentation carefully. Thank you.
Hi,
In debug mode, using VC Studio, the plugin is working as expected: the function is running when the back button is pressed. But when I build the app, the function is not running anymore. (Back Button is disabled, but it doesn't launch the function onPressed)
I tried to flutter clean and create a new build but I got the same issue. Some special permission is needed in the Manifest?