Qun Cheng
12acff81c7
DropdownMenu can be expanded to its parent size (#129753)
Fixes #125199
This PR is to add a new property `expandedInsets` so that the `DropdownMenu` can be expandable and has some margins around.
<details><summary>Example: Setting `expandedInsets` to `EdgeInsets.zero`</summary>
```dart
import 'package:flutter/material.dart';
void main() => runApp(const DropdownMenuExample());
class DropdownMenuExample extends StatefulWidget {
const DropdownMenuExample({super.key});
@override
State<DropdownMenuExample> createState() => _DropdownMenuExampleState();
}
class _DropdownMenuExampleState extends State<DropdownMenuExample> {
final TextEditingController colorController = TextEditingController();
ColorLabel? selectedColor;
@override
Widget build(BuildContext context) {
final List<DropdownMenuEntry<ColorLabel>> colorEntries = <DropdownMenuEntry<ColorLabel>>[];
for (final ColorLabel color in ColorLabel.values) {
colorEntries.add(
DropdownMenuEntry<ColorLabel>(value: color, label: color.label, enabled: color.label != 'Grey'),
);
}
return MaterialApp(
theme: ThemeData(
useMaterial3: true,
colorSchemeSeed: Colors.green,
),
home: Scaffold(
body: Center(
child: Container(
width: 500,
height: 500,
color: Colors.orange,
child: DropdownMenu<ColorLabel>(
expandedInsets: EdgeInsets.zero,
inputDecorationTheme: const InputDecorationTheme(
filled: true,
fillColor: Colors.white,
border: OutlineInputBorder(),
),
controller: colorController,
dropdownMenuEntries: colorEntries,
onSelected: (ColorLabel? color) {
setState(() {
selectedColor = color;
});
},
// expandedInsets: EdgeInsets.only(left: 35.0, right: 20.0, top: 80),
),
),
),
),
);
}
}
enum ColorLabel {
blue('Blue', Colors.blue),
pink('Pink', Colors.pink),
green('Green', Colors.green),
yellow('Yellow', Colors.yellow),
grey('Grey', Colors.grey);
const ColorLabel(this.label, this.color);
final String label;
final Color color;
}
```
<img width="500" alt="Screenshot 2023-06-28 at 11 33 20 PM" src="https://github.com/flutter/flutter/assets/36861262/e703f8a2-6e7c-45a0-86cf-d96da6dc157a">
</details>
2023-07-11 17:08:07 +00:00
..
2023-06-13 21:21:13 +00:00
2023-06-19 22:03:26 +00:00
2023-05-16 21:38:23 +00:00
2023-07-06 08:51:06 -07:00
2023-06-13 09:01:05 -07:00
2023-06-13 09:01:05 -07:00
2023-06-13 21:21:13 +00:00
2023-06-13 21:21:13 +00:00
2023-07-07 10:25:35 -07:00
2023-05-15 11:07:30 +02:00
2023-05-26 00:09:51 +00:00
2023-06-13 21:21:13 +00:00
2023-06-13 21:21:13 +00:00
2023-06-13 21:21:13 +00:00
2023-06-13 21:21:13 +00:00
2023-06-13 21:21:13 +00:00
2023-06-13 21:21:13 +00:00
2023-06-15 20:13:07 +00:00
2023-06-09 08:04:07 +00:00
2023-06-13 08:58:11 -07:00
2023-06-13 21:21:13 +00:00
2023-06-13 08:58:11 -07:00
2023-06-26 21:02:58 +00:00
2023-06-19 22:03:26 +00:00
2023-06-19 22:03:26 +00:00
2023-06-13 21:21:13 +00:00
2023-05-19 00:26:53 +00:00
2023-06-13 21:21:13 +00:00
2023-05-16 21:44:24 +00:00
2023-06-15 20:13:07 +00:00
2023-06-28 08:51:53 -07:00
2023-06-13 21:21:13 +00:00
2023-06-07 03:02:55 +00:00
2023-06-13 09:01:05 -07:00
2023-06-13 21:21:13 +00:00
2023-06-13 21:21:13 +00:00
2023-06-13 21:21:13 +00:00
2023-06-13 21:21:13 +00:00
2023-06-13 08:58:11 -07:00
2023-07-11 17:08:07 +00:00
2023-06-13 21:21:13 +00:00
2023-06-12 09:11:34 -07:00
2023-06-09 06:57:21 -07:00
2023-06-13 21:21:13 +00:00
2023-06-13 21:21:13 +00:00
2023-06-13 21:21:13 +00:00
2023-07-11 08:47:11 +00:00
2023-06-12 09:11:34 -07:00
2023-06-19 22:03:26 +00:00
2023-06-13 21:21:13 +00:00
2023-06-28 15:33:51 +00:00
2023-06-12 09:11:34 -07:00
2023-06-12 09:11:34 -07:00
2023-06-09 06:57:21 -07:00
2023-05-08 09:11:23 +00:00
2023-06-14 16:09:27 -07:00
2023-06-13 21:21:13 +00:00
2023-06-13 21:21:13 +00:00
2023-06-14 16:09:27 -07:00
2023-06-13 21:21:13 +00:00
2023-06-13 21:21:13 +00:00
2023-06-19 22:03:26 +00:00
2023-06-28 16:31:51 -07:00
2023-06-13 21:21:13 +00:00
2023-06-13 21:21:13 +00:00
2023-07-06 08:51:06 -07:00
2023-06-12 09:11:34 -07:00
2023-06-14 16:09:27 -07:00
2023-07-06 00:09:01 +00:00
2023-06-13 21:21:13 +00:00
2023-06-13 21:21:13 +00:00
2023-06-13 21:21:13 +00:00
2023-07-05 16:58:28 -07:00
2023-06-13 08:58:11 -07:00
2023-06-30 08:58:14 +00:00
2023-06-08 13:32:27 -07:00
2023-06-13 08:58:11 -07:00
2023-06-12 09:11:34 -07:00
2023-06-09 06:57:21 -07:00
2023-06-14 16:09:27 -07:00
2023-07-07 16:39:08 +00:00
2023-06-13 21:21:13 +00:00
2023-06-13 21:21:13 +00:00
2023-06-13 21:21:13 +00:00
2023-06-14 16:09:27 -07:00
2023-06-29 15:55:15 +00:00
2023-06-30 18:06:25 +00:00
2023-06-13 21:21:13 +00:00
2023-06-12 09:11:34 -07:00
2023-06-13 21:21:13 +00:00
2023-05-30 17:28:19 +00:00
2023-06-22 17:00:58 +00:00
2023-06-13 21:21:13 +00:00
2023-06-13 21:21:13 +00:00
2023-06-22 21:20:41 +00:00
2023-07-06 17:52:58 +00:00
2023-06-09 11:06:21 -07:00
2023-06-13 21:21:13 +00:00
2023-06-22 21:20:40 +00:00
2023-06-13 21:21:13 +00:00
2023-06-14 16:09:27 -07:00
2023-06-13 08:58:11 -07:00
2023-06-20 09:04:41 -07:00
2023-06-30 09:05:48 +00:00
2023-06-30 18:06:23 +00:00
2023-06-30 16:29:02 -07:00
2023-06-22 22:34:06 +00:00
2023-06-22 22:34:06 +00:00
2023-06-12 09:11:34 -07:00
2023-06-09 06:57:21 -07:00
2023-07-06 08:51:06 -07:00
2023-06-13 21:21:13 +00:00
2023-06-13 21:21:13 +00:00
2023-06-13 08:58:11 -07:00
2023-06-13 21:21:13 +00:00
2023-06-13 08:58:11 -07:00
2023-06-13 08:58:11 -07:00
2023-06-13 08:58:11 -07:00
2023-06-13 08:58:11 -07:00
2023-06-12 09:11:34 -07:00
2023-06-21 02:40:48 +00:00
2023-06-16 16:16:36 +00:00
2023-05-30 06:15:28 +00:00