I have been trying to adjust the size of the text field but whenever I do it I have a lot of whitespace. Whenever I add a SizedBox it starts to add lots of whitespace. I have the TextField embedded in a MaterialApp and a Scaffold. So I am stuck on this.
This is without the SizedBox:
TextField(
decoration: InputDecoration(
hintText: "Enter Your Email Address",
border: OutlineInputBorder(),
contentPadding: EdgeInsets.all(30),
),
),
This is when you add the SizedBox:
SizedBox(
height: 100,
width: 100,
child: TextField(
decoration: InputDecoration(
hintText: "Enter Your Email Address",
border: OutlineInputBorder(),
contentPadding: EdgeInsets.all(30),
),
),
),
6
Answers
Probably you are not using Column, that’s why when you wrap your TextField with SizedBox the screen takes SizedBox’s width. At the top in body of Scaffold you should use Column.
If you already have Column, please share your whole code for this particular page, and let me have a better look.
you can do like this.
I generally used ‘Sized Box’ for spacing purpose in my flutter project
Use the below written code to understand how SizedBox works as spacing
Currently, the width of the widget tree is the width of the widget whose width is maximum(Here, the width of the widget tree is equal to the width of the next button).
set width of sizedBox to double.inifinity, it makes the sizedbox to occupy the available width i.e screen width.
And the widget tree occupies the entire width.
Please accept the solution if solves your problem
just change this -> dont need to use SizedBox widget
You are adding a sized box which have 100 width and also 100 height ,so the sized box will be a squared box .
By increasing the width of the sized box like 300 something you can easily do this or I suggest you a way that a text field will be easily fixed in you code .
I hope this code will help you