skip to Main Content
return WillPopScope(
      onwillPop: () async{

      },
  
  child: Scaffold(
    body: SafeArea(
      child: Obx(
        () => IndexedStack(
          index: logic.currentIndex.value,
          children: logic.pages,
        ),
      ),

but the willpopscope is depreciated as per dart 3.2.3 version.what to do?

want to close the app only after double tap the back button with the popscope widget ?

2

Answers


  1. Swap out the outdated WillPopScope widget for the PopScope new widget; see the code below

    PopScope(
      canPop: true,
      onPopInvoked : (didPop){
       // Write your logic here...
      },
    )
    
    Login or Signup to reply.
  2. Yes Will PopScope is deprecated and you should use popScope instead.

       PopScope(
             canPop: true,
             onPopInvoked: (didPop) => Navigator.pop(context),
             child: child),
    

    This is a new widget provided by flutter to handle pop scope. Simply add this to any child and implement onPopInvoked method it will give you a Boolean value which gives you feedback on whether it popped or not if yes then pop scope was invoked and you can handle action accordingly.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search