Skip to content

Take InputDecoration's densityOffset into account when determining the button size #370

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/dropdown_button2/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- Respect inputDecoration's borderRadius when barrierCoversButton is false.
- Support BorderRadiusDirectional for dropdown menu.
- Fix barrier when using TextDirection.rtl while barrierCoversButton set to false.
- Take InputDecoration's densityOffset into account when determining the button size.

## 3.0.0-beta.21

Expand Down
5 changes: 4 additions & 1 deletion packages/dropdown_button2/lib/src/dropdown_button2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -570,8 +570,11 @@ class _DropdownButton2State<T> extends State<DropdownButton2<T>> with WidgetsBin
// Return the contentPadding only if inputDecoration is defined.
if (widget._inputDecoration case final decoration?) {
final TextDirection? textDirection = Directionality.maybeOf(context);
// Use inputDecorationTheme.visualDensity when added (https://github.com/flutter/flutter/issues/166201#issuecomment-2774622584)
final Offset densityOffset = Theme.of(context).visualDensity.baseSizeAdjustment;
return (decoration.contentPadding ?? Theme.of(context).inputDecorationTheme.contentPadding)
?.resolve(textDirection);
?.add(EdgeInsets.symmetric(vertical: densityOffset.dy / 2))
.resolve(textDirection);
} else {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import 'test_app.dart';
void main() {
runGoldenTests(
'FormField Example',
// NOTE: InputDecorator's contentPadding.vertical is incorrect on desktop
// until https://github.com/flutter/flutter/issues/166201 is fixed
(WidgetTester tester, ViewVariant variant) async {
// GIVEN
await tester.pumpTestApp(const FormFieldExample());
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading