diff --git a/packages/material_ui/lib/src/dropdown_menu.dart b/packages/material_ui/lib/src/dropdown_menu.dart index bb1ad621c3a5..22588f3d8fcf 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 (widget.leadingIcon != null && 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(