Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Controlling the width of elements in a Listview - flutter

I have created a list view , containging 3 TextFields , the problem is that ofc , they expand through the all screen width.

I tried , wrapping them with a container and set a width , and wrap it with a LimitedBox and set maxWidth - Neither of them works How i can control the width of the Textfields the inside the Listview , or please an alternative way to accomplish it. I have added one of the Textfields with my tries of resizing its width Thanks

ListView(
          children: <Widget>[
            LimitedBox(
              maxWidth: 50,
              child: Container(
                width: 50,
                child: TextFormField(
                  style: TextStyle(color: Colors.white),
                  decoration: InputDecoration(
                      hintText: '[email protected]',
                      hintStyle: TextStyle(fontSize: 10, color: Colors.white),
                      labelText: 'E-mail adress',
                      labelStyle: TextStyle(
                        color: Colors.white,
                      )),
                ),
              ),
            ),

),

like image 566
shahar Avatar asked Aug 28 '19 20:08

shahar


1 Answers

use Row Widget

ListView(children: <Widget>[
          Row(
            children: <Widget>[
              LimitedBox(
                maxWidth: 50,
                child: Container(
                  child: TextFormField(
                    style: TextStyle(color: Colors.white),
                    decoration: InputDecoration(
                        hintText: '[email protected]',
                        hintStyle: TextStyle(fontSize: 10, color: Colors.white),
                        labelText: 'E-mail adress',
                        labelStyle: TextStyle(
                          color: Colors.white,
                        )),
                  ),color: Colors.amber,
                ),
              )
          ],
        ),
        ])

enter image description here

like image 94
Junsu Cho Avatar answered Nov 15 '22 17:11

Junsu Cho