Skip to content

[material/dropdown_menu.dart] Dropdown body render object accesses this.constraints from computeDryLayout #176501

@davidhicks980

Description

@davidhicks980

Steps to reproduce

  1. Run example

Expected results

Does not throw

Actual results

Throws "Bad state: A RenderObject does not have any constraints before it has been laid out."

Code sample

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

import 'package:flutter/rendering.dart';

void main(List<String> args) {
  runApp(
    const MaterialApp(
      home: Scaffold(
        body: Center(
          child: _TestDryLayout(
            child: DropdownMenu<int>(
              dropdownMenuEntries: <DropdownMenuEntry<int>>[
                DropdownMenuEntry<int>(value: 1, label: 'One'),
                DropdownMenuEntry<int>(value: 2, label: 'Two'),
              ],
            ),
          ),
        ),
      ),
    ),
  );
}

class _TestDryLayout extends SingleChildRenderObjectWidget {
  const _TestDryLayout({super.child});

  @override
  RenderObject createRenderObject(BuildContext context) {
    return _RenderTestDryLayout();
  }
}

class _RenderTestDryLayout extends RenderProxyBox {
  @override
  void performLayout() {
    if (child == null) {
      size = constraints.smallest;
      return;
    }

    child!.getDryLayout(constraints);
    child!.layout(constraints, parentUsesSize: true);
    size = child!.size;
  }
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[✓] Flutter (Channel master, 3.37.0-1.0.pre-400, on macOS 15.5 24F74 darwin-arm64, locale
    en-US) [2.0s]
    • Flutter version 3.37.0-1.0.pre-400 on channel master at
      /Users/davidhicks/fvm/versions/master
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5c0c9e9e9a (10 hours ago), 2025-10-03 11:49:25 -0400
    • Engine revision dca709fbbf
    • Dart version 3.10.0 (build 3.10.0-278.0.dev)
    • DevTools version 2.50.0
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop,
      enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets,
      omit-legacy-version-file, enable-lldb-debugging

[!] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [3.0s]
    • Android SDK at /Users/davidhicks/Library/Android/sdk
    • Emulator version 35.4.9.0 (build_id 13025442) (CL:N/A)
    • Platform android-36, build-tools 35.0.0
    • ANDROID_HOME = /Users/davidhicks/Library/Android/sdk
    • Java binary at: /Library/Java/JavaVirtualMachines/jdk-17.0.2.jdk/Contents/Home/bin/java
      This JDK is specified in your Flutter configuration.
      To change the current JDK, run: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version Java(TM) SE Runtime Environment (build 17.0.2+8-LTS-86)
    ! Some Android licenses not accepted. To resolve this, run: flutter doctor
      --android-licenses

[✓] Xcode - develop for iOS and macOS (Xcode 16.4) [1,590ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16F6
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web [9ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Connected device (2 available) [6.6s]
    • macOS (desktop) • macos  • darwin-arm64   • macOS 15.5 24F74 darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 140.0.7339.214
    ! Error: Browsing on the local area network for David’s iPhone. Ensure the device is
      unlocked and attached with a cable or associated with the same local area network as this
      Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources [251ms]
    • All expected network resources are available.

! Doctor found issues in 1 category.

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.35Found to occur in 3.35found in release: 3.37Found to occur in 3.37frameworkflutter/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