Skip to content

DropdownButtonFormField triggers assertion when nested in InputDecorator #176696

@davide-sys

Description

@davide-sys

Steps to reproduce

Create a DropdownButtonFormField within an InputDecorator: everything works fine :)
Create a DropdownButtonFormField with empty items within an InputDecorator: everything crashes :(

Expected results

I Expect to use DropdownButtonFormField inside another InputDecorator even with empty items.

Actual results

Crashes, see logs below

Code sample

Code sample
InputDecorator(
      decoration: InputDecoration(labelText: 'Dropdowns:'),
      child: DropdownButtonFormField<String?>(
        decoration: InputDecoration(labelText: 'Dropdown 1'),
        items: [],
        onChanged: (_) {},
      ),
    );

Screenshots or Video

Screenshots / Video demonstration

Not much to see

Logs

Logs
======== Exception caught by rendering library =====================================================
The following assertion was thrown during performLayout():
RenderBox.size accessed beyond the scope of resize, layout, or permitted parent access. RenderBox can always access its own size, otherwise, the only object that is allowed to read RenderBox.size is its parent, if they have said they will. It you hit this assert trying to access a child's size, pass "parentUsesSize: true" to that child's layout() in RenderConstrainedBox.performLayout.
'package:flutter/src/rendering/box.dart':
Failed assertion: line 2267 pos 11: 'sizeAccessAllowed'


Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=02_bug.yml

The relevant error-causing widget was: 
  InputDecorator InputDecorator:file:///.../lib/my_form.dart:78:12
When the exception was thrown, this was the stack: 
#2      RenderBox.size.<anonymous closure> (package:flutter/src/rendering/box.dart:2267:11)
#3      RenderBox.size (package:flutter/src/rendering/box.dart:2301:6)
#4      _RenderDecoration.computeDistanceToActualBaseline (package:flutter/src/material/input_decorator.dart:1323:63)
#5      RenderBox.getDistanceToActualBaseline.<anonymous closure> (package:flutter/src/rendering/box.dart:2517:26)
#6      _Baseline.memoize.ifAbsent (package:flutter/src/rendering/box.dart:1088:42)
#7      _LinkedHashMapMixin.putIfAbsent (dart:_compact_hash:674:23)
#8      _Baseline.memoize (package:flutter/src/rendering/box.dart:1089:18)
#9      RenderBox._computeWithTimeline (package:flutter/src/rendering/box.dart:1620:32)
[205 more...]
(elided 5 frames from class _AssertionError, class _Timer, and dart:async-patch)
The following RenderObject was being processed when the exception was fired: _RenderDecoration#d6256 relayoutBoundary=up12 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...  needs compositing
...  parentData: offset=Offset(0.0, 12.0) (can use size)
...  constraints: BoxConstraints(w=392.0, 0.0<=h<=Infinity)
...  size: MISSING
RenderObject: _RenderDecoration#d6256 relayoutBoundary=up12 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
  needs compositing
  parentData: offset=Offset(0.0, 12.0) (can use size)
  constraints: BoxConstraints(w=392.0, 0.0<=h<=Infinity)
  size: MISSING
...  input: RenderSemanticsAnnotations#4dad1 relayoutBoundary=up13 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...    needs compositing
...    parentData: offset=Offset(0.0, 0.0) (can use size)
...    constraints: BoxConstraints(w=360.0, 0.0<=h<=Infinity)
...    size: Size(360.0, 48.0)
...    child: RenderSemanticsAnnotations#7e79f relayoutBoundary=up14 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...      needs compositing
...      parentData: <none> (can use size)
...      constraints: BoxConstraints(w=360.0, 0.0<=h<=Infinity)
...      size: Size(360.0, 48.0)
...      child: RenderSemanticsAnnotations#c3828 relayoutBoundary=up15 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...        needs compositing
...        parentData: <none> (can use size)
...        constraints: BoxConstraints(w=360.0, 0.0<=h<=Infinity)
...        size: Size(360.0, 48.0)
...        child: RenderSemanticsAnnotations#d3e6b relayoutBoundary=up16 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...          needs compositing
...          parentData: <none> (can use size)
...          constraints: BoxConstraints(w=360.0, 0.0<=h<=Infinity)
...          size: Size(360.0, 48.0)
...  label: RenderTransform#8901f relayoutBoundary=up13 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...    needs compositing
...    parentData: offset=Offset(0.0, 0.0) (can use size)
...    constraints: BoxConstraints(0.0<=w<=480.0, 0.0<=h<=Infinity)
...    size: Size(90.0, 16.0)
...    transform matrix: [0] 1.0,0.0,0.0,-0.0
[1] 0.0,1.0,0.0,0.0
[2] 0.0,0.0,1.0,0.0
[3] 0.0,0.0,0.0,1.0
...    origin: null
...    alignment: Alignment.center
...    textDirection: ltr
...    transformHitTests: true
...    child: RenderAnimatedOpacity#18fd9 relayoutBoundary=up14 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...      needs compositing
...      parentData: <none> (can use size)
...      constraints: BoxConstraints(0.0<=w<=480.0, 0.0<=h<=Infinity)
...      size: Size(90.0, 16.0)
...      opacity: AnimationController#f8ecb(⏮ 0.000; paused; for AnimatedOpacity)➩Cubic(0.40, 0.00, 0.20, 1.00)➩Tween<double>(1.0 → 1.0)➩1.0
...      child: RenderParagraph#0a42f relayoutBoundary=up15 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...        parentData: <none> (can use size)
...        constraints: BoxConstraints(0.0<=w<=480.0, 0.0<=h<=Infinity)
...        size: Size(90.0, 16.0)
...        textAlign: start
...        textDirection: ltr
...        softWrap: wrapping at box width
...        overflow: ellipsis
...        locale: en_US
...        maxLines: unlimited
...        text: TextSpan
...          debugLabel: (((((englishLike bodyLarge 2021).merge(((blackMountainView bodyLarge).apply).apply)).copyWith).merge(unknown)).merge(unknown)).copyWith
...          inherit: false
...          color: Color(alpha: 1.0000, red: 0.0000, green: 0.0000, blue: 0.0000, colorSpace: ColorSpace.sRGB)
...          family: Roboto
...          size: 16.0
...          weight: 400
...          letterSpacing: 0.5
...          baseline: alphabetic
...          height: 1.0x
...          leadingDistribution: even
...          decoration: Color(alpha: 1.0000, red: 0.0000, green: 0.0000, blue: 0.0000, colorSpace: ColorSpace.sRGB) TextDecoration.none
...          "Dropdowns:"
...  helperError: RenderConstrainedBox#ed7de relayoutBoundary=up13 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...    parentData: offset=Offset(0.0, 0.0) (can use size)
...    constraints: BoxConstraints(0.0<=w<=368.0, 0.0<=h<=Infinity)
...    size: Size(0.0, 0.0)
...    additionalConstraints: BoxConstraints(w=0.0, h=0.0)
...  container: RenderCustomPaint#fb311 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...    parentData: offset=Offset(0.0, 0.0)
...    constraints: MISSING
...    size: MISSING
...    painter: null
...    foregroundPainter: _InputBorderPainter#c5235

Flutter Doctor output

Doctor output
_ % flutter doctor -v
[✓] Flutter (Channel stable, 3.35.3, on macOS 15.6.1 24G90 darwin-x64, locale it-IT) [3,1s]
    • Flutter version 3.35.3 on channel stable at /Users/home/Development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision a402d9a437 (5 weeks ago), 2025-09-03 14:54:31 -0700
    • Engine revision ddf47dd3ff
    • Dart version 3.9.2
    • DevTools version 2.48.0
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-lldb-debugging

[✓] Android toolchain - develop for Android devices (Android SDK version 36.1.0) [6,6s]
    • Android SDK at /Users/home/Library/Android/sdk
    • Emulator version 36.1.9.0 (build_id 13823996) (CL:N/A)
    • Platform android-36, build-tools 36.1.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.7+-13880790-b1038.58)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS (Xcode 26.0.1) [7,0s]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 17A400
    ! CocoaPods 1.11.3 out of date (1.16.2 is recommended).
        CocoaPods is a package manager for iOS or macOS platform code.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/to/platform-plugins
      To update CocoaPods, see https://guides.cocoapods.org/using/getting-started.html#updating-cocoapods

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

[✓] Android Studio (version 2025.1) [54ms]
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • android-studio-dir = /Applications/Android Studio.app
    • Java version OpenJDK Runtime Environment (build 21.0.7+-13880790-b1038.58)

[✓] IntelliJ IDEA Ultimate Edition (version 2025.2.1) [52ms]
    • IntelliJ at /Users/home/Applications/IntelliJ IDEA Ultimate.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] Connected device (4 available) [13,3s]
    • My Phone (wireless) (mobile)    • adb-45221FDAS0078Q-TodKD8._adb-tls-connect._tcp • android-arm64  • Android 16 (API 36)
    • macOS (desktop)                       • macos                                           • darwin-x64     • macOS 15.6.1 24G90 darwin-x64
    • Chrome (web)                          • chrome                                          • web-javascript • Google Chrome 141.0.7390.65

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

! Doctor found issues in 1 category.

Metadata

Metadata

Assignees

Labels

a: error messageError messages from the Flutter frameworkc: regressionIt was better in the past than it is nowf: 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 teamworkaround availableThere is a workaround available to overcome the issue

Type

No type

Projects

Status

Done (PR merged)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions