I want to create a hole in any Flutter widget. For example, say we have two widgets in a Stack, I want to dig a hole in the upper one in order to make the below widget visible to users.
There is a question with a similar title but the accepted answer does not match the question exactly. What is achieved by the answer is to dig a hole in a single-color overlay, not on a complete widget.
I have found that with CustomPaint we can draw widgets in three layers:
class BasicExample extends StatelessWidget {
const BasicExample({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return CustomPaint(
child: Image.asset(
"images/flutter.jpg",
fit: BoxFit.cover,
),
foregroundPainter: DemoPainter(Colors.red.withOpacity(0.5)),
painter: DemoPainter(Colors.blue.withOpacity(0.5)),
size: Size.square(200.0),
willChange: true,
);
}
}
But I cannot find a mechanism like ColorFiltered mentioned in the above answer. Is there something called WidgetFiltered, as a counterpart in the widget world to the single-color overlay world, that we can use to handle the render of two overlapped widgets (for example, the painter & child in the example code)?
