3

Friends,

I working on DropdownButtonFormField in flutter. It get overflow if menuitem is very big text. can anyone please suggest how to overcome this issue.

Thanks in advance.

  Padding(
                   padding: const EdgeInsets.fromLTRB(0, 20, 0, 0),
                   child:
                   DropdownButtonFormField<String>(
                     value: _paperController,


                     validator: (value) {
                       if (value == null) {
                         return "Select Paper";
                       }
                     },
                     items: Paper_data.map((label) => DropdownMenuItem(
                       child: Text(label.toString()),
                       value: label,
                     ))
                         .toList(),

                     onChanged: (value) {
                       setState(() {
                         _paperController = value;
                       });



                     },
                     hint: Text('Select Paper'),
                     decoration: InputDecoration(

                         border: OutlineInputBorder(
                             borderSide: BorderSide(
                                 color: Color(0xffCED0D2), width: 1),
                             borderRadius:
                             BorderRadius.all(Radius.circular(6)))),


                   ),


                 )

2 Answers 2

1

Inside the Text widget add the overflow property:

 child: Text(label.toString(), overflow: TextOverflow.ellipsis,),

From the docs:

overflowTextOverflow

How visual overflow should be handled.

Sign up to request clarification or add additional context in comments.

Comments

1

I had to add isExpanded: true and overflow: TextOverflow.ellipsis.

SizedBox(
        width: 200.0,
        child:
          DropdownButtonFormField<String>(
            isExpanded: true,

            ...

            DropdownMenuItem(
              child: Text('YOUR_NAME',
                overflow: TextOverflow.ellipsis)

              ...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.