Skip to content

DropdownMenu crashes when provided menuStyle with small maximumSize #162356

Closed

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

Activity

  1. danagbemava-nc commented on Jan 29, 2025

    @danagbemava-nc
    Member

    Reproducible using the code sample provided above.

    flutter doctor -v
    [✓] Flutter (Channel stable, 3.27.3, on macOS 15.1.1 24B91 darwin-arm64, locale en-US)
        • Flutter version 3.27.3 on channel stable at /Users/deanli/dev/stable
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision c519ee916e (8 days ago), 2025-01-21 10:32:23 -0800
        • Engine revision e672b006cb
        • Dart version 3.6.1
        • DevTools version 2.40.2
    
    [!] Flutter (Channel master, 3.29.0-1.0.pre.143, on macOS 15.1.1 24B91 darwin-arm64, locale en-US) [7.1s]
        • Flutter version 3.29.0-1.0.pre.143 on channel master at /Users/deanli/dev/master
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 3905156860 (6 hours ago), 2025-01-28 18:09:42 -0800
        • Engine revision 3905156860
        • Dart version 3.8.0 (build 3.8.0-24.0.dev)
        • DevTools version 2.42.0
    
  2. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    p: material_uimaterial_ui package in flutter/packages
    a: error messageError messages from the Flutter framework
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    team-designOwned by Design Languages team
    and removed
    in triagePresently being triaged by the triage team
    on Jan 29, 2025
  3. added a commit that references this issue on Feb 13, 2025
    4aafcce
  4. github-actions commented on Feb 28, 2025

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  5. locked as resolved and limited conversation to collaborators on Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: error messageError messages from the Flutter frameworkfound 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 onp: material_uimaterial_ui package in flutter/packagesr: 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