Reputation: 319
How can I have a new line property in the textfield widget? SO that the text entered when reaches a certain point, it shifts to a new line. Can anyone help me fix this?
Code :
body: Center(
child: Container(
height: 500,
decoration: BoxDecoration(
border: Border.all(
color: Colors.black,
width: 2,
),
borderRadius: BorderRadius.circular(10)),
child: Padding(
padding: const EdgeInsets.only(left: 16.0),
child: TextFormField(
decoration: InputDecoration(
hintText: 'UserName',
hintStyle:
TextStyle(fontWeight: FontWeight.w400, fontSize: 24.0)),
),
),
),
)
Output:
Upvotes: 0
Views: 42
Reputation: 1073
From the Official Docs, The maxLines property can be set to null to remove the restriction on the number of lines. By default, it is one, meaning this is a single-line text field. maxLines must not be zero.
You just have to add maxLines: null
body: Center(
child: Container(
height: 500,
decoration: BoxDecoration(
border: Border.all(
color: Colors.black,
width: 2,
),
borderRadius: BorderRadius.circular(10)),
child: Padding(
padding: const EdgeInsets.only(left: 16.0),
child: TextFormField(
maxLines: null,
decoration: InputDecoration(
hintText: 'UserName',
hintStyle:
TextStyle(fontWeight: FontWeight.w400, fontSize: 24.0)),
),
),
),
)
Upvotes: 1