如何在颤振中动态降低底片高度?

Uma*_*air 4 dart flutter bottom-sheet flutter-showmodalbottomsheet

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

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

San*_*rma 9

您可以通过替换为您的自定义小部件来使用以下代码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(),
              ));
        });
  }
Run Code Online (Sandbox Code Playgroud)