AhmedLSayed9 / dropdown_button2

Flutter's core Dropdown Button widget with steady dropdown menu and many other features.
https://pub.dev/packages/dropdown_button2
MIT License
264 stars 122 forks source link

Not possible to have label, text and dropdown values all aligned with OutlineInputBorder #265

Closed giordy16 closed 4 months ago

giordy16 commented 4 months ago

I want to implement a DropdownButtonFormField2 with an OutlineInputBorder border. This is the code:

    return DropdownButtonFormField2(
      items: values.map<DropdownMenuItem>((entity) {
        return DropdownMenuItem(
          value: entity,
          child: Text(
            entity.toString(),
          ),
        );
      }).toList(),
      onChanged: (value) {
        if (onItemSelected != null) {
          onItemSelected!(value);
        }
      },
      decoration: InputDecoration(
        label: Text(title),
        labelStyle: TextStyle(color: theme.colorScheme.secondary),
        errorBorder: formErrorBorder(context),
        focusedBorder: formFocusedBorder(context),
        enabledBorder: formEnabledBorder(context),
        focusedErrorBorder: formFocusedBorder(context),
      ),
      validator: isMandatory ? mandatoryFieldDynamic() : null,
      value: initialValue,
    );

And this is the result: Screenshot 2024-05-06 at 16 57 32

I would like to have "Liquidità" (the selected value of the dropdown) to be aligned with the label on the border and the other dropdown values, but I am playing with the different paddings and I can't achieve what I want.

Any suggestions?

AhmedLSayed9 commented 4 months ago

Check https://github.com/AhmedLSayed9/dropdown_button2/issues/237

giordy16 commented 4 months ago

thank you, this helped https://stackoverflow.com/a/77971775/14036990