WillpopScope is deprecared after v3.12.0-1.0.pre. you can find more details thought this link.
So, PopScope calss we can use directly instance of WillPopScope, so you can find more details by using this link.
and I faced some issues and I fix those are so I share my isses and answers as help for others,
1.How to prevent go to back when click defult back button on mobile devices,
return Scaffold(
body: PopScope(
canPop: true,
onPopInvoked: (didPop) {
Navigator.pop(context);
},
),
);
when I was making a game I want prevent goin to back when click the default back button, I fix it as above example.your's requirements are will be different but logic is same,
I thnink anyone can get help with this answer for solve your issues.
Scaffold(
body = PopScope(
///
/// [canPop] is used to determine whether the current page can be popped or not.
///
canPop: false,
///
///
/// Called after a route pop was handled.
/// It's not possible to prevent the pop from happening at the time that this method is called; the pop has already happened. Use [canPop] to disable pops in advance.
/// This will still be called even when the pop is canceled. A pop is canceled when the relevant [Route.popDisposition] returns false, such as when [canPop] is set to false on a [PopScope]. The didPop parameter indicates whether or not the back navigation actually happened successfully.
///
///
onPopInvoked: (didPop) {
if (didPop) {
Navigator.pop(context);
}
},
child: Container(),
),
)