From 97d0dce59f932069b598e1c3ce934c4812a59085 Mon Sep 17 00:00:00 2001 From: Hashem Date: Fri, 4 Sep 2026 21:18:09 +0100 Subject: [PATCH 1/2] [material_ui] Fix DropdownMenuFormField leading icon Apply the leadingIcon fallback for custom decorations, add regression coverage, and record the patch release changelog. --- .../material_ui/lib/src/dropdown_menu.dart | 6 +++++ ...2026_09_04_dropdown_menu_leading_icon.yaml | 3 +++ .../test/dropdown_menu_form_field_test.dart | 26 +++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 packages/material_ui/pending_changelogs/change_2026_09_04_dropdown_menu_leading_icon.yaml diff --git a/packages/material_ui/lib/src/dropdown_menu.dart b/packages/material_ui/lib/src/dropdown_menu.dart index bb1ad621c3a5..bf5db6134b2b 100644 --- a/packages/material_ui/lib/src/dropdown_menu.dart +++ b/packages/material_ui/lib/src/dropdown_menu.dart @@ -421,6 +421,9 @@ class DropdownMenu extends StatefulWidget { /// The builder function used to create the [InputDecoration] passed to the text field. /// + /// If the resulting [InputDecoration.prefixIcon] is null, [leadingIcon] is + /// assigned as the prefix icon. + /// /// If a value is provided for this property and the resulting [InputDecoration.suffixIcon] /// is null, a default [IconButton] is assigned as the suffix icon. This button's icon will /// use [trailingIcon] and [selectedTrailingIcon] if those are explicitly defined; otherwise, @@ -1266,6 +1269,9 @@ class _DropdownMenuState extends State> { final DropdownMenuDecorationBuilder decorationBuilder = widget.decorationBuilder ?? _buildDefaultDecoration; InputDecoration decoration = decorationBuilder(context, controller); + if (decoration.prefixIcon == null) { + decoration = decoration.copyWith(prefixIcon: widget.leadingIcon); + } // If no suffixIcon is provided, the default IconButton is used for convenience. if (decoration.suffixIcon == null) { decoration = decoration.copyWith( diff --git a/packages/material_ui/pending_changelogs/change_2026_09_04_dropdown_menu_leading_icon.yaml b/packages/material_ui/pending_changelogs/change_2026_09_04_dropdown_menu_leading_icon.yaml new file mode 100644 index 000000000000..c36748eb82ea --- /dev/null +++ b/packages/material_ui/pending_changelogs/change_2026_09_04_dropdown_menu_leading_icon.yaml @@ -0,0 +1,3 @@ +changelog: | + - Fixes `DropdownMenuFormField.leadingIcon` not being shown in the text field. +version: patch diff --git a/packages/material_ui/test/dropdown_menu_form_field_test.dart b/packages/material_ui/test/dropdown_menu_form_field_test.dart index 4f2a5c668c2e..0d367335084f 100644 --- a/packages/material_ui/test/dropdown_menu_form_field_test.dart +++ b/packages/material_ui/test/dropdown_menu_form_field_test.dart @@ -175,6 +175,32 @@ void main() { expect(dropdownMenu.leadingIcon, leadingIcon); }); + testWidgets('leadingIcon is shown in the text field prefix decoration', ( + WidgetTester tester, + ) async { + const Widget leadingIcon = Icon(Icons.check); + + await tester.pumpWidget( + MaterialApp( + home: Scaffold( + body: DropdownMenuFormField( + leadingIcon: leadingIcon, + dropdownMenuEntries: menuEntries, + ), + ), + ), + ); + + final TextField textField = tester.widget(find.byType(TextField)); + final Widget? prefixIcon = textField.decoration?.prefixIcon; + expect(prefixIcon, isNotNull); + final Finder prefixCheckIcon = find.descendant( + of: find.byWidget(prefixIcon!), + matching: find.byIcon(Icons.check), + ); + expect(prefixCheckIcon, findsOneWidget); + }); + testWidgets('Passes trailingIcon to underlying DropdownMenu', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( From 61300f48a1765cf48a5b52503e1bd60ed92b8ce6 Mon Sep 17 00:00:00 2001 From: Hashem Date: Fri, 4 Sep 2026 21:30:07 +0100 Subject: [PATCH 2/2] [material_ui] Avoid unnecessary decoration copy --- packages/material_ui/lib/src/dropdown_menu.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/material_ui/lib/src/dropdown_menu.dart b/packages/material_ui/lib/src/dropdown_menu.dart index bf5db6134b2b..22588f3d8fcf 100644 --- a/packages/material_ui/lib/src/dropdown_menu.dart +++ b/packages/material_ui/lib/src/dropdown_menu.dart @@ -1269,7 +1269,7 @@ class _DropdownMenuState extends State> { final DropdownMenuDecorationBuilder decorationBuilder = widget.decorationBuilder ?? _buildDefaultDecoration; InputDecoration decoration = decorationBuilder(context, controller); - if (decoration.prefixIcon == null) { + if (widget.leadingIcon != null && decoration.prefixIcon == null) { decoration = decoration.copyWith(prefixIcon: widget.leadingIcon); } // If no suffixIcon is provided, the default IconButton is used for convenience.