Flutter 颤振成排
我需要创建以下内容: 我可以使用以下代码:Flutter 颤振成排,flutter,flutter-layout,Flutter,Flutter Layout,我需要创建以下内容: 我可以使用以下代码: Row( children: <Widget>[ Container( width: 30 ), Column( children: <Widget>[ Text("label"), Container( width: screenSize.width - 30, // <- this is problem
Row(
children: <Widget>[
Container(
width: 30
),
Column(
children: <Widget>[
Text("label"),
Container(
width: screenSize.width - 30, // <- this is problem
child: Row(
children: <Widget>[
Expanded( child: TextField() ),
Expanded( child: TextField() ),
],
),
),
],
),
],
);
行(
儿童:[
容器(
宽度:30
),
纵队(
儿童:[
文本(“标签”),
容器(
宽度:screenSize.width-30,//解决方案
行(
儿童:[
容器(
颜色:颜色,红色,
宽度:50,
),
扩大(
子:列(
儿童:[
文本(“标签”),
扩大(
孩子:排(
儿童:[
扩大(
子项:TextField()
),
扩大(
子项:TextField()
),
],
),
),
],
),
),
],
);
解释
它是关于您放置扩展的实例的位置。
您有一行,如果它包含一个展开的子行,则可以填充其父行。因此,我们定义了它的一个子行(容器)的大小,而另一个子行仅为展开的。这同样适用于列子行
也许从一个简单的例子开始更容易理解。请参阅
输出
另外,欢迎使用StackOverFlow,Dmitry!您可以在列小部件中使用crossAxisAlignment,并使其拉伸以获得屏幕中所有剩余的宽度
Row(
children: <Widget>[
Container(
width: 30
),
Column(
crossAxisAlignment: CrossAxisAlignment.stretch, // <- Add this
children: <Widget>[
Text("label"),
Container(
child: Row(
children: <Widget>[
Expanded( child: TextField() ),
Expanded( child: TextField() ),
],
),
),
],
),],);
行(
儿童:[
容器(
宽度:30
),
纵队(
crossAxisAlignment:crossAxisAlignment.stretch//