'Why does Flutter calculate size of top-level container when introducing row in a sized child element?
I'm trying to create a Flutter app without using Material Design of Cupertino, but I'm stuck creating the row element inside my layout builder.
Every time I try to create the child: Row(), element in my ConstrainedBox, I get the "RenderBox was not laid out: RenderDecoratedBox#6f073" exception.
I know that Flutter is trying to find out the size of my top-level container, but why? This happens even if I use a SizedBox instead of ConstrainedBox.
If I'm specifying the size of the parent for the row, then why does introducing it make Flutter go and try to find the size of the container at the highest level in my application?
@override
Widget build(BuildContext context) {
return Center(
child: Container(
height: double.infinity,
width: double.infinity,
decoration: const BoxDecoration(
gradient: LinearGradient(colors: [
Color.fromARGB(136, 255, 0, 191),
Color.fromARGB(199, 165, 10, 255)
], transform: GradientRotation(4)),
),
child: LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
return Column(children: <Widget>[
ConstrainedBox(
constraints: BoxConstraints(
maxHeight: constraints.maxHeight / 4,
maxWidth: double.infinity,
),
child: Row(),
),
HomeTaskSpace(constraints),
]);
})));
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
