So I have a Row inside a fixed size Container, the Row contains 2 Text widgets, both of them wrapped in FittedBox so the text wouldn't overflow.
[Edit] The Container's fixed size is just a placeholder for the minimal example. In reality the Container is in many parents and his size is determined by the size screen. So I can't really access the Containers width and height properties easily.
Container(
height: 100,
width: 240,
color: Colors.blue,
child: Center(
child: Container(
color: Colors.green,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Expanded(
child: Container(
color: Colors.red,
child: const FractionallySizedBox(
heightFactor: 0.5,
child: FittedBox(
fit: BoxFit.contain,
child: Text("10"),
)
)
),
),
Expanded(
child: Container(
color: Colors.yellow,
child: const FittedBox(
fit: BoxFit.contain,
child: Text("10"),
)
)
),
],
)
)
)
)
I want the red widget to be half (or any other fraction) the height of the yellow widget, so I wrapped the red widget in the FractionallySizedBox, which works if the yellow widget has same height as the blue Container.
But if the text in the yellow widget is longer, its height gets smaller and the Row's height gets smaller, but the red widget is still taking the fraction from the blue Container not the smaller green Row.
I want the red widget to be at most half the height of the yellow widget even if it gets smaller because of the text length. If the red widget has to be smaller because of the length of its text, then it should be smaller, but it should never be taller than half of the yellow box.
How to do it?