Skip to content

feat(dropdown): add optional border to the dropdown panel - #228

Open
welingtonfidelis wants to merge 1 commit into
oi-narendra:mainfrom
welingtonfidelis:feat/dropdown-panel-border
Open

welingtonfidelis wants to merge 1 commit into
oi-narendra:mainfrom
welingtonfidelis:feat/dropdown-panel-border

Conversation

@welingtonfidelis

Copy link
Copy Markdown

What

Adds DropdownDecoration.border, an optional BorderSide drawn around the
dropdown panel.

Why

The panel is separated from whatever is behind it by elevation alone. That
works while the two differ in colour, and stops working when they do not — a
white panel over white cards reads as a single surface. Raising the elevation
does not help, because what is missing is an edge, not a stronger shadow.

There is no way to get one today: the panel is a Material(elevation, borderRadius, color) built inside the package, and DropdownDecoration
exposes neither shape nor a border.

How

border defaults to null, so every existing panel renders exactly as before.

Material asserts that shape and borderRadius are never both set, so the
radius travels inside a RoundedRectangleBorder whenever a border is given,
and the plain borderRadius path is kept otherwise.

MultiDropdown<String>(
  items: items,
  dropdownDecoration: const DropdownDecoration(
    backgroundColor: Colors.white,
    border: BorderSide(color: Color(0xFFE5E7EB)),
  ),
)

Tests

test/panel_border_test.dart covers the three states: an outline is drawn when
a border is given, the radius survives the move into the shape, and the
borderRadius path is untouched when no border is given.

The middle one guards the actual risk of this change: dropping the radius while
moving it into the shape would square off every rounded panel that adopts a
border, and nothing else would catch it.

test/decoration_test.dart gets the two matching unit assertions.

Full suite: 156 tests passing, flutter analyze clean.

The panel is separated from the content behind it by elevation alone.
That is enough while the two differ in colour, and not enough when they
do not: a white panel over white cards reads as one surface, and raising
the elevation does not fix it because the shadow is what is being missed,
not what is being seen.

`DropdownDecoration.border` takes a `BorderSide` and defaults to null, so
every existing panel renders exactly as before.

Material asserts that `shape` and `borderRadius` are never both set, so
the radius travels inside the `RoundedRectangleBorder` whenever a border
is given, and the plain `borderRadius` path is kept otherwise. A test
covers that the radius survives the move — dropping it there would square
off every rounded panel that adopts a border.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant