Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Dart 画布上的自定义画师路径附加线_Dart_Flutter_Flutter Layout - Fatal编程技术网

Dart 画布上的自定义画师路径附加线

Dart 画布上的自定义画师路径附加线,dart,flutter,flutter-layout,Dart,Flutter,Flutter Layout,我在需要画线的地方使用CustomPainter class ShapesPainter extends CustomPainter { @override void paint(Canvas canvas, Size size) { final Paint firstPaint = Paint(); firstPaint.color = const Color.fromARGB(255, 236, 0, 140); final Path firstPath =

我在需要画线的地方使用CustomPainter

class ShapesPainter extends CustomPainter {
  @override
  void paint(Canvas canvas, Size size) {
    final Paint firstPaint = Paint();
    firstPaint.color = const Color.fromARGB(255, 236, 0, 140);

    final Path firstPath = Path();
    firstPath.lineTo(size.width, 0);
    firstPath.lineTo(0, size.height * 0.10);
    firstPath.close();
    canvas.drawShadow(firstPath, Colors.black87, 2.0, false);
    canvas.drawPath(firstPath, firstPaint);
 }
}
我需要在屏幕周围留有边距,以便在容器中使用边距:

........
Container(
          color: Colors.white,
          margin:
              EdgeInsets.only(top: 60.0, bottom: 20.0, left: 15.0, right: 15.0),
          child: Container(
            child: CustomPaint(
              painter: ShapesPainter(),
              child: Container(
.......
我需要在我的自定义路径下画一个阴影,我在我的构建小部件中使用了anvas.drawShadow方法,但左侧也有一个小阴影,请参见下面的图像我指出了一个错误,这里是指向小阴影的箭头:

由于我无法为路径上的
canvas.drawShadow
效果找到任何解决方案,我只是在阴影路径的顶部创建了另一个路径(),解决了这个问题,但这有点像黑客

final Path firstPathb = Path();
firstPathHide.lineTo(size.width, 0);
firstPathHide.lineTo(-10.0, size.height * 0.10);
firstPathHide.close();
canvas.drawPath(firstPathHide, firstPaint);