1

In Flutter, when text is entered that is longer than the field, the text is hidden, as shown in the gif:

enter image description here

The code from first text form field:

Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        labelFormStyle("Nome do equipamento"),
                        Container(
                          height: hasErrorForm && equipmentNameController.text.isEmpty ? 55 : 35,
                          child: Container(
                          height: hasErrorForm && equipmentNameController.text.isEmpty ? 55 : 35,
                          child: TextFormField(
                            validator: (value){
                              return validatorEmpty(value);
                            },
                            controller: equipmentNameController,
                            keyboardType: TextInputType.multiline,
                            maxLines: null,
                            textInputAction: TextInputAction.next,
                            style: TextStyle(
                                fontSize: 14
                            ),
                            decoration: InputDecoration(
                                isDense: true,
                                enabledBorder: enableBorderField(),
                                focusedBorder: enableBorderField(),
                                disabledBorder: enableBorderField(),
                                border: enableBorderField(),
                                focusedErrorBorder: errorBorderField(equipmentNameController.text.isEmpty),
                                errorBorder: errorBorderField(equipmentNameController.text.isEmpty)
                            ),
                            onChanged: (value){
                              if(hasErrorForm){
                                setState(() {
                                  _formKey.currentState!.validate();
                                });
                              }
                            },
                          ),
                        ),
                      ],
                    ),

How to solve this?

  • What platform are you running this code on (Android/iOS/Web/Windows/Linux)? – TarHalda Nov 28 '22 at 19:08
  • 1
    Im running in Android 10 – Gabi Mangili Nov 28 '22 at 19:10
  • Have you checked this post? https://stackoverflow.com/questions/45900387/multi-line-textfield-in-flutter – GrahamD Nov 28 '22 at 19:13
  • I tried put TextField( keyboardType: TextInputType.multiline, maxLines: null, ) but the error continues – Gabi Mangili Nov 28 '22 at 19:24
  • Edit your post to show the new code – GrahamD Nov 28 '22 at 19:27
  • 1
    The height that you have put on the container may be the problem. I can't test it at the moment. Try commenting out the container size constraints and see what happens. The multiple lines are probably there but you can't see them. – GrahamD Nov 28 '22 at 19:29
  • this worked, but it was too big, I'm sure the designer will disapprove. I wanted to know a way to make it a single line and have scrolling – Gabi Mangili Nov 28 '22 at 19:35
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/249968/discussion-between-grahamd-and-gabi-mangili). – GrahamD Nov 28 '22 at 19:36

1 Answers1

0

I managed to solve the problem by removing the height restriction and putting maxLines: 1. The only problem is that it didn't get the size the designer wanted, but I'll talk to him about it