初始高度为屏幕一半的底页,如果滚动,则高度增加到全屏
问题内容:
我在下面的代码中放了一个底部工作表,在其中我将高度设置为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构造函数,则会发现以下内容:
@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高度限制,则底部工作表将占据整个屏幕的高度。