Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter - Textfield label overflow cutting off text

Tags:

flutter

I am working on a Flutter project, I have implemented a Form with a TextFormField, we have some fields with really long labels, and because they are so long, Flutter us cutting the text off and adding ... in the end, is it possible to set the overflow so it makes the label text in to 2 lines instead of cutting the text off?

TextFormField(
          key: GlobalKey(),
          controller: _textEditingController,
          focusNode: _focusNode,
          obscureText: true,
          keyboardType: TextInputType.text,
          textInputAction: TextInputAction.done,
          decoration: widget.decorations.copyWith(
            errorText:
                widget.field["error"] != null ? widget.field["error"] : null,
            labelText: "A VERY VERY VERY VERY VERY VERY LONG LABEL",
            hintText: widget.field["helpText"],
            helperStyle: TextStyle(
              color: Colors.black,
            ),
          ),
          onFieldSubmitted: widget.onFieldSubmitted,
          onSaved: widget.onSaved,
          onTap: widget.onTap,
        ),
like image 829
Billy Mahmood Avatar asked Oct 31 '25 03:10

Billy Mahmood


2 Answers

I found this solution while I was trying to solve the same problem. Try using the decoration property with the errorMaxLines property set to a number greater than 1. E.g.

TextField(
     keyboardType: TextInputType.number,
     decoration: InputDecoration(
     errorMaxLines: 2,),)
like image 152
abene42 Avatar answered Nov 02 '25 17:11

abene42


It works for me....

TextFormField(

 decoration: InputDecoration(
 label: Text(
      "A VERY VERY VERY VERY VERY VERY LONG LABEL",
    ),)
like image 38
Dinesh Avatar answered Nov 02 '25 17:11

Dinesh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!