Skip to content

Does not work inside an IntrinsicHeight and row #30

@stargazing-dino

Description

@stargazing-dino

Hi!

Steps to Reproduce
Create a listview and add an item that looks like the following code block from here https://stackoverflow.com/a/51157072/8213910

Here is a minimal example

class ExampleWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: ListView.builder(
        itemCount: 3,
        itemBuilder: (context, _) {
          return Card(
            child: IntrinsicHeight(
              child: Row(
                crossAxisAlignment: CrossAxisAlignment.stretch,
                children: <Widget>[
                  Container(
                    height: 40,
                    width: 20.0,
                    color: Colors.amber,
                  ),
                  Expanded(
                    child: AutoSizeText('hello'),
                  ),
                ],
              ),
            ),
          );
        },
      ),
    );
  }
}

It throws this:

The following assertion was thrown during performLayout():
LayoutBuilder does not support returning intrinsic dimensions.

Calculating the intrinsic dimensions would require running the layout callback speculatively, which might mutate the live render object tree.
User-created ancestor of the error-causing widget was
    Card 
lib\pages\home.dart:28
When the exception was thrown, this was the stack
#0      _RenderLayoutBuilder._debugThrowIfNotCheckingIntrinsics.<anonymous closure> 
package:flutter/…/widgets/layout_builder.dart:263
#1      _RenderLayoutBuilder._debugThrowIfNotCheckingIntrinsics 
package:flutter/…/widgets/layout_builder.dart:270
#2      _RenderLayoutBuilder.computeMaxIntrinsicHeight 
package:flutter/…/widgets/layout_builder.dart:234
#3      RenderBox._computeIntrinsicDimension.<anonymous closure> 
package:flutter/…/rendering/box.dart:1290
#4      _LinkedHashMapMixin.putIfAbsent  (dart:collection-patch/compact_hash.dart:291:23)
...
The following RenderObject was being processed when the exception was fired: RenderIntrinsicHeight#dd578 relayoutBoundary=up11 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
RenderObject: RenderIntrinsicHeight#dd578 relayoutBoundary=up11 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
    parentData: <none> (can use size)
    constraints: BoxConstraints(w=675.4, 0.0<=h<=Infinity)
    size: Size(675.4, 40.0)
    child: RenderFlex#ef52d NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
        parentData: <none> (can use size)
        constraints: BoxConstraints(w=675.4, h=40.0)
        size: Size(675.4, 40.0)
        direction: horizontal
        mainAxisAlignment: start
        mainAxisSize: max
        crossAxisAlignment: stretch
        textDirection: ltr
        verticalDirection: down
        child 1: RenderConstrainedBox#34546 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<=Infinity, h=40.0)
            size: Size(20.0, 40.0)
            additionalConstraints: BoxConstraints(w=20.0, h=40.0)
            child: RenderDecoratedBox#f84cb NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
                parentData: <none> (can use size)
                constraints: BoxConstraints(w=20.0, h=40.0)
                size: Size(20.0, 40.0)
                decoration: BoxDecoration
                    color: MaterialColor(primary value: Color(0xffffc107))
                configuration: ImageConfiguration(bundle: PlatformAssetBundle#f4e9c(), devicePixelRatio: 2.6, locale: en_US, textDirection: TextDirection.ltr, platform: android)
        child 2: _RenderLayoutBuilder#14596 NEEDS-LAYOUT NEEDS-PAINT
            parentData: offset=Offset(0.0, 0.0); flex=1; fit=FlexFit.tight
            constraints: MISSING
            size: MISSING
════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by rendering library ═════════════════════════════════
LayoutBuilder does not support returning intrinsic dimensions.
User-created ancestor of the error-causing widget was
    Card 
lib\pages\home.dart:28
════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by rendering library ═════════════════════════════════
LayoutBuilder does not support returning intrinsic dimensions.
User-created ancestor of the error-causing widget was
    Card 
lib\pages\home.dart:28
════════════════════════════════════════════════════════════════════════════════

Screenshots
I want to create a card with date text on the left that will scale and content on the right. I don't want to use a FittedBox solution as the text grows too much on landscape and looks ugly.

card_screenshot

Version

Flutter 1.9.1+hotfix.1 • channel beta • https://github.com/flutter/flutter.git
Framework • revision a1fb3fabec (2 days ago) • 2019-09-03 18:07:52 -0700
Engine • revision cc88fa45db
Tools • Dart 2.5.0
  • auto_size_text version: 2.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions