Skip to content

Empty Stack in Column or Row throws cryptic assertion error #102640

@bleroux

Description

@bleroux

Steps to Reproduce

  1. Execute flutter run on the code sample (see "Code sample" section below)

Expected results: meaningful error message

Actual results: 'package:flutter/src/rendering/stack.dart': Failed assertion: line 523 pos 14: 'constraints.biggest.isFinite': is not true.

Some widgets, for instance AnimatedSwitcher, rely on Stack and might throw this non obvious error message (see #88575).

Code sample
// Flutter code sample for AnimatedSwitcher
//
// This sample shows a counter that animates the scale of a text widget
// whenever the value changes.

import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  static const String _title = 'Flutter Code Sample';

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: _title,
      home: MyStatelessWidget(),
    );
  }
}

class MyStatelessWidget extends StatelessWidget {
  const MyStatelessWidget({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisSize: MainAxisSize.max,
      children: [
        Stack(children: const [Text('Hello')]), // OK
        Expanded(child: Stack()), // OK
        SizedBox(height: 100, child: Stack()), // OK

        Stack(), // Complex assertion error
      ],
    );
  }
}
Logs
Launching lib/main copy.dart on Linux in debug mode...
Connecting to VM Service at ws://127.0.0.1:33035/4jo_VhF1PR4=/ws

════════ Exception caught by rendering library ═════════════════════════════════
The following assertion was thrown during performLayout():
'package:flutter/src/rendering/stack.dart': Failed assertion: line 523 pos 14: 'constraints.biggest.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=2_bug.md

The relevant error-causing widget was
Stack
When the exception was thrown, this was the stack
#2      RenderStack._computeSize
#3      RenderStack.performLayout
#4      RenderObject.layout
#5      ChildLayoutHelper.layoutChild
#6      RenderFlex._computeSizes
#7      RenderFlex.performLayout
#8      RenderObject.layout
#9      RenderProxyBoxMixin.performLayout
#10     RenderObject.layout
#11     RenderProxyBoxMixin.performLayout
#12     RenderObject.layout
#13     RenderProxyBoxMixin.performLayout
#14     RenderObject.layout
#15     RenderProxyBoxMixin.performLayout
#16     RenderObject.layout
#17     RenderProxyBoxMixin.performLayout
#18     RenderObject.layout
#19     RenderProxyBoxMixin.performLayout
#20     RenderObject.layout
#21     RenderProxyBoxMixin.performLayout
#22     RenderObject.layout
#23     RenderProxyBoxMixin.performLayout
#24     RenderObject.layout
#25     RenderProxyBoxMixin.performLayout
#26     RenderObject.layout
#27     RenderProxyBoxMixin.performLayout
#28     RenderObject.layout
#29     RenderProxyBoxMixin.performLayout
#30     RenderObject.layout
#31     RenderProxyBoxMixin.performLayout
#32     RenderObject.layout
#33     RenderProxyBoxMixin.performLayout
#34     RenderObject.layout
#35     RenderProxyBoxMixin.performLayout
#36     RenderObject.layout
#37     RenderProxyBoxMixin.performLayout
#38     RenderObject.layout
#39     RenderProxyBoxMixin.performLayout
#40     RenderObject.layout
#41     RenderProxyBoxMixin.performLayout
#42     RenderOffstage.performLayout
#43     RenderObject.layout
#44     RenderProxyBoxMixin.performLayout
#45     RenderObject.layout
#46     _RenderTheatre.performLayout
#47     RenderObject.layout
#48     RenderProxyBoxMixin.performLayout
#49     RenderObject.layout
#50     RenderProxyBoxMixin.performLayout
#51     RenderObject.layout
#52     RenderProxyBoxMixin.performLayout
#53     RenderObject.layout
#54     RenderProxyBoxMixin.performLayout
#55     RenderCustomPaint.performLayout
#56     RenderObject.layout
#57     RenderProxyBoxMixin.performLayout
#58     RenderObject.layout
#59     RenderProxyBoxMixin.performLayout
#60     RenderObject.layout
#61     RenderProxyBoxMixin.performLayout
#62     RenderObject.layout
#63     RenderProxyBoxMixin.performLayout
#64     RenderObject.layout
#65     RenderView.performLayout
#66     RenderObject._layoutWithoutResize
#67     PipelineOwner.flushLayout
#68     RendererBinding.drawFrame
#69     WidgetsBinding.drawFrame
#70     RendererBinding._handlePersistentFrameCallback
#71     SchedulerBinding._invokeFrameCallback
#72     SchedulerBinding.handleDrawFrame
#73     SchedulerBinding.scheduleWarmUpFrame.<anonymous closure>
(elided 6 frames from class _AssertionError, class _RawReceivePortImpl, class _Timer, and dart:async-patch)
The following RenderObject was being processed when the exception was fired: RenderStack#0a6e0 relayoutBoundary=up1 NEEDS-LAYOUT NEEDS-PAINT
RenderObject: RenderStack#0a6e0 relayoutBoundary=up1 NEEDS-LAYOUT NEEDS-PAINT
    parentData: offset=Offset(0.0, 0.0); flex=null; fit=null (can use size)
    constraints: BoxConstraints(0.0<=w<=1280.0, 0.0<=h<=Infinity)
    size: MISSING
    alignment: AlignmentDirectional.topStart
    textDirection: ltr
    fit: loose
════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderStack#0a6e0 relayoutBoundary=up1 NEEDS-PAINT
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1978 pos 12: 'hasSize'

The relevant error-causing widget was
Column
════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderFlex#c2fdc NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1978 pos 12: 'hasSize'

The relevant error-causing widget was
MaterialApp
════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderSemanticsAnnotations#9c0d2 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1978 pos 12: 'hasSize'

The relevant error-causing widget was
MaterialApp
════════════════════════════════════════════════════════════════════════════════

stable and master flutter doctor -v :

[✓] Flutter (Channel stable, 2.10.4, on Ubuntu 20.04.4 LTS 5.4.0-109-generic, locale fr_FR.UTF-8)
    • Flutter version 2.10.4 at /home/bruno/fvm/versions/2.10.4
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision c860cba910 (il y a 4 semaines), 2022-03-25 00:23:12 -0500
    • Engine revision 57d3bac3dd
    • Dart version 2.16.2
    • DevTools version 2.9.2

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /home/bruno/Android/Sdk
    • Platform android-31, build-tools 30.0.3
    • Java binary at: /home/bruno/Produits/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • clang version 10.0.0-4ubuntu1
    • cmake version 3.16.3
    • ninja version 1.8.2
    • pkg-config version 0.29.1

[✓] Android Studio (version 2020.3)
    • Android Studio at /home/bruno/Produits/android-studio
    • Flutter plugin version 60.1.2
    • Dart plugin version 203.8292
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[✓] VS Code (version 1.66.2)
    • VS Code at /usr/share/code
    • Flutter extension version 3.38.1

[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • Ubuntu 20.04.4 LTS 5.4.0-109-generic
    • Chrome (web)    • chrome • web-javascript • Google Chrome 100.0.4896.127

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!


[✓] Flutter (Channel master, 2.13.0-0.0.pre.710, on Ubuntu 20.04.4 LTS 5.4.0-109-generic, locale fr_FR.UTF-8)
    • Flutter version 2.13.0-0.0.pre.710 at /home/bruno/fvm/versions/master
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 4fec2ee0ed (il y a 3 heures), 2022-04-24 23:29:06 -0400
    • Engine revision 20b5b8604c
    • Dart version 2.18.0 (build 2.18.0-44.0.dev)
    • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /home/bruno/Android/Sdk
    • Platform android-31, build-tools 30.0.3
    • Java binary at: /home/bruno/Produits/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • clang version 10.0.0-4ubuntu1
    • cmake version 3.16.3
    • ninja version 1.8.2
    • pkg-config version 0.29.1

[✓] Android Studio (version 2020.3)
    • Android Studio at /home/bruno/Produits/android-studio
    • Flutter plugin version 60.1.2
    • Dart plugin version 203.8292
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[✓] VS Code (version 1.66.2)
    • VS Code at /usr/share/code
    • Flutter extension version 3.38.1

[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • Ubuntu 20.04.4 LTS 5.4.0-109-generic
    • Chrome (web)    • chrome • web-javascript • Google Chrome 100.0.4896.127

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: error messageError messages from the Flutter frameworkc: crashStack traces logged to the consolefound in release: 2.10Found to occur in 2.10found in release: 2.13Found to occur in 2.13frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work on

Type

No type

Projects

Status

Done (PR merged)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions