底部工作表的初始高度为屏幕的一半,如果滚动,则高度会增加到全屏

2023-12-28

我有一个底部工作表,其中包含以下代码,其中我将高度设置为 300.0,但我想在用户滚动时将高度增加到全屏..我该怎么做..请

void _showBottomSheet() {
    setState(() {
      _showPersBottomSheetCallBack = null;
    });

    _scaffoldKey.currentState
        .showBottomSheet((context) {
      return new Container(
        height: 300.0,
        color: Colors.greenAccent,
        child: new Center(
          child: new Text("Hi BottomSheet"),
        ),
      );
    })
        .closed
        .whenComplete(() {
      if (mounted) {
        setState(() {
          _showPersBottomSheetCallBack = _showBottomSheet;
        });
      }
    });
  }

颤振包底板是不是这个意思占据全屏,尽管稍加调整就可以产生您期望的行为。 如果你看一下BottomSheet 构造函数 https://github.com/flutter/flutter/blob/1ad538e454c77496fbd068b9e8b5f8b61c2f6d96/packages/flutter/lib/src/material/bottom_sheet.dart#L169,你会发现以下内容:

  @override
  BoxConstraints getConstraintsForChild(BoxConstraints constraints) {
    return new BoxConstraints(
      minWidth: constraints.maxWidth,
      maxWidth: constraints.maxWidth,
      minHeight: 0.0,
      maxHeight: constraints.maxHeight * 9.0 / 16.0
    );
  }

如果删除 9.0/16.0 高度限制,底部工作表将占据整个屏幕高度。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

底部工作表的初始高度为屏幕的一半,如果滚动,则高度会增加到全屏 的相关文章

随机推荐