2

I want to back programmatically without press back button , ("trigger back button functionality without pressing it ") ?

Omar Abdelazeem
  • 381
  • 2
  • 20

1 Answers1

1

I think you can use WillPopScope class for this case

bool shouldPop = true;
@override
Widget build(BuildContext context) {
  return WillPopScope (
    onWillPop: () async {
      return shouldPop;
    },
    child: const Text('WillPopScope sample'),
  );
}

Hope this helps. You can read more in the official documentation https://api.flutter.dev/flutter/widgets/WillPopScope-class.html

Aditya
  • 740
  • 1
  • 5
  • 11