For a page, I only see two options to perform actions - "On Page Load" & "On Phone Shake". But I need to perform an action on press of Android back button or back gesture (swipe from the edges). I can write my own custom action, but the problem is I am not aware how to add that trigger (on back press) in FlutterFlow.
Has anyone done similar thing? Any pointers?

I got the same problem and found a work around.
(don't run the code, it's just for a better overlook)
class BackButtonOverrider extends StatefulWidget {
const BackButtonOverrider({
super.key,
this.width,
this.height,
required this.onBack,
});
final double? width;
final double? height;
final Future Function() onBack;
@override
State<BackButtonOverrider> createState() => _BackButtonOverriderState();
}
class _BackButtonOverriderState extends State<BackButtonOverrider> {
@override
Widget build(BuildContext context) {
return PopScope(
canPop: false,
onPopInvoked: (popAllowed) async {
widget.onBack.call();
},
child: Scaffold(
// Your scaffold content here
),
);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With