admin管理员组

文章数量:1289845

I am using Popscope on my local authview- a screen where user enters a pin to enter the app. When user hit backbutton it is clearing the entered pin but does not close the app. It is the first screen when user opens the app. When I set canPop parameter to true it will close app without clearing entered pin. I want to clear the entered pin if user entered something and close the app when hit back button

I am using Popscope on my local authview- a screen where user enters a pin to enter the app. When user hit backbutton it is clearing the entered pin but does not close the app. It is the first screen when user opens the app. When I set canPop parameter to true it will close app without clearing entered pin. I want to clear the entered pin if user entered something and close the app when hit back button

Share Improve this question edited Feb 20 at 10:13 Vinaya Augusthy asked Feb 20 at 4:59 Vinaya AugusthyVinaya Augusthy 915 bronze badges 2
  • avoid adding screenshot of code meta.stackoverflow/questions/303812/… – Munsif Ali Commented Feb 20 at 5:24
  • Got it .Thanks for your suggestion. – Vinaya Augusthy Commented Feb 20 at 10:14
Add a comment  | 

1 Answer 1

Reset to default 3

You can assign false to canPop and exit the app with SystemNavigator like this:

  return PopScope(
    canPop: false,
    onPopInvokedWithResult: (didPop, result) {
      if (didPop) return;
      vm.clearPassCodeView();
      SystemNavigator.pop();
    },
    child: YourScffold(),
  );

本文标签: dartFlutter PopScope onPopInvokedWithResult not calling on pressing back buttonStack Overflow