Open abhaysood opened 2 years ago
Issue is reproducible on stable
and master
.
In the code sample below, MyPainter2
uses Path..addArc
, which draws the shadow but MyPainter
which uses Path..lineTo
does not draw the shadow. Switch between the two classes to see the difference.
This reproduces on all platforms.
Steps to Reproduce
Checkout the code below where I create a custom painter "MyPainter". The painter draws a line from left to right of the screen and adds a shadow along the same path using
canvas.drawShadow
. Note that the shadow doesn't appear.Expected: A red color shadow should appear below the line. Actual: No shadow appears.
Additionally, I tried this same code by creating a path from a rect in which case the shadow appears.
Code sample
```dart import 'package:flutter/material.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( theme: ThemeData.light(), debugShowCheckedModeBanner: false, home: Scaffold( body: MyWidget(), ), ); } } class MyWidget extends StatelessWidget { @override Widget build(BuildContext context) { return Center( child: Container( color: const Color.fromARGB(255, 198, 198, 198), child: const CustomPaint( size: Size(double.infinity, 2), painter: MyPainter(), ), ), ); } } class MyPainter extends CustomPainter { const MyPainter(); @override void paint(Canvas canvas, Size size) { final paint = Paint() ..color = Colors.black ..style = PaintingStyle.stroke ..strokeWidth = 4; final path = Path()..lineTo(size.width, 0); canvas.drawPath(path, paint); canvas.drawShadow(path, Colors.red, 2, false); } @override bool shouldRepaint(covariant CustomPainter oldDelegate) => false; } ```Flutter doctor
``` Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 2.10.4, on macOS 11.6 20G165 darwin-x64, locale en-IN) [✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 13.2.1) [✓] Chrome - develop for the web [✓] Android Studio (version 2021.2) [✓] Android Studio (version 2020.3) [✓] IntelliJ IDEA Ultimate Edition (version 2021.1.2) [✓] IntelliJ IDEA Ultimate Edition (version 2021.2.3) [✓] IntelliJ IDEA Ultimate Edition (version 2021.2.3) [✓] VS Code (version 1.63.2) [✓] Connected device (1 available) [✓] HTTP Host Availability • No issues found ```