GithubHelp home page GithubHelp logo

Comments (11)

AhmedLSayed9 avatar AhmedLSayed9 commented on September 25, 2024

Check the decoration parameter of DropdownButtonFormField2 at Example 7, you've to disable the horizontal padding there.

from dropdown_button2.

FabienDvK avatar FabienDvK commented on September 25, 2024

from dropdown_button2.

AhmedLSayed9 avatar AhmedLSayed9 commented on September 25, 2024

Unfortunately, this doesn’t work with the prefixIcon 😕

Can you explain more please? Maybe a sample can help.

from dropdown_button2.

FabienDvK avatar FabienDvK commented on September 25, 2024

from dropdown_button2.

AhmedLSayed9 avatar AhmedLSayed9 commented on September 25, 2024

I mean a working sample that has zero horizontal padding at decoration parameter.

from dropdown_button2.

FabienDvK avatar FabienDvK commented on September 25, 2024

from dropdown_button2.

AhmedLSayed9 avatar AhmedLSayed9 commented on September 25, 2024

In InputDecoration of DropdownbuttonFormField2, there is no horizontal padding in the example I provided above. The issue is that the padding in MenuItemStyleData is passed to ButtonStyleData (when the value is selected and displayed).

On Fri, 9 Feb 2024 at 19:38, Ahmed Elsayed @.> wrote: I mean a working sample that has zero horizontal padding at decoration parameter. — Reply to this email directly, view it on GitHub <#237 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXOUCPBNALXMYY6OWACZVPLYSZUJFAVCNFSM6AAAAABDBNL4IGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZWGQZDGNJSHA . You are receiving this because you authored the thread.Message ID: @.>

Add contentPadding: EdgeInsets.zero to InputDecoration and start from there.

from dropdown_button2.

FabienDvK avatar FabienDvK commented on September 25, 2024

from dropdown_button2.

FabienDvK avatar FabienDvK commented on September 25, 2024

from dropdown_button2.

AhmedLSayed9 avatar AhmedLSayed9 commented on September 25, 2024

Alright, when you've null buttonWidth & dropdownWidth, all menu horizontal padding will be added to the button padding so that menu width adapts to max items width with padding properly.

The thing is that the padding will be added to the content of the form field without the prefixIcon. It's the same behavior as Flutter's form fields IIRC.

You have too much padding because the prefix icon has constraints. Updating your code with the following:

prefixIcon: Padding(
  padding: const EdgeInsetsDirectional.only(start: 30),
  child: const Icon(
    Icons.transgender_outlined,
    color: Colors.red,
  ),
),
prefixIconConstraints: const BoxConstraints(),

will align the prefix icon with the menu items properly, but will also include padding of 30 between the prefix and the button content which is expected as discussed above.

It's not a perfect solution i know.
I'm thinking of adding a property to ButtonStyleData to control whether to include menu padding into the button or not (will default to true). When it's set to false, you've to handle the padding at the button on your own and also the menu can't dynamically match button's size when both buttonWidth & dropdownWidth are null (Note to myself: You've to add menu padding to the menu size in that case).

from dropdown_button2.

FabienDvK avatar FabienDvK commented on September 25, 2024

from dropdown_button2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.