0
点赞
收藏
分享

微信扫一扫

MySQL-事务(详细版)

时光已翩然轻擦 2024-11-13 阅读 17

在Flutter中,如果你想禁用侧滑返回功能,你可以使用WillPopScope小部件,并在onWillPop回调中返回false来阻止用户通过侧滑返回到上一个页面。

class DisableSwipePop extends StatelessWidget {
  
  Widget build(BuildContext context) {
    return WillPopScope(
      onWillPop: () async => false,
      child: Scaffold(
        appBar: AppBar(
          title: Text('禁用侧滑返回'),
        ),
        body: Center(
          child: Text('点击按钮返回'),
        ),
      ),
    );
  }
}

但是 WillPopScope方法已经过时,现在PopScope 代替具体使用方法

class DisableSwipePop extends StatelessWidget {
  
  Widget build(BuildContext context) {
    return PopScope(
      canPop: false,
      child: Scaffold(
        appBar: AppBar(
          title: Text('禁用侧滑返回'),
        ),
        body: Center(
          child: Text('点击按钮返回'),
        ),
      ),
    );
  }
}
举报

相关推荐

MySQL-事务

mysql-事务

MySQL-事务详解

mysql-事务篇

MySQL-事务与锁

MySQL-索引

0 条评论