forked from firka/flutter
549dd82f2ff1ab43d78be4285e0bc110e5bccb7a
A division by zero happens if the shadow color is fully transparent, and
the NaNs are getting assigned to the RGB values of the paint color being
handed to the rrect shadow draw. This doesn't cause a problem when wide
gamut is off because NaN output ends up being interpreted as zero (thus
making the shadow output fully transparent black, which happens to be
the expected and correct result). However, when a wide gamut attachment
is present, the NaN output ends up being interpreted as a negative
value.
Reproduction app:
```dart
import 'package:flutter/material.dart';
void main() => runApp(const GeneralDialogApp());
class EvilPainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
final Rect rect = Offset.zero & size;
canvas.drawPaint(Paint()..color = Colors.white);
canvas.saveLayer(null, Paint()..blendMode = BlendMode.srcOver);
canvas.drawShadow(Path()..addRect(Rect.fromLTRB(100, 100, 300, 300)),
Colors.black54, 15, false);
canvas.drawShadow(Path()..addRect(Rect.fromLTRB(100, 100, 300, 300)),
Colors.black54, 15, false);
canvas.drawShadow(Path()..addRect(Rect.fromLTRB(100, 100, 300, 300)),
Colors.transparent, 15, false);
canvas.restore();
}
@override
bool shouldRepaint(EvilPainter oldDelegate) => false;
@override
bool shouldRebuildSemantics(EvilPainter oldDelegate) => false;
}
class GeneralDialogApp extends StatelessWidget {
const GeneralDialogApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
restorationScopeId: 'app',
home: CustomPaint(painter: EvilPainter()),
);
}
}
```
Before:

After:

Description
No description provided
Languages
Dart
75.4%
C++
16.4%
Objective-C++
2.7%
Java
2.7%
Objective-C
0.6%
Other
1.8%