I want to increase the length of the validator message whilst keeping the width of the textfield itself the same. Ideally it would just wrap onto a second line but I have no idea how to achieve this.
This is my current implementation.
Expanded(
                              flex: 1,
                              child: TextFormField(
                                controller: shortNameController,
                                decoration: InputDecoration(hintText: 'SHRT'),
                                textAlign: TextAlign.center,
                                textCapitalization: TextCapitalization.characters,
                                inputFormatters: [
                                  WhitelistingTextInputFormatter(
                                      RegExp('[A-Za-z0-9]')),
                                  LengthLimitingTextInputFormatter(4),
                                ],
                                validator: (value) {
                                  if (value.isEmpty) {
                                    return 'Enter your team\'s short name';
                                  } else if (value.length < 3) {
                                    return 'Must be at least 3 characters';
                                  }
                                  return null;
                                },
                              )),
                Use errorMaxLines in InputDecoration(), like this:
TextFormField(
  controller: shortNameController,
  decoration: InputDecoration(
    hintText: 'SHRT',
    errorMaxLines: 3, // number of lines the error text would wrap 
  ),
  // other parameters
  validator: (value) {
    if (value.isEmpty) {
      return 'Enter your team\'s short name';
    } else if (value.length < 3) {
      return 'Must be at least 3 characters';
    }
    return null;
  },
)
                        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