英文:
how to add two Textfield in row. im add to this code but give a error
问题
此代码在一行中的两个文本字段上不起作用。
英文:
Container(
child: Row(
children: [
Container(child: TextField()),
Container(child: TextField()),
],
),
)
this code is not working on two Textfield in row.
答案1
得分: 0
尝试下面的代码,并将你的TextField包装在 Expanded
Widget 内:
Container(
margin: EdgeInsets.all(10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: TextField(
decoration: InputDecoration(
border: OutlineInputBorder(),
),
),
),
const SizedBox(
width: 10,
),
Expanded(
child: TextField(
decoration: InputDecoration(
border: OutlineInputBorder(),
),
),
),
],
),
),
英文:
Try below code and wrap your TextField inside Expanded
Widget:
Container(
margin: EdgeInsets.all(10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: TextField(
decoration: InputDecoration(
border: OutlineInputBorder(),
),
),
),
const SizedBox(
width: 10,
),
Expanded(
child: TextField(
decoration: InputDecoration(
border: OutlineInputBorder(),
),
),
),
],
),
),
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论