Taha Tesser
b3de00ad54
Fix DropdownMenu with expandedInsets always aligned on top (#156214)
Fixes [DropdownMenu can not be center aligned when using expandedInsets
](https://github.com/flutter/flutter/issues/155581)
### Code sample
<details>
<summary>expand to view the 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) {
final List<DropdownMenuEntry<ShortMenu>> shortMenuItems =
<DropdownMenuEntry<ShortMenu>>[];
for (final ShortMenu value in ShortMenu.values) {
final DropdownMenuEntry<ShortMenu> entry =
DropdownMenuEntry<ShortMenu>(value: value, label: value.label);
shortMenuItems.add(entry);
}
return MaterialApp(
home: Scaffold(
body: Row(
children: <Widget>[
Expanded(
child: Center(
child: DropdownMenu<ShortMenu>(
expandedInsets: const EdgeInsets.all(16),
initialSelection: ShortMenu.item0,
dropdownMenuEntries: shortMenuItems,
label: const Text('With expandedInsets'),
),
),
),
Expanded(
child: Center(
child: DropdownMenu<ShortMenu>(
initialSelection: ShortMenu.item0,
dropdownMenuEntries: shortMenuItems,
label: const Text('Without expandedInsets'),
),
),
),
],
),
),
);
}
}
enum ShortMenu {
item0('Menu 0'),
item1('Menu 1'),
item2('Menu 2');
const ShortMenu(this.label);
final String label;
}
```
</details>
### Before
(`DropdownMenu` without `expandedInsets` cannot be centered)
<img width="770" alt="Screenshot 2024-10-04 at 14 13 58" src="https://github.com/user-attachments/assets/c7520c12-d16a-4867-8fae-38b75dbc4225">
### After
(`DropdownMenu` with `expandedInsets` be centered)
<img width="770" alt="Screenshot 2024-10-04 at 14 13 49" src="https://github.com/user-attachments/assets/82e0b81e-5c85-4e59-99b8-df329459773b">
2024-10-07 13:43:22 +00:00
..
2024-04-09 19:35:07 +00:00
2024-09-04 00:20:16 +00:00
2024-09-13 08:09:13 +00:00
2024-09-10 15:32:40 -07:00
2024-09-06 21:10:35 +00:00
2024-09-06 21:10:35 +00:00
2024-09-10 15:32:40 -07:00
2024-01-31 16:13:17 +00:00
2024-09-10 15:32:40 -07:00
2024-01-24 16:49:18 +00:00
2024-07-08 21:01:56 +00:00
2024-04-25 10:32:45 -07:00
2024-09-10 15:32:40 -07:00
2024-09-04 18:35:23 +00:00
2024-09-10 15:32:40 -07:00
2024-09-10 15:32:40 -07:00
2024-02-28 13:55:50 -08:00
2024-06-21 14:48:41 -07:00
2024-09-10 15:32:40 -07:00
2024-08-28 18:40:05 +00:00
2024-09-10 15:32:40 -07:00
2024-09-10 15:32:40 -07:00
2024-08-22 03:30:22 +00:00
2024-06-12 20:05:10 +00:00
2024-10-04 18:59:05 +00:00
2024-10-02 00:21:23 +00:00
2024-10-06 14:49:20 +00:00
2024-10-02 22:47:18 +00:00
2024-09-10 15:32:40 -07:00
2024-09-04 00:20:16 +00:00
2024-09-10 15:32:40 -07:00
2024-09-04 00:20:16 +00:00
2024-06-20 06:44:11 -07:00
2024-09-04 16:27:48 +00:00
2024-08-15 19:02:23 +00:00
2024-09-10 15:32:40 -07:00
2024-10-02 23:48:13 +00:00
2024-09-10 15:32:40 -07:00
2024-09-06 21:10:35 +00:00
2024-09-06 19:13:17 +00:00
2024-10-02 23:48:13 +00:00
2024-09-10 15:32:40 -07:00
2024-07-08 21:01:56 +00:00
2024-08-29 02:23:19 +00:00
2024-09-10 15:32:40 -07:00
2024-04-08 20:47:13 +00:00
2024-10-07 13:43:22 +00:00
2024-02-28 13:55:50 -08:00
2024-07-31 11:22:26 +00:00
2024-09-18 00:19:40 +00:00
2024-02-28 13:55:50 -08:00
2024-06-12 20:05:10 +00:00
2024-06-12 20:05:10 +00:00
2024-09-10 15:32:40 -07:00
2024-09-10 15:32:40 -07:00
2024-09-18 00:19:40 +00:00
2024-02-28 13:55:50 -08:00
2024-09-04 00:20:16 +00:00
2024-01-24 16:13:26 +00:00
2024-07-31 23:35:24 +00:00
2024-06-12 20:05:10 +00:00
2024-09-10 15:32:40 -07:00
2024-08-29 07:02:23 +00:00
2024-04-24 11:56:32 +00:00
2024-07-15 07:09:09 +00:00
2024-04-09 19:35:07 +00:00
2024-02-07 02:44:21 +00:00
2024-04-09 19:35:07 +00:00
2024-06-12 20:05:10 +00:00
2024-06-13 19:28:21 +00:00
2024-07-08 21:01:56 +00:00
2024-09-26 22:08:05 +00:00
2024-09-10 15:32:40 -07:00
2024-09-10 15:32:40 -07:00
2024-02-21 08:59:24 +00:00
2024-04-03 15:49:38 -07:00
2024-06-12 20:05:10 +00:00
2024-09-10 15:32:40 -07:00
2024-09-10 15:32:40 -07:00
2024-10-03 20:09:19 +00:00
2024-07-11 19:25:18 +00:00
2024-03-11 23:04:57 +00:00
2024-06-12 20:05:10 +00:00
2024-09-10 15:32:40 -07:00
2024-09-11 23:59:53 +00:00
2024-09-10 15:32:40 -07:00
2024-08-22 07:25:34 +00:00
2024-09-10 15:32:40 -07:00
2024-09-18 00:19:40 +00:00
2024-02-28 13:55:50 -08:00
2024-05-28 16:35:29 -07:00
2024-08-28 18:40:05 +00:00
2024-09-09 21:49:07 +00:00
2024-05-28 16:35:29 -07:00
2024-09-11 23:59:53 +00:00
2024-09-10 15:32:40 -07:00
2024-03-27 16:43:10 -07:00
2024-09-11 23:59:53 +00:00
2024-07-30 20:38:06 +00:00
2024-07-24 22:47:55 +00:00
2024-09-10 15:32:40 -07:00
2024-09-10 15:32:40 -07:00
2024-06-12 20:05:10 +00:00
2024-08-30 17:50:08 +00:00
2024-07-30 20:38:06 +00:00
2024-07-31 23:35:24 +00:00
2024-03-13 16:31:50 +00:00
2024-03-19 17:58:13 +00:00
2024-10-04 18:59:05 +00:00
2024-09-10 15:32:40 -07:00
2024-10-03 18:14:51 +00:00
2024-09-10 15:32:40 -07:00
2024-09-18 00:19:40 +00:00
2024-04-24 11:56:32 +00:00
2024-04-24 09:06:17 -07:00
2024-09-10 15:32:40 -07:00
2024-09-10 15:32:40 -07:00
2024-09-10 15:32:40 -07:00
2024-09-10 15:32:40 -07:00
2024-04-15 16:06:07 +00:00
2024-09-11 23:59:53 +00:00
2024-07-30 20:38:06 +00:00
2024-07-16 20:25:09 +00:00
2024-09-10 15:32:40 -07:00
2024-10-01 20:13:52 +00:00
2024-09-08 03:57:20 +00:00
2024-04-17 07:59:07 +00:00
2024-09-18 00:19:40 +00:00
2024-02-28 13:55:50 -08:00
2024-09-10 15:32:40 -07:00
2024-06-18 17:52:21 +00:00
2024-09-10 15:32:40 -07:00
2024-03-01 06:40:47 +00:00
2024-09-04 16:27:48 +00:00
2024-10-04 18:59:05 +00:00
2024-02-28 13:55:50 -08:00
2024-08-23 17:15:36 +00:00
2024-09-10 15:32:40 -07:00
2024-07-11 16:51:35 +00:00
2024-09-10 15:32:40 -07:00
2024-09-10 15:32:40 -07:00
2024-05-18 10:41:56 -07:00
2024-09-10 15:32:40 -07:00
2024-03-28 01:20:55 +00:00
2024-06-12 20:05:10 +00:00
2024-02-21 00:34:11 +00:00