【问题标题】:How to decrease the bottomsheet height dynamically in flutter?如何在颤动中动态降低底片高度?
【发布时间】:2020-10-03 07:58:54
【问题描述】:

我正在使用 showModalBottomSheet 并在开始时给出 90% 的高度。底页内有两个选项卡(重复和一次),重复选项卡有很多内容,并且显示非常好,高度为 90%。但是当我在一次性选项卡上进行选项卡时,我想将底页的大小减小到 40%,因为它没有更多的内容,而且看起来也不好看。 但我无法在按下一次性标签按钮时动态更改底部工作表的高度。

谁能帮助我如何在颤振中实现此功能?

【问题讨论】:

  • 上传您的代码,以便我们更好地理解。

标签: flutter dart bottom-sheet flutter-showmodalbottomsheet


【解决方案1】:

您可以通过将PutYourWidgetHere() 替换为您的自定义小部件来使用以下代码。

void showBottomSheet() {
    showModalBottomSheet(
        context: context,
        isScrollControlled: true,
        builder: (BuildContext context) {
          return SingleChildScrollView(
              child: Container(
                padding: EdgeInsets.only(
                    bottom: MediaQuery.of(context).viewInsets.bottom),
                child: PutYourWidgetHere(),
              ));
        });
  }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-08-22
    • 1970-01-01
    • 2011-09-17
    • 2021-07-27
    • 2023-03-03
    • 1970-01-01
    • 2020-01-26
    • 2023-03-03
    相关资源
    最近更新 更多