skip to Main Content

enter image description here

Basicly i’m a junior programmer, i have never seen error like this. i’m always doing what it should does.Please i’m new in world of programmer, i wish someone can help me and teach what should i do

so, it a willPopScope error i don’t know where it is erroring but, i did solve agai and again but it isn’t working. Can someone looking for a error

i wish. I can more to learn about how many lesson shoul i learn. Please give me many lesson to improve myself

2

Answers


  1. https://docs.flutter.dev/release/breaking-changes/android-predictive-back

    According to this.
    To support Android 14’s Predictive Back feature, a set of ahead-of-time APIs have replaced just-in-time navigation APIs, like WillPopScope and Navigator.willPop.

    The PopScope class directly replaces WillPopScope.

    The old code we used before:

    WillPopScope(
      onWillPop: () async {
        return _anyCondition; //True or False
      },
      child: ...
    ),
    

    Code after migrating:

    PopScope(
      canPop: _anyCondition,  //Note here it takes a boolean instead of a function
      child: ...
    ),
    
    Login or Signup to reply.
  2. The error message "WillPopScope assumes immediate disposal on route change" means that the WillPopScope widget is being disposed of before the route change has finished completing. This can happen if you are using the WillPopScope widget in a route that is being popped, and the WillPopScope callback is taking a long time to complete.

    To fix this error, you need to make sure that the WillPopScope callback completes before the route change is finished completing. You can do this by either making the callback complete more quickly, or by using a different approach to preventing the user from exiting the screen.

    you can try this

      @override
    Widget build (BuildContext context) {
      return willPopScope(
        onWillPop: () async {
        
          final progressDialog = await showDialog(
            context: context,
            builder: (context) => AlertDialog(
              title: Text('Undoing operation...'),
              content: CircularProgressIndicator(),
            ),
          );
    
          await context.read<UndoAssignmentSubmissionCubit>().undo();
    
          progressDialog.dismiss();
    
          return true;
        },
        child: Container!
      );
    }
    

    OR

      @override
    Widget build (BuildContext context) {
      ModalRoute.addScopedWillPopCallback((_) async {
        await context.read<UndoAssignmentSubmissionCubit>().undo();
    
        return true;
      });
    
      return Container!
      
      @override
      void dispose() {
        ModalRoute.removeScopedWillPopCallback(_);
        super.dispose();
      }
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search