Visitar URL original
'package:flutter/src/rendering/stack.dart': Failed assertion: line 664 pos 12: 'size.isFinite': is not true. · Issue #172481 · flutter/flutter · GitHub
Skip to content

'package:flutter/src/rendering/stack.dart': Failed assertion: line 664 pos 12: 'size.isFinite': is not true. #172481

Closed

Description

@treeplate

Steps to reproduce

Run the code sample.

Expected results

Probably an error message, but one that actually has detail.

Actual results

I get an assertion that tells me to file a bug.

Code sample

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

void main() {
  runApp(
    Directionality(
      textDirection: TextDirection.ltr,
      child: Column(
        children: [
          Stack(children: [Positioned(top:0,child: SizedBox())]),
        ],
      ),
    ),
  );
}

Screenshots or Video

No response

Logs

log.txt

Flutter Doctor output

Doctor output
[✓] Flutter (Channel main, 3.33.0-1.0.pre-1039, on macOS 14.6.1 23G93 darwin-arm64, locale en-US) [1,230ms]
    • Flutter version 3.33.0-1.0.pre-1039 on channel main at /Users/user/dev/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 70cdc0c933 (2 hours ago), 2025-07-21 12:09:22 -0400
    • Engine revision 70cdc0c933
    • Dart version 3.10.0 (build 3.10.0-15.0.dev)
    • 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-native-assets

[✗] Android toolchain - develop for Android devices [116ms]
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/to/macos-android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.


[!] Xcode - develop for iOS and macOS (Xcode 16.2) [1,044ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16C5032a
    ✗ Unable to get list of installed Simulator runtimes.
    • CocoaPods version 1.16.2

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

[!] Android Studio (not installed) [6ms]
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/to/macos-android-setup for detailed instructions).

[✓] VS Code (version 1.101.2) [6ms]
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.114.0

[✓] Connected device (2 available) [5.7s]
    • macOS (desktop) • macos  • darwin-arm64   • macOS 14.6.1 23G93 darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 138.0.7204.158

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

! Doctor found issues in 3 categories.

Activity

  1. tirth-patel-nc commented on Jul 22, 2025

    @tirth-patel-nc
    Member

    hi @treeplate, thanks for the report. are you suggesting an improvement to the message?

  2. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jul 22, 2025
  3. treeplate commented on Jul 22, 2025

    @treeplate
    Author

    yes

  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jul 22, 2025
  5. tirth-patel-nc commented on Jul 23, 2025

    @tirth-patel-nc
    Member

    Positioned requires its Stack parent to have bounded constraints, which Column doesn't provide by default. So this is an implementation error, labelling it as a proposal to improve the error message.

    Logs
    ════════ Exception caught by rendering library ═════════════════════════════════
    The following assertion was thrown during performLayout():
    'package:flutter/src/rendering/stack.dart': Failed assertion: line 663 pos 12: 'size.isFinite': is not true.
    
    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:
        Stack Stack:file:///Users/tirthpatel/j23/lib/main.dart:9:11
    
    When the exception was thrown, this was the stack:
    #2      RenderStack._computeSize (package:flutter/src/rendering/stack.dart:663:12)
    stack.dart:663
    #3      RenderStack.performLayout (package:flutter/src/rendering/stack.dart:672:12)
    stack.dart:672
    #4      RenderObject.layout (package:flutter/src/rendering/object.dart:2775:7)
    object.dart:2775
    #5      ChildLayoutHelper.layoutChild (package:flutter/src/rendering/layout_helper.dart:62:11)
    layout_helper.dart:62
    #6      RenderFlex._computeSizes (package:flutter/src/rendering/flex.dart:1161:28)
    flex.dart:1161
    #7      RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:1257:32)
    flex.dart:1257
    #8      RenderObject.layout (package:flutter/src/rendering/object.dart:2775:7)
    object.dart:2775
    #9      RenderView.performLayout (package:flutter/src/rendering/view.dart:294:12)
    view.dart:294
    #10     RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:2623:7)
    object.dart:2623
    #11     PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:1170:18)
    object.dart:1170
    #12     PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:1183:15)
    object.dart:1183
    #13     RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:629:23)
    binding.dart:629
    #14     WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:1261:13)
    binding.dart:1261
    #15     RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:495:5)
    binding.dart:495
    #16     SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1434:15)
    binding.dart:1434
    #17     SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1347:9)
    binding.dart:1347
    #18     SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:1057:9)
    binding.dart:1057
    #19     PlatformDispatcher.scheduleWarmUpFrame.<anonymous closure> (dart:ui/platform_dispatcher.dart:886:16)
    platform_dispatcher.dart:886
    #23     _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:193:12)
    isolate_patch.dart:193
    (elided 5 frames from class _AssertionError, class _Timer, and dart:async-patch)
    
    The following RenderObject was being processed when the exception was fired: RenderStack#f7f91 relayoutBoundary=up1 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
        parentData: offset=Offset(0.0, 0.0); flex=null; fit=null (can use size)
        constraints: BoxConstraints(0.0<=w<=411.4, 0.0<=h<=Infinity)
        size: MISSING
        alignment: AlignmentDirectional.topStart
        textDirection: ltr
        fit: loose
        child 1: RenderConstrainedBox#0e1b8 NEEDS-LAYOUT NEEDS-PAINT
            parentData: top=0.0; offset=Offset(0.0, 0.0)
            constraints: MISSING
            size: MISSING
            additionalConstraints: BoxConstraints(unconstrained)
    RenderObject: RenderStack#f7f91 relayoutBoundary=up1 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
        parentData: offset=Offset(0.0, 0.0); flex=null; fit=null (can use size)
        constraints: BoxConstraints(0.0<=w<=411.4, 0.0<=h<=Infinity)
        size: MISSING
        alignment: AlignmentDirectional.topStart
        textDirection: ltr
        fit: loose
        child 1: RenderConstrainedBox#0e1b8 NEEDS-LAYOUT NEEDS-PAINT
            parentData: top=0.0; offset=Offset(0.0, 0.0)
            constraints: MISSING
            size: MISSING
            additionalConstraints: BoxConstraints(unconstrained)
    ════════════════════════════════════════════════════════════════════════════════
    
    ════════ Exception caught by rendering library ═════════════════════════════════
    RenderBox was not laid out: RenderStack#f7f91 relayoutBoundary=up1 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
    'package:flutter/src/rendering/box.dart':
    Failed assertion: line 2251 pos 12: 'hasSize'
    The relevant error-causing widget was:
        Column Column:file:///Users/tirthpatel/j23/lib/main.dart:7:14
    ════════════════════════════════════════════════════════════════════════════════

    #78796 (comment)

  6. added
    c: proposalA detailed proposal for a change to Flutter
    a: error messageError messages from the Flutter framework
    frameworkflutter/packages/flutter repository. See also f: labels.
    p: material_uimaterial_ui package in flutter/packages
    and removed
    in triagePresently being triaged by the triage team
    on Jul 23, 2025
  7. Rushikeshbhavsar20 commented on Aug 6, 2025

    @Rushikeshbhavsar20
    Contributor

    Hi! I’d love to contribute to this issue.
    I plan to improve the assertion error message in RenderStack to clearly explain that the Stack needs bounded constraints (like wrapping it in a SizedBox or Expanded).
    Please let me know if I can be assigned or if there’s any guidance. Thanks!

  8. tirth-patel-nc commented on Aug 6, 2025

    @tirth-patel-nc
    Member

    feel free to pick up, it's all yours. thanks for contributing.

  9. Rushikeshbhavsar20 commented on Aug 6, 2025

    @Rushikeshbhavsar20
    Contributor
    Image Hey @tirth-patel-nc ! I’ve updated the assertion to display a clearer error message explaining that Stack needs bounded constraints, with suggestions like using SizedBox, Expanded, or ConstrainedBox.

    Could you please take a quick look and let me know if the message looks good?
    If it's fine, I’ll go ahead and raise the PR.

    Thanks again!

  10. added a commit that references this issue on Aug 19, 2025
    e554671
  11. added 2 commits that reference this issue on Aug 22, 2025
    fd2f747
    bac3251
  12. github-actions commented on Sep 4, 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.

  13. locked as resolved and limited conversation to collaborators on Sep 4, 2025
  14. added a commit that references this issue on Sep 18, 2025
    4ffe3f1
  15. added a commit that references this issue on Sep 22, 2025
    92d11de
  16. added a commit that references this issue on Sep 24, 2025
    e049cf6
  17. added a commit that references this issue on Nov 21, 2025
    800e4a5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

P2Important issues not at the top of the work lista: error messageError messages from the Flutter frameworkc: proposalA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.p: material_uimaterial_ui package in flutter/packagesr: fixedIssue is closed as already fixed in a newer versionteam-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