Skip to content

DropdownMenu item icon and DropdownMenu.leadingIcon are not aligned horizontally #161668

@bleroux

Description

@bleroux

Steps to reproduce

  1. Run the given code sample.
  2. Tap on the dropdown to open the menu.
  3. Observe the first item icon alignment.

Expected results

The item icon is aligned with the DropdownMenu leading icon:

Image

Actual results

The item icon is not aligned with the DropdownMenu leading icon:

Image

Code sample

Code sample
import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return Transform.scale(
      scale: 1.0,
      child: MaterialApp(
        title: 'Material App',
        theme: ThemeData.dark().copyWith(visualDensity: VisualDensity.standard),
        home: const Home(),
      ),
    );
  }
}

class Home extends StatelessWidget {
  const Home({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Container(
          padding: const EdgeInsets.all(16.0),
          width: 400,
          child: Column(
            mainAxisSize: MainAxisSize.min,
            spacing: 8.0,
            children: [
              Container(
                height: 16.0,
                color: Colors.grey[700],
                child: Row(
                  children: [
                    Container(color: Colors.deepOrangeAccent, width: 12.0),
                    Container(color: Colors.orangeAccent, width: 24.0),
                    Container(color: Colors.deepOrangeAccent, width: 12.0),
                    Container(color: Colors.yellow, width: 4.0),
                  ],
                ),
              ),
              TextField(
                controller: TextEditingController(text: 'TextField with prefix icon'),
                decoration: const InputDecoration(
                  filled: true,
                  labelText: 'For reference',
                  prefixIcon: Icon(Icons.check_box_rounded),
                ),
              ),
              Container(
                height: 16.0,
                color: Colors.grey[700],
                child: Row(
                  children: [
                    Container(color: Colors.deepOrangeAccent, width: 12.0),
                    Container(color: Colors.orangeAccent, width: 24.0),
                    Container(color: Colors.deepOrangeAccent, width: 12.0),
                    Container(color: Colors.yellow, width: 4.0),
                  ],
                ),
              ),
              const DropdownMenu<String>(
                expandedInsets: EdgeInsets.zero,
                leadingIcon: Icon(Icons.check_box_rounded),
                dropdownMenuEntries: [
                  DropdownMenuEntry(
                    label: 'Item with leading icon',
                    value: '1',
                    leadingIcon: Icon(Icons.check_box_rounded),
                  ),
                  DropdownMenuEntry(label: 'Item 2', value: '2'),
                ],
                label: Text('DropdownMenu with icon'),
                inputDecorationTheme: InputDecorationTheme(filled: true),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

Screenshots or Video

No response

Logs

No response

Flutter Doctor output

Doctor output
Flutter (Channel master, 3.28.0-2.0.pre.38753, on Ubuntu 24.04.1 LTS 6.8.0-51-generic, locale fr_FR.UTF-8)

Metadata

Metadata

Assignees

Labels

a: text inputEntering text in a text field or keyboard related problemsc: regressionIt was better in the past than it is nowf: material designflutter/packages/flutter/material repository.found in release: 3.28Found to occur in 3.28frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionteam-text-inputOwned by Text Input team

Type

No type

Projects

Status

Done (PR merged)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions