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

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

问题描述

我有一个带有以下代码的底部表,我在其中放置高度 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天全站免登陆