How do I make a TextField take up the entire screen - flutter

I am creating a notes application and using a text field with max lines set as null so the text can expand infinitely according to the text. The problem is that you can only start typing in the note when you select the text field due to its size I want to make it big enough to cover the entire screen for accessibility but I fear that the size of the text field may differ on each device which would ruin the entire point of making it fit the entire screen.
TextField(
controller: _textController,
style: const TextStyle(color: Colors.white),
keyboardType: TextInputType.multiline,
maxLines: null,
decoration: const InputDecoration(
contentPadding:
EdgeInsets.symmetric(horizontal: 10, vertical: 10),
border: InputBorder.none,
hintText: "Start typing your note...",
hintStyle: TextStyle(color: Colors.white),
),
);

By wraping your TextField in a SizedBox with a height: double.infinity you can expand your TextField
SizedBox(
height: double.infinity,
child: TextField(
controller: _textController,
style: const TextStyle(color: Colors.white),
keyboardType: TextInputType.multiline,
maxLines: null,
decoration: const InputDecoration(
contentPadding:
EdgeInsets.symmetric(horizontal: 10, vertical: 10),
border: InputBorder.none,
hintText: "Start typing your note...",
hintStyle: TextStyle(color: Colors.white),
)),
),

SizedBox(
height: MediaQuery.of(context).size.height,
TextField(
controller: _textController,
style: const TextStyle(color: Colors.white),
keyboardType: TextInputType.multiline,
maxLines: null,
decoration: const InputDecoration(
contentPadding:
EdgeInsets.symmetric(horizontal: 10, vertical: 10),
border: InputBorder.none,
hintText: "Start typing your note...",
hintStyle: TextStyle(color: Colors.white),
),
),
),

Related

How to Create small TextField

I want to reduce space between line and text with flutter.
SizedBox(
width: 60.0,
child: TextField(
textAlign: TextAlign.center,
keyboardType: TextInputType.number,
style: TextStyle(color: Colors.black),
decoration: InputDecoration(
hintText: '125',
),
),
),
Instead of wrapping TextField inside SizedBox use constraints property of Input Decoration to give the TextField min or max height/width:
TextField(
textAlign: TextAlign.center,
keyboardType: TextInputType.number,
style: TextStyle(color: Colors.black),
decoration: InputDecoration(
hintText: '125',
isDense: true,
constraints: BoxConstraints(
maxWidth: 60
)
),
)
Inside InputDecoration() set the contentPadding: EdgeInsets.zero. And set isDense: true

Flutter TextField hint text not aligned center horizontally

I have a very simple TextField, where I have textAlign: TextAlign.center inside (as advised in other answer here).
However, hint text is not horizontally centered, whereas input text is centered. (see attached picture)
I wonder why.. Somebody please help.
Code:
Container(
margin: EdgeInsets.symmetric(horizontal: 18.0),
child: TextField(
textAlign: TextAlign.center,
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'time',
),
),
width: 80,
)
You have to use hintText instead of labelText:
Container(
margin: EdgeInsets.symmetric(horizontal: 18.0),
child: TextField(
textAlign: TextAlign.center,
decoration: InputDecoration(
border: OutlineInputBorder(),
hintText: 'time', //instead of labelText
),
),
width: 80,
)

Underlined When Writing - Flutter - Textfield

Whenever I write the word is underlined. As soon as I write a new word, it will no longer be underlined, but what I am currently writing. Can I somehow issue that nothing is underlined when writing? I didn't find anything in the forum either.
child: TextField(
autocorrect: false,
style: TextStyle(
fontSize: 22.0,
),
cursorColor: Colors.black,
decoration: InputDecoration(
hintText: 'Search',
border: InputBorder.none,
icon: Icon(
Icons.search,
color: Color(0xFFe1F5FE),
),
),
),
did you try it with focusedBorder?
TextField(
decoration: new InputDecoration(
border: InputBorder.none,
focusedBorder: InputBorder.none,
contentPadding: EdgeInsets.only(left: 15, bottom: 11, top: 11, right: 15),
hintText: 'what you want'
),
),
Put this code inside TextField
keyboardType: TextInputType.text,
Example:
TextField(
keyboardType: TextInputType.text,
autocorrect: false,
style: TextStyle(
fontSize: 22.0,
),
cursorColor: Colors.black,
decoration: InputDecoration(
hintText: 'Search',
border: InputBorder.none,
icon: Icon(
Icons.search,
color: Color(0xFFe1F5FE),
),
),
),

Text cutting from below in TextField widget: Flutter

TextField widget works fine with less text but when i adding long text it starts to cut from bottom.
Without text.
With less text
Problem starts here with long text
My widget code.
Opacity(
opacity: 0.5600000023841858,
child: Container(
padding: EdgeInsets.only(left: 10),
width: 213,
height: 36,
decoration: BoxDecoration(
color: boxShadowCreamColor,
borderRadius: BorderRadius.circular(48),
boxShadow: [BoxShadow(color: boxShadowColor, offset: Offset(0, 0), blurRadius: 8, spreadRadius: 0)],
),
child: TextField(
keyboardType: TextInputType.text,
textAlign: TextAlign.left,
maxLines: 1,
textAlignVertical: TextAlignVertical.center,
style: TextStyle(color: Colors.white,fontSize: fontMedium,fontWeight: fontWeightRegular),
decoration: InputDecoration(
hintText: "Search",
border: InputBorder.none,
hintStyle: TextStyle(color: Colors.white,fontSize: fontMedium,fontWeight: fontWeightRegular),
suffixIcon: Icon(
Icons.search,
color: Colors.white,
),
),
),
),
);
Use isDense property inside decoration and set it to true, which should resolve your issue.
isDense property helps to take less vertical space.
decoration: InputDecoration(
isDense: true,
hintText: "Search",
border: InputBorder.none,
hintStyle: TextStyle(color: Colors.white),
suffixIcon: Icon(
Icons.search,
color: Colors.white,
),
),
It happens just because of your height which you have given your Container. Just increase that it will be fine for you.
try height: 42, // -- its because textfield shrink the size of Textfield when its growing.
OR
Add isDense: true // inside InputDecoration

How to make resizable TextField?

I want to make TextField resizable vertically and I have one idea about that
Expanded(
child: TextField(
cursorColor: Colors.black,
decoration: new InputDecoration.collapsed(
// border: new OutlineInputBorder(
// borderSide: new BorderSide(color: hexToColor('#5c6277'),style: BorderStyle())
// ),
hintText: "El Baraka",hintStyle: TextStyle(fontFamily: 'RobotoLight',color: Colors.grey,fontSize: 16),
),
),
This can be achieved with maxLines: null:
TextField(
cursorColor: Colors.black,
decoration: new InputDecoration.collapsed(
hintText: "El Baraka",hintStyle: TextStyle(fontFamily: 'RobotoLight',color: Colors.grey,fontSize: 16),
),
maxLines: null,
)
Now TextField will add a new line when your text reaches the edge.