Skip to content

Commit

Permalink
Warn about invalid arguments to ColorFilter.mode (#32269)
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-simmons authored Apr 6, 2022
1 parent 5f2b566 commit fe6a51a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/web_ui/lib/src/engine/canvaskit/canvaskit_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ class SkMaskFilter {

@JS()
class SkColorFilterNamespace {
external SkColorFilter MakeBlend(Float32List color, SkBlendMode blendMode);
external SkColorFilter? MakeBlend(Float32List color, SkBlendMode blendMode);
external SkColorFilter MakeMatrix(
Float32List matrix, // 20-element matrix
);
Expand Down
6 changes: 5 additions & 1 deletion lib/web_ui/lib/src/engine/canvaskit/color_filter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,14 @@ class CkBlendModeColorFilter extends CkColorFilter {

@override
SkColorFilter _initRawColorFilter() {
return canvasKit.ColorFilter.MakeBlend(
final SkColorFilter? filter = canvasKit.ColorFilter.MakeBlend(
toSharedSkColor1(color),
toSkBlendMode(blendMode),
);
if (filter == null) {
throw ArgumentError('Invalid parameters for blend mode ColorFilter');
}
return filter;
}

@override
Expand Down

0 comments on commit fe6a51a

Please sign in to comment.