Let's say in Flutter we have a Stack that contains:
- A CustomPainter with size of Size.infinite
- Any other widget that is not a Custom Painter (that we also want to fill all available space exactly the same way that the custom painter does)
In this example, I'm using an Icon for item 2:
@override
Widget build(BuildContext context) {
return Expanded(
child: Container(
color: Colors.white,
child: Stack(
children: [
Icon(Icons.star),
CustomPaint(
painter: MyCustomPainter(percentTimeElapsed: 0.5),
size: Size.infinite)
],
),
),
);
}
Now, obviously, we don't get the desired result yet -- the custom painter is "expanded" but the icon is not.
But I have tried all the following with no luck:
- Wrapping the Icon with Expanded (causes exception)
- Wrapping the Stack widget with Expanded (causes exception)
- Defining the size of the Icon to be Size.infinite (will not build because size param expects a double)
- Using fit: StackFit.expand as a parameter for the Stack, but this just seems to center the Icon and doesn't change it's size.