Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WillPopScope is deprecated after flutter 3.12

Tags:

flutter

When we use below code after flutter version 3.12.0 we are getting deprecated message, what to use insted of this now?

WillPopScope(
          onWillPop: () {
            setStatusBarColor(statusBarColorPrimary,statusBarIconBrightness: Brightness.light);
            finish(context);
            return Future.value(true);
          },)
like image 937
dharmx Avatar asked Dec 01 '25 09:12

dharmx


1 Answers

WillPopScope is deprecated after flutter v3.12.0-1.0.pre.

Now you can use PopScope as below:

return PopScope(
    canPop: true, //When false, blocks the current route from being popped.
    onPopInvoked: (didPop) {
        //do your logic here:
        setStatusBarColor(
            statusBarColorPrimary,
            statusBarIconBrightness: Brightness.light,
        );
        finish(context);
    },
    child: Scaffold(/*other child and ui etc*/),
);
like image 112
dharmx Avatar answered Dec 03 '25 00:12

dharmx