I aim to make my application work on background if i clicked on the back button of the phone and not the application . So i use the widget WillPopScope to detect if the user pressed the back button or not . i mean i want that the back button has the same functionality as the button with circle.
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: () async {
///your code here...
return false;
},
child:Scaffold(),
);
}
CodePudding user response:
Use move_to_background plugin like this
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: () async {
MoveToBackground.moveTaskToBack();
return false;
},
child:Scaffold(),
);
}
CodePudding user response:
If you want only android
application then you can use
flutter_background plugin.
For more advanced application
you can see this awesome doc.