我正在做一个设置页面和布局是一个容器与设置的高度,然后在它下面的列表视图,但这个列表视图需要一个设置的高度;所以当我把它 Package 在一个容器里,并给予它一个高度时,它是有效的,但是如果我把它 Package 在一个展开的容器里,它就不起作用了。
我已经尝试了很多方法,比如把它放在布局生成器中,并将高度指定为BoxConstraints.maxHeight,还有很多其他的技巧,这些技巧应该有效,但没有。
class Settings extends StatelessWidget {
Settings({@required this.userInfo, @required this.licenseInfo});
final userInfo;
final licenseInfo;
@override
Widget build(BuildContext context) {
double width = MediaQuery.of(context).size.width;
double height = MediaQuery.of(context).size.height;
return GestureDetector(
onTap: () {
FocusScope.of(context).requestFocus(new FocusNode());
SystemChannels.textInput.invokeMethod('TextInput.hide');
},
child: Scaffold(
resizeToAvoidBottomPadding: false,
backgroundColor: Colors.transparent,
appBar: AppBar(
elevation: 0.0,
backgroundColor: Color(0xFF77FDA7),
title: Text('Settings',
style: TextStyle(color: darkGrey, fontWeight: FontWeight.w600)),
),
body: Column(
children: <Widget>[
Stack(
children: <Widget>[
Container(
height: 91,
width: width,
decoration: BoxDecoration(gradient: greenGradient),
),
Column(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
SettingsProfile(
userInfo: this.userInfo,
licenseInfo: this.licenseInfo),
SizedBox(
height: 300,
child: SettingsList(),
),
],
),
],
),
],
)),
);
}
}
如你所见,有一个堆栈和另一列,但这些只是UI的一部分,我需要它们。它们与我尝试修复此问题没有任何关系。请帮助,因为我需要此列表视图占用列中的所有可用空间,而不会溢出。
1条答案
按热度按时间bz4sfanl1#
我有一个类似的用例,我在我的应用程序上做的是用
Expanded
PackageLayoutBuilder
。LayoutBuilder获取小部件可用屏幕空间的尺寸,它可以用来设置小部件的高度。