在设置了bottomNavigationBar的情况下覆盖全屏?

时间:2019-06-12 15:49:19

标签: flutter dart

我正在尝试使用全屏进度平视显示器(旋转器),它实际上是全屏的。我当前的脚手架看起来像这样:

  Widget build(BuildContext context) {
    return WillPopScope(
      onWillPop: () async =>
          !await navigatorKeys[currentTab].currentState.maybePop(),
      child: Scaffold(
        resizeToAvoidBottomPadding: false,
        resizeToAvoidBottomInset: false,

        body:  ModalProgressHUD(child: buildTabs(context), inAsyncCall: _saving, color: Colors.grey, opacity: 0.5),
        bottomNavigationBar: BottomNavigation(
          currentTab: currentTab,
          onSelectTab: _selectTab,
        ),
      ),
    );
  }

基于本教程(https://medium.com/coding-with-flutter/flutter-case-study-multiple-navigators-with-bottomnavigationbar-90eb6caa6dbf)。在“正文”中,我有一个小部件(来自https://pub.dev/packages/modal_progress_hud的“ ModalProgressHUD”)应覆盖全屏,但底部导航栏将从覆盖中排除。

如何在底部导航栏上放置一个全屏覆盖小部件,以显示一些“进行中”的微调框?

谢谢 马丁

1 个答案:

答案 0 :(得分:0)

令人尴尬...发布后,我立即发现了它。只需将“ WillPopScope”包装到ModalProgressHud小部件中就可以了

  @override
  Widget build(BuildContext context) {
    return ModalProgressHUD(child: buildScaffoldWidget(context), inAsyncCall: _saving, color: Colors.grey, opacity: 0.5);
  }

  Widget buildScaffoldWidget(BuildContext context) {
    return WillPopScope(
      onWillPop: () async =>
          !await navigatorKeys[currentTab].currentState.maybePop(),
      child: Scaffold(
        resizeToAvoidBottomPadding: false,
        resizeToAvoidBottomInset: false,

        body:  buildTabs(context),
        bottomNavigationBar: BottomNavigation(
          currentTab: currentTab,
          onSelectTab: _selectTab,
        ),
      ),
    );
  }