Will pop 范围已被弃用

问题描述 投票:0回答:1

我用过

WillPopScope

WillPopScope(
            onWillPop: () => willPopScopeWid(),
            child:Container(
//SomeCode
)),
willPopScopeWid() {
    setState(() {
      onTapOfVideo = false;
    });
    return Navigator.pop(context);
  }

=>

还有其他方法可以摆脱已弃用的 Widget 吗?

flutter
1个回答
0
投票

是的,

WillPopScope
小部件已被弃用,并被
PopScope
取代,以下是如何使用
PopScope
:

  PopScope(
      canPop: false,
      onPopInvoked: (bool didPop) async {
        // when pressing back button this is a callback for
      },
      child: YourWidget()
     )
© www.soinside.com 2019 - 2024. All rights reserved.