Reputation: 85
I am new to flutter and I am trying to place two text fields side by side like the image shown below.
This is the code I have so far for the single-line text fields.
Padding(
padding: const EdgeInsets.symmetric(horizontal: 25.0),
child: Container(
decoration: BoxDecoration(
color: Colors.grey[200],
border: Border.all(color: Colors.white),
borderRadius: BorderRadius.circular(100),
),
child: Padding(
padding: const EdgeInsets.only(left: 20.0),
child: TextField(
decoration: InputDecoration(
border: InputBorder.none,
hintText: "Contact No",
),
),
),
),
)
Upvotes: 0
Views: 594
Reputation: 1557
You can simply put them inside a Row
but you have to wrap each one of them with an Expanded
widget like the following:
Row(
children: [
Expanded(child:,TextField()),
SizedBox(width: 12), // Optional
Expanded(child:,TextField()),
]
)
NOTE: The idea of wrapping TextField
with an Expanded
when using it inside a row is to allow Flutter to determine the correct render size of the field due to internal details in the Framework.
Upvotes: 2
Reputation: 17772
Create a row and add 2 textfields like written below
Row(
children: [
TextField(),
TextField(),
]
)
Upvotes: 0