Skip to content

OverlayPortal child throws sizeAccessAllowed when enclosing Overlay has unbounded constraints #192861

Closed

Description

@fujidaiti

Steps to reproduce

  1. Place an Overlay in a box with an unbounded constraint, with canSizeOverlay:true on its OverlayEntry so that it shrink-wraps
  2. Put a widget that uses OverlayPortal, such as DropdownMenu, inside the entry
  3. Open the OverlayPortal child, e.g., by tapping the DropdownMenu

Expected results

No assertion is thrown.

Actual results

An assertion is thrown:

 ════════ 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. If you hit this assert trying to access a child's size, pass "parentUsesSize: true" to that child's layout() in _RenderTheater.performLayout.
 'package:flutter/src/rendering/box.dart':
 Failed assertion: line 2268 pos 11: 'sizeAccessAllowed'

See the Logs below for the full output.

Code sample

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

void main() {
  runApp(
    MaterialApp(
      home: Scaffold(
        body: Center(
          child: UnconstrainedBox(
            child: Overlay(
              initialEntries: [
                OverlayEntry(
                  canSizeOverlay: true,
                  builder: (_) => const _Content(),
                ),
              ],
            ),
          ),
        ),
      ),
    ),
  );
}

class _Content extends StatelessWidget {
  const _Content();

  @override
  Widget build(BuildContext context) {
    return Container(
      width: 300,
      height: 300,
      color: Colors.lightBlue.shade100,
      alignment: Alignment.bottomCenter,
      child: DropdownMenu<int>(
        label: const Text('Tap to reproduce'),
        dropdownMenuEntries: [
          for (var i = 1; i <= 3; i++)
            DropdownMenuEntry(value: i, label: 'Item $i'),
        ],
      ),
    );
  }
}

Screenshots or Video

Screenshot (expected result) Image

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. If you hit this assert trying to access a child's size, pass "parentUsesSize: true" to that child's layout() in _RenderTheater.performLayout.
 'package:flutter/src/rendering/box.dart':
 Failed assertion: line 2268 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:
     DropdownMenu<int> DropdownMenu:file:///Users/fujidaiti/Dev/navigator_resizable-overlay-compat/example/lib/repro.dart:34:14

 When the exception was thrown, this was the stack:
 #2      RenderBox.size.<anonymous closure> (package:flutter/src/rendering/box.dart:2268:11)
 #3      RenderBox.size (package:flutter/src/rendering/box.dart:2302:6)
 #4      _RenderLayoutSurrogateProxyBox.performLayout (package:flutter/src/widgets/overlay.dart:2795:21)
 #5      RenderObject.layout (package:flutter/src/rendering/object.dart:2923:7)
 #6      RenderPositionedBox.performLayout (package:flutter/src/rendering/shifted_box.dart:484:14)
 #7      RenderObject.layout (package:flutter/src/rendering/object.dart:2923:7)
 #8      ChildLayoutHelper.layoutChild (package:flutter/src/rendering/layout_helper.dart:62:11)
 #9      RenderStack._computeSize (package:flutter/src/rendering/stack.dart:647:43)
 #10     RenderStack.performLayout (package:flutter/src/rendering/stack.dart:682:12)
 #11     RenderObject.layout (package:flutter/src/rendering/object.dart:2923:7)
 #12     RenderPositionedBox.performLayout (package:flutter/src/rendering/shifted_box.dart:484:14)
 #13     RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:2771:7)
 #14     PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:1174:18)
 #15     PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:1187:15)
 #16     RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:692:23)
 #17     WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:1573:13)
 #18     RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:558:5)
 #19     SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1430:15)
 #20     SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1345:9)
 #21     SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1198:5)
 #22     _invoke (dart:ui/hooks.dart:441:13)
 #23     PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:450:5)
 #24     _drawFrame (dart:ui/hooks.dart:413:31)
 (elided 2 frames from class _AssertionError)

 The following RenderObject was being processed when the exception was fired: _RenderLayoutSurrogateProxyBox#cb077 relayoutBoundary=up3 NEEDS-LAYOUT NEEDS-PAINT
     needs compositing
     parentData: offset=Offset(0.0, 0.0) (can use size)
     constraints: BoxConstraints(0.0<=w<=300.0, 0.0<=h<=300.0)
     size: Size(216.6, 56.0)
     child: RenderSemanticsAnnotations#788db relayoutBoundary=up4 NEEDS-PAINT
         needs compositing
         parentData: <none> (can use size)
         constraints: BoxConstraints(0.0<=w<=300.0, 0.0<=h<=300.0)
         semantics node: SemanticsNode#5
             Rect.fromLTRB(92.7, 531.0, 309.3, 587.0)
             actions: expand, focus
             flags: isButton, isTextField, hasEnabledState, isEnabled, isReadOnly, isFocusable, hasExpandedState
             traversalParentIdentifier: _OverlayPortalState#421c3
             label: "Tap to reproduce"
             hint: "Collapsed"
             textDirection: ltr
             currentValueLength: 0
             inputType: text
         size: Size(216.6, 56.0)
         child: RenderTapRegion#45d90 relayoutBoundary=up5 NEEDS-PAINT
             needs compositing
             parentData: <none> (can use size)
             constraints: BoxConstraints(0.0<=w<=300.0, 0.0<=h<=300.0)
             size: Size(216.6, 56.0)
             behavior: deferToChild
             groupId: MenuController#f8cf9
             child: RenderSemanticsAnnotations#1dbe9 relayoutBoundary=up6 NEEDS-PAINT
                 needs compositing
                 parentData: <none> (can use size)
                 constraints: BoxConstraints(0.0<=w<=300.0, 0.0<=h<=300.0)
                 size: Size(216.6, 56.0)
                 child: _RenderDropdownMenuBody#40fb4 relayoutBoundary=up7 NEEDS-PAINT
                     needs compositing
                     parentData: <none> (can use size)
                     constraints: BoxConstraints(0.0<=w<=300.0, 0.0<=h<=300.0)
                     size: Size(216.6, 56.0)
 RenderObject: _RenderLayoutSurrogateProxyBox#cb077 relayoutBoundary=up3 NEEDS-LAYOUT NEEDS-PAINT
     needs compositing
     parentData: offset=Offset(0.0, 0.0) (can use size)
     constraints: BoxConstraints(0.0<=w<=300.0, 0.0<=h<=300.0)
     size: Size(216.6, 56.0)
     child: RenderSemanticsAnnotations#788db relayoutBoundary=up4 NEEDS-PAINT
         needs compositing
         parentData: <none> (can use size)
         constraints: BoxConstraints(0.0<=w<=300.0, 0.0<=h<=300.0)
         semantics node: SemanticsNode#5
             Rect.fromLTRB(92.7, 531.0, 309.3, 587.0)
             actions: expand, focus
             flags: isButton, isTextField, hasEnabledState, isEnabled, isReadOnly, isFocusable, hasExpandedState
             traversalParentIdentifier: _OverlayPortalState#421c3
             label: "Tap to reproduce"
             hint: "Collapsed"
             textDirection: ltr
             currentValueLength: 0
             inputType: text
         size: Size(216.6, 56.0)
         child: RenderTapRegion#45d90 relayoutBoundary=up5 NEEDS-PAINT
             needs compositing
             parentData: <none> (can use size)
             constraints: BoxConstraints(0.0<=w<=300.0, 0.0<=h<=300.0)
             size: Size(216.6, 56.0)
             behavior: deferToChild
             groupId: MenuController#f8cf9
             child: RenderSemanticsAnnotations#1dbe9 relayoutBoundary=up6 NEEDS-PAINT
                 needs compositing
                 parentData: <none> (can use size)
                 constraints: BoxConstraints(0.0<=w<=300.0, 0.0<=h<=300.0)
                 size: Size(216.6, 56.0)
                 child: _RenderDropdownMenuBody#40fb4 relayoutBoundary=up7 NEEDS-PAINT
                     needs compositing
                     parentData: <none> (can use size)
                     constraints: BoxConstraints(0.0<=w<=300.0, 0.0<=h<=300.0)
                     size: Size(216.6, 

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.47.4, on macOS 26.6.2 25G83 darwin-arm64, locale ja-JP) [629ms]
    • Flutter version 3.47.4 on channel stable at /Users/fujidaiti/.fvm/versions/3.47.4
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 9584c6713b (5 days ago), 2026-09-10 15:25:10 -0700
    • Engine revision 06a2e2a110
    • Dart version 3.13.3
    • DevTools version 2.60.0
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets, enable-record-use, enable-swift-package-manager, omit-legacy-version-file, enable-lldb-debugging, enable-uiscene-migration

[✓] Android toolchain - develop for Android devices (Android SDK version 37.0.0) [2.3s]
    • Android SDK at /Users/fujidaiti/Library/Android/sdk
    • Emulator version 37.1.11.0 (build_id 15917651) (CL:N/A)
    • Platform android-37.0, build-tools 37.0.0
    • ANDROID_HOME = /Users/fujidaiti/Library/Android/sdk
    • Java binary at: /Library/Java/JavaVirtualMachines/temurin-17.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 OpenJDK Runtime Environment Temurin-17.0.20.1+1 (build 17.0.20.1+1)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 26.5) [1,387ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 17F42
    • CocoaPods version 1.16.2

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

[✓] Connected device (3 available) [7.0s]
    • iPhone 17 (mobile) • 5C8B5F23-484F-46AD-A497-CC9135E971B6 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-26-2 (simulator)
    • macOS (desktop)    • macos                                • darwin-arm64   • macOS 26.6.2 25G83 darwin-arm64
    • Chrome (web)       • chrome                               • web-javascript • Google Chrome 152.0.7977.83
    ! Error: Browsing on the local area network for P240202. 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)
    ! Error: Browsing on the local area network for 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 [537ms]
    • All expected network resources are available.

• No issues found!

Activity

  1. fujidaiti commented on Sep 16, 2026

    @fujidaiti
    Author

    I ran into this while building an experimental layout in which a Navigator is given unbounded constraints so that it shrink-wraps to the current route's content, instead of filling the entire screen.

    If I understand the root cause correctly, the deferred child falls back to reading the RenderTheater's size when the theater's constraints are unbounded, but which is rejected as it is not permitted to do so:

    final theater = deferredChild.parent! as _RenderTheater;
    // If the theater is laying out the size-determining child, its size is not
    // available yet. Since the theater always lays out the size-determining
    // child first and the deferred child can never be size-determining,
    // this method does not have to do anything, the theater will update the
    // constraints of the deferred child and resize / put it in the dirty list if
    // needed.
    if (!theater._layingOutSizeDeterminingChild) {
    final BoxConstraints theaterConstraints = theater.constraints;
    final Size boxSize = theaterConstraints.biggest.isFinite
    ? theaterConstraints.biggest
    : theater.size;
    deferredChild._doLayoutFrom(this, constraints: BoxConstraints.tight(boxSize));
    }

    I think reading the theater's size is legitimate here, so the fix would be bypassing the assertion somehow, for example by cacheing the last measured size in the theater and read it here instead of RenderBox.size.

    I hope the issue gets fixed for my very niche use case :)
    Or, if you don't mind and the idea above is heading in the right direction, I could send a PR. Thank you.

  2. suryaKommana2662 commented on Sep 16, 2026

    @suryaKommana2662
    Contributor

    @fujidaiti Thanks for the report. I was able to reproduce the issue locally on macOS, iOS simulator and Android emulator using the provided code sample. I observed the following assertion when opening the DropdownMenu:

    package:flutter/src/rendering/box.dart: 
    Failed assertion: line 2268 pos 11: 'sizeAccessAllowed
    

    The stack trace also points to _RenderLayoutSurrogateProxyBox.performLayout in packages/flutter/lib/src/widgets/overlay.dart. Routing this to the framework team for further investigation.

    Flutter Doctor Output

    [✓] Flutter (Channel stable, 3.47.4, on macOS 27.0 26A428 darwin-arm64, locale en-IN) [731ms]
        • Flutter version 3.47.4 on channel stable at /Users/suryakommana/develop/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 9584c6713b (6 days ago), 2026-09-10 15:25:10 -0700
        • Engine revision 06a2e2a110
        • Dart version 3.13.3
        • DevTools version 2.60.0
        • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets,
          enable-record-use, enable-swift-package-manager, omit-legacy-version-file, enable-lldb-debugging, enable-uiscene-migration
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [1,590ms]
        • Android SDK at /Users/suryakommana/Library/Android/sdk
        • Emulator version 37.1.11.0 (build_id 15917651) (CL:N/A)
        • Platform android-37.0, build-tools 36.0.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 25.0.2+-15348964-b329.117)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 27.0) [735ms]
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 27A266a
        • CocoaPods version 1.17.0
    
    [✓] Chrome - develop for the web [4ms]
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Connected device (4 available) [6.0s]
        • sdk gphone16k arm64 (mobile) • emulator-5554                        • android-arm64  • Android 17 (API 37) (emulator)
        • iPhone 17 pro (mobile)       • DB7548B3-163D-4C89-A357-B948B8CE1F16 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-26-5 (simulator)
        • macOS (desktop)              • macos                                • darwin-arm64   • macOS 27.0 26A428 darwin-arm64
        • Chrome (web)                 • chrome                               • web-javascript • Google Chrome 153.0.8010.47
    
    [✓] Network resources [984ms]
        • All expected network resources are available.
    
    • No issues found!
  3. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    platform-macosBuilding on or for macOS specifically
    team-androidOwned by Android platform team
    team-iosOwned by iOS platform team
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    and removed
    in triagePresently being triaged by the triage team
    on Sep 16, 2026
  4. added
    P2Important issues not at the top of the work list
    on Sep 29, 2026
  5. justinmc commented on Sep 29, 2026

    @justinmc
    Contributor
  6. added a commit that references this issue on Oct 6, 2026
    f6bf934
  7. github-actions commented on Oct 24, 2026

    @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.

  8. locked as resolved and limited conversation to collaborators on Oct 24, 2026
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 listf: material designframeworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-androidAndroid applications specificallyplatform-iosiOS applications specificallyplatform-macosBuilding on or for macOS specificallyteam-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions