Commit 44ff2f5
authored
Fix DropdownMenu isCollapsed decoration does not Reduce height (#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/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/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/flutter#153089.
suffixIconConstraints: BoxConstraints(minHeight: 24, maxHeight: 24),
filled: true,
),
),
),
),
);
}
}
```
</details>
## Related Issue
Fixes [DropdownMenu inputDecoration isCollapsed property does not reduce
vertical spacing](flutter/flutter#138691)
## Tests
Adds 2 tests.1 parent 1e79b65 commit 44ff2f5
File tree
2 files changed
+71
-1
lines changed- packages/flutter
- lib/src/material
- test/material
2 files changed
+71
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
965 | 965 | | |
966 | 966 | | |
967 | 967 | | |
| 968 | + | |
968 | 969 | | |
969 | | - | |
| 970 | + | |
970 | 971 | | |
971 | 972 | | |
| 973 | + | |
| 974 | + | |
972 | 975 | | |
973 | 976 | | |
974 | 977 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| |||
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
| 60 | + | |
59 | 61 | | |
60 | 62 | | |
61 | 63 | | |
| |||
1172 | 1174 | | |
1173 | 1175 | | |
1174 | 1176 | | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
1175 | 1242 | | |
1176 | 1243 | | |
1177 | 1244 | | |
| |||
0 commit comments