Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do i represent two text fields in row

So I am trying to create a layout like this. Where I have 2 text fields horizontally but upon wrapping it in a row. However upon reloading no text field shows up:

enter image description here

Through this code however upon reloading the none of this appears:

Column(
                    children: <Widget>[
                      SizedBox(height: 10.0),
                      Row(
                        mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                        children: <Widget>[
                          TextField(
                            decoration: InputDecoration(
                                labelText: 'Name',
                                labelStyle: TextStyle(
                                    color: Colors.grey[400]
                                )
                            ),
                          ),
                          SizedBox(width: 10.0),
                          TextField(
                            decoration: InputDecoration(
                                labelText: 'Name',
                                labelStyle: TextStyle(
                                    color: Colors.grey[400]
                                )
                            ),
                          ),
                        ],
                      ),
                      SizedBox(height: 10.0),
                      TextField(
                        decoration: InputDecoration(
                            labelText: 'Email/Mobile Number',
                            labelStyle: TextStyle(
                              color: Colors.grey[400],
                            )
                        ),
                      ),
                      SizedBox(height: 10.0),
                      TextField(
                        decoration: InputDecoration(
                            labelText: 'Password',
                            labelStyle: TextStyle(
                              color: Colors.grey[400],
                            )
                        ),
                      ),
                    ],
                  )
like image 447
Aditya Pandey Avatar asked Jan 31 '26 05:01

Aditya Pandey


1 Answers

You have to use an Expanded widget . Replace your Row widget with the one below:

  Row(
                          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                          children: <Widget>[
                            Expanded(
                              // optional flex property if flex is 1 because the default flex is 1
                              flex: 1,
                              child: TextField(
                                decoration: InputDecoration(
                                    labelText: 'Name',
                                    labelStyle: TextStyle(
                                        color: Colors.grey[400]
                                    )
                                ),
                              ),
                            ),
                            SizedBox(width: 10.0),
                            Expanded(
                              // optional flex property if flex is 1 because the default flex is 1
                              flex: 1,
                              child: TextField(
                                decoration: InputDecoration(
                                    labelText: 'Name',
                                    labelStyle: TextStyle(
                                        color: Colors.grey[400]
                                    )
                                ),
                              ),
                            ),
                          ],
                        ),

like image 158
V.N Avatar answered Feb 03 '26 00:02

V.N