I want to back programmatically without press back button , ("trigger back button functionality without pressing it ") ?
1 Answer
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
Navigator.pop(context)?