使用 WillPopScope + Future.value(false); 屏蔽返回键。

    1. showDialog<Null>(
    2. context: context, // BuildContext对象
    3. barrierDismissible: false, // 屏蔽点击对话框外部自动关闭
    4. builder: (_) => WillPopScope(
    5. child: AlertDialog(
    6. content: Text(
    7. 'xxx',
    8. ),
    9. actions: <Widget>[
    10. ],
    11. ),
    12. onWillPop: () async {
    13. return Future.value(false);
    14. },
    15. ),
    16. );