Skip to content

Commit

Permalink
Warn about invalid arguments to ColorFilter.mode
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-simmons committed Mar 28, 2022
1 parent ca2f95c commit 9c20cb0
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 9c20cb0

Please sign in to comment.