初始高度为屏幕一半的底页,如果滚动,则高度增加到全屏 [英] bottom sheet with initial height half of screen and if it scroll then height is increase to full screen

查看:54
本文介绍了初始高度为屏幕一半的底页,如果滚动,则高度增加到全屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在下面的代码中放了一个底页,在其中我将高度设置为300.0,但是我希望在用户滚动时将高度增加到全屏..我该怎么做..请

I have a bottom sheet with below code in where i put a height 300.0 but I want increase height to full screen when user scroll ..how can i do that ..please

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;
        });
      }
    });
  }

推荐答案

尽管有些微调整可以产生您期望的行为,但flutter软件包的底页并不是全部占据全屏的意思. 如果您查看 BottomSheet构造函数,您会发现以下内容:

The flutter package bottom sheet is not meant to occupy the full screen, though a little tweak can produce the behavior you expect. If you look at the BottomSheet constructor, you will find the following:

  @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高度限制,则底部工作表将占据整个屏幕高度.

If you remove the 9.0/16.0 height constraint, the bottom sheet will occupy the full screen height.

这篇关于初始高度为屏幕一半的底页,如果滚动,则高度增加到全屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆