Skip to content

Commit

Permalink
Update for web support. (#26)
Browse files Browse the repository at this point in the history
* Update for web support.

Update for web support.

* Update flutter_svg_provider.dart

Avoid `getFilterColor` returns `null`.
  • Loading branch information
Meatysoda authored Jan 5, 2022
1 parent 4291580 commit 36992c2
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/flutter_svg_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class Svg extends ImageProvider<SvgImageKey> {
),
clipToViewBox: false,
colorFilter: ColorFilter.mode(
key.color ?? Colors.transparent,
getFilterColor(key.color),
BlendMode.srcATop,
),
);
Expand All @@ -122,6 +122,15 @@ class Svg extends ImageProvider<SvgImageKey> {
// [SvgImageKey] instances will be compared instead.
@override
String toString() => '$runtimeType(${describeIdentity(path)})';

// Running on web with Colors.transparent may throws the exception `Expected a value of type 'SkDeletable', but got one of type 'Null'`.
static Color getFilterColor(color) {
if (kIsWeb && color == Colors.transparent) {
return const Color(0x01ffffff);
} else {
return color ?? Colors.transparent;
}
}
}

@immutable
Expand Down

0 comments on commit 36992c2

Please sign in to comment.