You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix DropdownMenu isCollapsed decoration does not Reduce height (flutter#161427)
## Description
This PR fixes DropdownMenu arrow icon position when
`InputDecoration.isCollapsed` is set to true and
`InputDecoration.suffixConstraints` is set to a smaller value than the
min interactive height.
It makes it possible to use collapsed `DropdownMenu` such as:

_____
Before this PR and flutter#153089,
`InputDecoration.isCollapsed` had no impact on the `DropdownMenu` height
and there was no solution to reduce the height because its minimum
height is enforced by the `IconButton` (arrow down or up) which is part
of the `DropdownMenu`.
Since flutter#153089, the height can be
reduce with `InputDecoration.suffixIconConstraints` but it results in
the icon being misaligned:

After this PR:
When `InputDecoration.suffixIconConstraints` is used the icon is
correctly aligned:

<details><summary>Code sample</summary>
```dart
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@OverRide
Widget build(BuildContext context) {
return const MaterialApp(
title: 'Flutter Demo',
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@OverRide
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@OverRide
Widget build(BuildContext context) {
return const Scaffold(
body: Center(
child: Center(
child: DropdownMenu<String>(
dropdownMenuEntries: [
DropdownMenuEntry(label: 'Item 1', value: '1'),
DropdownMenuEntry(label: 'Item 2', value: '2'),
],
inputDecorationTheme: InputDecorationTheme(
contentPadding: EdgeInsets.fromLTRB(5, 0, 5, 0),
isCollapsed: true,
// Usable since flutter#153089.
suffixIconConstraints: BoxConstraints(minHeight: 24, maxHeight: 24),
filled: true,
),
),
),
),
);
}
}
```
</details>
## Related Issue
Fixes [DropdownMenu inputDecoration isCollapsed property does not reduce
vertical spacing](flutter#138691)
## Tests
Adds 2 tests.
0 commit comments