[英]I am new to flutter and i am trying to create this layout
How can i create this layout in flutter.如何在 flutter 中创建此布局。 when i click raised button the name and number is saved and you get two new textformfield to enter another business owner data
当我单击凸起按钮时,名称和号码已保存,您将获得两个新的 textformfield 以输入另一个企业主数据
initially there will be two textformfield to enter owner details as shown in first image if there are many co-founders then he can press the raised button and two new blank form field will be shown最初将有两个文本表单字段来输入所有者详细信息,如第一张图片所示,如果有很多联合创始人,那么他可以按下凸起的按钮,将显示两个新的空白表单字段
end result can look like this second image最终结果可能看起来像第二张图片
i tried multiple times but wasn't able to implement it correctly.我尝试了多次,但无法正确实施。 Any help is appreciated.
任何帮助表示赞赏。
One ideal way to do this would be to use a ListView
to hold your TextFields
.一种理想的方法是使用
ListView
来保存您的TextFields
。 It'll first hold your initial TextFields
, then a Column
placeholder that can add additional TextFields
when you tap your button AddOwner.它首先会保存您的初始
TextFields
,然后是一个Column
占位符,当您点击按钮 AddOwner 时可以添加其他TextFields
。 A simplified example:一个简化的例子:
ListView(
children: <Widget>[
TextFormField(
decoration: InputDecoration(labelText: 'name'),
),
TextFormField(
decoration: InputDecoration(labelText: 'phone'),
),
Column(children: additionalTextFields,),
],
),
And in your AddOwner button, you'll call the method to add more entries as you wish:在您的 AddOwner 按钮中,您将调用该方法以根据需要添加更多条目:
var additionalTextFields = List<Widget>();
void _addNewTextFields() {
setState(() {
additionalTextFields.add(
TextFormField(
decoration: InputDecoration(labelText: 'name'),
),
);
additionalTextFields.add(
TextFormField(
decoration: InputDecoration(labelText: 'phone'),
),
);
});
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.