In my TextFormString
for Password Field I have validator
that returns a String. The problem is this String
is too long and it doesn't fit the screen.
I'd like to make it multiline, but I can't find how to do it: I've tried setting width for the Container
this TextFormString
is in -- no effect, I've hardcoded newlines \n
to my String, it actually worked but I think there must be some other solution to break it to lines more dynamically.
What is the right way to do it?
Screenshot
You can decorate your TextFormFiled
so that the error label has more than 1 lines:
errorMaxLines: 2
Here an example:
TextFormField(
decoration: const InputDecoration(
icon: Icon(Icons.person),
hintText: 'What do people call you?',
labelText: 'Name *',
errorMaxLines: 2
),
validator: (String value) {
return value.contains('@')
? 'Do not use the @ char. Do not use the @ char. Do not use the @ char. Do not use the @ char.'
: null;
},
),
In this example I didn't set obscureText: true
(desiderata for a password field), so that the text is visible.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With