Flutter:如何在AppBar中绘制自定义重叠三角形

时间:2019-07-28 15:48:43

标签: flutter dart

我想使用CustomPainter或Path像这样的图像那样在抖动中绘制重叠的三角形,但是问题是如果我使用此当前图像并将其放在appbar中,

AppBar Effect

我已经尝试在容器中使用堆栈创建一些三角形并重叠,但是我无法在 AppBar

中创建它

我的代码是这样的,但我学习的并不是直角三角形,

class ShapesPainter extends CustomPainter {
  @override
  void paint(Canvas canvas, Size size) {
    final paint = Paint();
    // set the paint color to be white
    paint.color = Colors.white;
    // Create a rectangle with size and width same as the canvas
    var rect = Rect.fromLTWH(0, 0, size.width, size.height);
    // draw the rectangle using the paint
    canvas.drawRect(rect, paint);
    paint.color = Colors.yellow;
    // create a path
    var path = Path();
    path.lineTo(0, size.height);
    path.lineTo(size.width, 0);
    // close the path to form a bounded shape
    path.close();
    canvas.drawPath(path, paint);
  }
  @override
  bool shouldRepaint(CustomPainter oldDelegate) => false;
}

我想使用flutter小部件来达到这种效果,您能给我一些建议还是实现该效果我必须做些什么?

谢谢

0 个答案:

没有答案