PP
Size: a a a
PP
А
PP
MK
IE
А
IE
А
А
IE
А
PP
Ю
IE
PP
IE
IE
PP
PP
GestureDetector(
onTap: () => print('tap'),
child: CustomPaint(
// note: to make GestureDetector work,
// either size should be specified
// or parent widget should has size (e.g. use Expanded if in Row/Column, Positioned.fill if in Stack)
painter: PathPainter(
path: Path()
..moveTo(100, 0)
..lineTo(200, 200)
..lineTo(0, 200)
..close(),
color: Colors.orange,
),
),
);
PP
class PathPainter extends CustomPainter {
final Path path;
final Color color;
const PathPainter({
@required this.path,
@required this.color,
});
@override
bool shouldRepaint(PathPainter oldDelegate) =>
oldDelegate.path != path || oldDelegate.color != color;
@override
bool shouldRebuildSemantics(PathPainter oldDelegate) => true;
@override
void paint(Canvas canvas, Size size) {
canvas.drawPath(
path,
Paint()
..color = color
..style = PaintingStyle.fill,
);
}
@override
bool hitTest(Offset position) => path.contains(position);
}