mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Add DropdownMenuFormField.decorationBuilder (#178640)
## Description This PR adds `DropdownMenuFormField.decorationBuilder` and passes it to the underlying `DropdownMenu`. ## Related Issue Follow-up to https://github.com/flutter/flutter/pull/176264 which added `DropdownMenu.decorationBuilder`. ## Tests - Adds 1 test.
This commit is contained in:
parent
2805900c57
commit
4b33f98a01
@ -50,6 +50,7 @@ class DropdownMenuFormField<T extends Object> extends FormField<T> {
|
||||
TextAlign textAlign = TextAlign.start,
|
||||
// TODO(bleroux): Clean this up once `InputDecorationTheme` is fully normalized.
|
||||
Object? inputDecorationTheme,
|
||||
DropdownMenuDecorationBuilder? decorationBuilder,
|
||||
MenuStyle? menuStyle,
|
||||
this.controller,
|
||||
T? initialSelection,
|
||||
@ -95,6 +96,7 @@ class DropdownMenuFormField<T extends Object> extends FormField<T> {
|
||||
textStyle: textStyle,
|
||||
textAlign: textAlign,
|
||||
inputDecorationTheme: inputDecorationTheme,
|
||||
decorationBuilder: decorationBuilder,
|
||||
menuStyle: menuStyle,
|
||||
controller: state.textFieldController,
|
||||
initialSelection: state.value,
|
||||
|
||||
@ -472,6 +472,36 @@ void main() {
|
||||
expect(dropdownMenu.inputDecorationTheme, inputDecorationTheme);
|
||||
});
|
||||
|
||||
testWidgets('Passes decorationBuilder to underlying DropdownMenu', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(body: DropdownMenuFormField<MenuItem>(dropdownMenuEntries: menuEntries)),
|
||||
),
|
||||
);
|
||||
|
||||
// Check default value.
|
||||
DropdownMenu<MenuItem> dropdownMenu = tester.widget(find.byType(DropdownMenu<MenuItem>));
|
||||
expect(dropdownMenu.decorationBuilder, null);
|
||||
|
||||
InputDecoration buildDecoration(BuildContext context, MenuController controller) {
|
||||
return const InputDecoration(labelText: 'labelText');
|
||||
}
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: DropdownMenuFormField<MenuItem>(
|
||||
decorationBuilder: buildDecoration,
|
||||
dropdownMenuEntries: menuEntries,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
dropdownMenu = tester.widget(find.byType(DropdownMenu<MenuItem>));
|
||||
expect(dropdownMenu.decorationBuilder, buildDecoration);
|
||||
});
|
||||
|
||||
testWidgets('Passes menuStyle to underlying DropdownMenu', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user