For some reason, the Stack
widget does not show the Container
with the CustomPaint
.
However if removed from Stack
, it works fine. What am I missing here?
class _DemoNavBar extends State<DemoNavBar> {
@override
Widget build(BuildContext context) {
// TODO: implement build
return MaterialApp(
home:
Stack(
children: <Widget>[
Container(child: CustomPaint(painter: CurvePainter()))
],
)
);
}
}
class CurvePainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
var paint = Paint();
paint.color = Colors.green[800];
paint.style = PaintingStyle.fill;
var path = Path();
path.moveTo(0, size.height - 100);
path.lineTo(size.width * 0.5, size.height - 100);
path.quadraticBezierTo(size.width * 0.7, size.height, size.width * 0.9,
size.height - 100);
path.lineTo(size.width, size.height - 100);
path.lineTo(size.width, size.height);
path.lineTo(0, size.height);
canvas.drawPath(path, paint);
}
@override
bool shouldRepaint(CustomPainter oldDelegate) {
return true;
}
Thanks!