-
Notifications
You must be signed in to change notification settings - Fork 29.1k
Open
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listcustomer: crowdAffects or could affect many people, though not necessarily a specific customer.Affects or could affect many people, though not necessarily a specific customer.found in release: 3.13Found to occur in 3.13Found to occur in 3.13found in release: 3.16Found to occur in 3.16Found to occur in 3.16frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has partial patchThere is a PR awaiting someone to take it across the finish lineThere is a PR awaiting someone to take it across the finish linehas reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team
Description
Let's start with example, you can paste it into https://dartpad.dev
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
void main() {
debugPaintSizeEnabled = true;
runApp(
const MaterialApp(
home: Scaffold(
body: Center(
child: IntrinsicHeight(
child: SizedBox(
width: 100,
child: Column(
children: [
Text(lipsum),
],
),
),
),
),
),
),
);
}
const lipsum =
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam malesuada vulputate efficitur. Curabitur a nulla et nulla bibendum rhoncus. Duis nec porttitor nunc, vitae pharetra sapien. Ut et vulputate velit, eget porttitor nulla. Curabitur maximus dui id nunc ornare lacinia.';
The Column
has height equal to intrinsic heigth of its child. But it's wrong. The computeMinIntrinsicHeight
doesn't take into account the SizedBox
's width
when it should. It calculates the intrinsic height with the height it receives from the parent. You can see this height by commenting out the width
line.
Reproducible both on Flutter stable (3.13.7
) and master (3.16.0-11.0.pre.3
).
Expected | Actual | What intrinsic height "sees" as width |
---|---|---|
The faulty code is in RenderConstrainedBox
, so it touches not only SizedBox
, but also ConstrainedBox
and possibly other widgets. It's both in compute intrinsic height and width methods.
@override
double computeMinIntrinsicHeight(double width) {
if (_additionalConstraints.hasBoundedHeight && _additionalConstraints.hasTightHeight) {
return _additionalConstraints.minHeight;
}
final double height = super.computeMinIntrinsicHeight(width);
assert(height.isFinite);
if (!_additionalConstraints.hasInfiniteHeight) {
return _additionalConstraints.constrainHeight(height);
}
return height;
}
bartekpacia, fylyppo, karolinaoparczyk, denis-lncd, jtarkowski27 and 27 more
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listcustomer: crowdAffects or could affect many people, though not necessarily a specific customer.Affects or could affect many people, though not necessarily a specific customer.found in release: 3.13Found to occur in 3.13Found to occur in 3.13found in release: 3.16Found to occur in 3.16Found to occur in 3.16frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has partial patchThere is a PR awaiting someone to take it across the finish lineThere is a PR awaiting someone to take it across the finish linehas reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team