Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to limit size of DropDown from DropDownButton #23865

Closed
sathishRA91 opened this issue Nov 2, 2018 · 49 comments · Fixed by #76493
Closed

Option to limit size of DropDown from DropDownButton #23865

sathishRA91 opened this issue Nov 2, 2018 · 49 comments · Fixed by #76493
Assignees
Labels
c: new feature Nothing broken; request for a new capability customer: crowd Affects or could affect many people, though not necessarily a specific customer. f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. P2 Important issues not at the top of the work list

Comments

@sathishRA91
Copy link

i have long list its fill the window when click the DropDownButton. Is it possible to limit the suggestionsAmount in DropDownButton view

@zoechi
Copy link
Contributor

zoechi commented Nov 2, 2018

Please elaborate more what this request is about.

@zoechi zoechi added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Nov 2, 2018
@sathishRA91
Copy link
Author

screenshot_1541159874
screenshot_1541159880

@no-response no-response bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Nov 2, 2018
@zoechi
Copy link
Contributor

zoechi commented Nov 2, 2018

Please add the output of flutter doctor -v.

@zoechi zoechi added the framework flutter/packages/flutter repository. See also f: labels. label Nov 2, 2018
@zoechi zoechi added this to the Goals milestone Nov 2, 2018
@HansMuller
Copy link
Contributor

This is a reasonable request.

By default, DropdownButton's menu shows as many items as will fit modulo a little padding above and below. It would be useful to be able to provide a limit. Could be: number of items, menu height, menu height as a percentage of the available space.

If the dropdown's menu is going to scroll, it's helpful if the height limit is not a whole number of items. A partially visible item at the bottom of the menu is a reminder that the menu is scrollable.

@goderbauer goderbauer added c: new feature Nothing broken; request for a new capability f: material design flutter/packages/flutter/material repository. labels Jan 4, 2019
@goderbauer goderbauer changed the title Hi is it possible to limit the suggestions item in DropDownButton view Option to limit size of DropDown from DropDownButton Jan 4, 2019
@aytunch
Copy link

aytunch commented Feb 20, 2019

@HansMuller While at it, we should add limitations for the distance the opened menu is from top or bottom. A problem I am having is as follows:
I am using Scaffold.extendBody = true and when I open Dropdownmenu, the bottom part of the list stays under the bottomnavbar. So if we can limit the menu with bottom/top padding as well as the size it would be perfect. Having an only height/width limitation would not be enough since sometimes the dropdownbutton is just above the bottomnavbar and the menu opens up towards top keeping the bottom under the bar. limiting height would only bring the top downwards. not bottom upwards.

@HansMuller
Copy link
Contributor

HansMuller commented Feb 20, 2019

If Scaffold.extendBody = true, descendants of the scaffold's body enclosed in a SafeArea should avoid the BottomNavigationBar. Will have to see how that works with a drop down menu...

@aytunch
Copy link

aytunch commented Feb 20, 2019

If Scaffold.extendBody = true, descendants of the scaffold's body enclosed in a SafeArea should avoid the BottomNavigationBar. Will have to see how that works with a drop down menu...

Most probably you are right that it should work with a standart BottomNavigationBar but I implemented mine custom which is wrapping a BottomAppBar. And I believe many can do so as well in order to have the tabs having their own nested navigators like Bizzotto did.

@aytunch
Copy link

aytunch commented Feb 20, 2019

@HansMuller I tried wrapping DropDownButton in a SafeArea and the dropdowns themselves moved up in the screen by a lot.

However, the DropDownButton Menu still is behind the BottomNavigationBar (BottomAppBar) :((

simulator screen shot - iphone xr - 2019-02-21 at 00 38 03

simulator screen shot - iphone xr - 2019-02-21 at 00 38 11

@HansMuller
Copy link
Contributor

In the case 5km/10km/etc case above the dropdown menu just doesn't fit within the SafeArea. I think what's needed is for the menu's size to reflect the safe area's limits (not the screen's limits). Will look into this. Thanks for the excellent illustration of the problem BTW!

@aytunch
Copy link

aytunch commented Feb 20, 2019

@HansMuller Thank you for answering so quickly. I will leave them as they are for now and work on building other stuff. I am sure a solution will emerge since you are handling it. Can't wait

@HansMuller
Copy link
Contributor

Ordinarily the dropdown button's menu appears in a route that appears on top of the BottomNavigationBar etc. Here's a simple test case: https://gist.github.com/HansMuller/4444359b7a06df9593004173bc639949

dropdown

Your case looks considerably more complex? Can you provide a test case that demonstrates the problem?

@HansMuller HansMuller added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Feb 22, 2019
@wprater
Copy link

wprater commented Apr 12, 2019

Is there another issue that tracks a request to adjust or limit the max height for a DropdownButton. We would like to track the progress of such a change, if it's already planned.

@no-response
Copy link

no-response bot commented Apr 12, 2019

Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now. Please don't hesitate to comment on the bug if you have any more information for us; we will reopen it right away!
Thanks for your contribution.

@no-response no-response bot closed this as completed Apr 12, 2019
@byronferguson
Copy link

@wprater we also have an issue with the default behavior consuming the entire screen, minus a little vertical padding, which makes it difficult to dismiss.

Screen Shot 2019-04-26 at 11 33 12 AM

We really need a means to control the dropdown area of this Widget

@CoreyCole
Copy link

diegoveloper on stack overflow has implemented a dropdown that takes a pixel height

@tudor07
Copy link

tudor07 commented Sep 2, 2019

@sathishRA91 can you please re-open this issue, it has not been fixed. @CoreyCole's answer is a workaround, but I think a proper fix is necessary in Flutter.

@jffiorillo
Copy link

Do we have a proper fix to this issue? I agree with @tudor07 what @CoreyCole suggested is just a workaround.

@MuhammadAliKhan1
Copy link

Still not solved huh ? oh well..

@maxgmer
Copy link

maxgmer commented Apr 6, 2020

ye pls add the option to set expanded height

@BoredNerdy
Copy link

custom dropdown widget is here :

https://github.com/BoredNerdy/custom_drop_down.git

@talhashahab786
Copy link

Brother, simply use containers with margin and paddings and use isExpanded to true. Code given below:

  • Thank me Later *

                Container(
                        width: MediaQuery.of(context).size.width * 0.3,
                        margin: EdgeInsets.only(
                            top: 0,
                            left: MediaQuery.of(context).size.width * 0.75),
                        padding: EdgeInsets.only(),
                        child: Center(
                            child: Align(
                                alignment: Alignment.topRight,
                                child: DropdownButton<String>(
                                  value: dropDownValue,
                                  // icon: Icon(Icons.arrow_downward),
                                  iconSize: 24,
                                  elevation: 16,
                                  isExpanded: true,
                                  style: TextStyle(
                                    color: Colors.black87,
                                    fontSize: 14,
                                    height: 1.5,
                                  ),
                                  // underline: Container(
                                  //   height: 2,
                                  //   color: Colors.deepPurpleAccent,
                                  // ),
                                  onChanged: (String newValue) {
                                    setState(() {
                                      dropDownValue = newValue;
                                    });
                                  },
                                  items: countriesList
                                      .map<DropdownMenuItem<String>>(
                                          (String value) {
                                    return DropdownMenuItem<String>(
                                      value: value,
                                      child: Text(
                                        value,
                                        textAlign: TextAlign.right,
                                      ),
                                    );
                                  }).toList(),
                                )))),
    

@kf6gpe kf6gpe added the P2 Important issues not at the top of the work list label May 29, 2020
@tanpinquan
Copy link

tanpinquan commented Jun 4, 2020

Since I wanted to maintain a minimum distance from the top the screen instead of a fixed height, I modified diegodeveloper's custom_dropdown to accept a minimum offset value from the top of the screen.

Just download the dart file from link

Usage is the similar to diegodeveloper's

    import 'custom_dropdown.dart' as custom;

    Scaffold(
      appBar: AppBar(title: Text(widget.title)),
      body: Container(
          padding: EdgeInsets.fromLTRB(5, 5, 5, 5),
          child: Form(
            child: ListView(
              scrollDirection: Axis.vertical,
              children: <Widget>[
                //other widgets here
                custom.DropdownButtonFormField(
                  offsetAmount: 150.0,
                  items: this.dropDownItems
                ),
              ],
            ),
          )),
    );

Don't forget to add the alias also in your DropdownMenuItem like this :

 custom.DropdownMenuItem(
                child: Text("Sample Tex"),
                value: "any_value",
              ),

@Hixie Hixie removed this from the None. milestone Aug 17, 2020
@mahmedMostafa
Copy link

still open!!!

@lucasbiel7
Copy link

No solutions for this?

@yagnimurali
Copy link

Is there any estimation by when we can see a proper solution?

@bhavinwebdesk
Copy link

bhavinwebdesk commented Sep 10, 2020

I am able to solve it by changing the copy of DropDown and change this line to something like:
final double maxHeight = math.max(0.0, (constraints.maxHeight / 2) - 1.5 * _kMenuItemHeight);
It is a quick-fix for me but still, I am testing it.

@slagathor2094
Copy link

I can't believe this is still open

@gfb-47
Copy link

gfb-47 commented Oct 10, 2020

Having the same issue here..

@ggaj
Copy link

ggaj commented Oct 18, 2020

Some problem here...

😭

@TobiasHeidingsfeld
Copy link

Any ETA? How can it take 2 years to add a simple height when the community already added the code for it?

@yudi43
Copy link

yudi43 commented Nov 29, 2020

Flutter is getting a bad reputation because of such issues. It's been so long.

@PranDev
Copy link

PranDev commented Dec 14, 2020

Has there been any form of acknowledgement of this issue? As a new Flutter dev, Having to use custom components for such a simple issue isn't encouraging at all.

@diego-lipinski-de-castro

2 year anniversary of this issue

@2shrestha22
Copy link

I faced this issue a year ago, faced it again. But here, this issue is open for 2 years.

@AkshayKaneriya
Copy link

I am facing this issue, is this issue solved or not?

@YeungKC YeungKC self-assigned this Jan 17, 2021
@TahaTesser TahaTesser added the customer: crowd Affects or could affect many people, though not necessarily a specific customer. label Feb 1, 2021
@slagathor2094
Copy link

Are there any updates on this?

@YeungKC
Copy link
Member

YeungKC commented Feb 15, 2021

maybe this week.

@shihaohong
Copy link
Contributor

#76493 has a PR ready that should allow users to limit the size of the menu, if anybody wants to take a look and see

@Joan1211
Copy link

Joan1211 commented Mar 8, 2021

More than 2 years to wait for a simple feature.. From one of the most famous software development kit, it's strange that this kind of basic features are not included.

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
c: new feature Nothing broken; request for a new capability customer: crowd Affects or could affect many people, though not necessarily a specific customer. f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. P2 Important issues not at the top of the work list
Projects
None yet
Development

Successfully merging a pull request may close this issue.