Skip to content

DropdownMenu crashes when provided menuStyle with small maximumSize #162356

@PurplePolyhedron

Description

@PurplePolyhedron

Steps to reproduce

set maximumSize property of menuStyle to be smaller than the DropdownMenu

Expected results

maximumSize property of menuStyle should be able to set the width of menu item smaller than the DropdownMenu

Actual results

DropdownMenu would overwrite the minimumSize property of menuStyle to the width of the Textfield, The widget would throw when trying to set the width to be smaller than Textfield.

Code sample

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

void main() {
  runApp(const DropApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Padding(
          padding: const EdgeInsets.all(32.0),
          child: DropdownMenu<String>(
            width: 200.0,
            dropdownMenuEntries: [
              DropdownMenuEntry(
                  value: "1", label: "one this is a long long long text"),
              DropdownMenuEntry(
                  value: "2", label: "two this is a long long long text"),
            ],
            menuStyle: MenuStyle(
              maximumSize: WidgetStatePropertyAll(Size(150.0, 100.0)),
            ),
          ),
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
The following assertion was thrown building _MenuPanel(dirty, dependencies:
[InheritedCupertinoTheme, _InheritedTheme, _LocalizationsScope-[GlobalKey#f400a]], state:
_MenuPanelState#b76a8):
BoxConstraints has non-normalized width constraints.
The offending constraints were:
  BoxConstraints(200.0<=w<=150.0, 0.0<=h<=100.0; NOT NORMALIZED)

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.27.3, on macOS 14.6.1 23G93 darwin-arm64, locale en-AU)
    • Flutter version 3.27.3 on channel stable at /Users/mainj/php/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision c519ee916e (7 days ago), 2025-01-21 10:32:23 -0800
    • Engine revision e672b006cb
    • Dart version 3.6.1
    • DevTools version 2.40.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: error messageError messages from the Flutter frameworkf: material designflutter/packages/flutter/material repository.found in release: 3.27Found to occur in 3.27found in release: 3.29Found to occur in 3.29frameworkflutter/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-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions