From e3d1fcf5953e71709bf767c6f684ba5bbc869169 Mon Sep 17 00:00:00 2001 From: Kirpal Demian Date: Fri, 21 Jun 2024 23:11:35 -0400 Subject: [PATCH] fix: provide theme to SvgAssetLoader instead of SvgPicture (#532) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## What does this change? Since version 5.5.0+1, the `SvgTheme` no longer works. It doesn't work because flutter_svg has deprecated using the `theme` with the `SvgPicture` constructor, and suggests that you pass the theme to the bytes loader instead. Fixes #531 🎯 ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) --- examples/example/lib/gen/assets.gen.dart | 3 +-- examples/example_resources/lib/gen/assets.gen.dart | 3 +-- packages/core/lib/generators/integrations/svg_integration.dart | 3 +-- packages/core/test_resources/actual_data/assets.gen.dart | 3 +-- .../test_resources/actual_data/assets_directory_path.gen.dart | 3 +-- .../actual_data/assets_package_parameter.gen.dart | 3 +-- .../test_resources/actual_data/assets_parse_metadata.gen.dart | 3 +-- .../actual_data/assets_svg_integrations.gen.dart | 3 +-- packages/runner/example/lib/gen/assets.gen.dart | 3 +-- 9 files changed, 9 insertions(+), 18 deletions(-) diff --git a/examples/example/lib/gen/assets.gen.dart b/examples/example/lib/gen/assets.gen.dart index 11b4264e..9efacf68 100644 --- a/examples/example/lib/gen/assets.gen.dart +++ b/examples/example/lib/gen/assets.gen.dart @@ -318,7 +318,7 @@ class SvgGenImage { ? AssetBytesLoader(_assetName, assetBundle: bundle, packageName: package) : SvgAssetLoader(_assetName, - assetBundle: bundle, packageName: package), + assetBundle: bundle, packageName: package, theme: theme), key: key, matchTextDirection: matchTextDirection, width: width, @@ -329,7 +329,6 @@ class SvgGenImage { placeholderBuilder: placeholderBuilder, semanticsLabel: semanticsLabel, excludeFromSemantics: excludeFromSemantics, - theme: theme, colorFilter: colorFilter ?? (color == null ? null : ColorFilter.mode(color, colorBlendMode)), clipBehavior: clipBehavior, diff --git a/examples/example_resources/lib/gen/assets.gen.dart b/examples/example_resources/lib/gen/assets.gen.dart index d1fce046..0ce358a5 100644 --- a/examples/example_resources/lib/gen/assets.gen.dart +++ b/examples/example_resources/lib/gen/assets.gen.dart @@ -186,7 +186,7 @@ class SvgGenImage { ? AssetBytesLoader(_assetName, assetBundle: bundle, packageName: package) : SvgAssetLoader(_assetName, - assetBundle: bundle, packageName: package), + assetBundle: bundle, packageName: package, theme: theme), key: key, matchTextDirection: matchTextDirection, width: width, @@ -197,7 +197,6 @@ class SvgGenImage { placeholderBuilder: placeholderBuilder, semanticsLabel: semanticsLabel, excludeFromSemantics: excludeFromSemantics, - theme: theme, colorFilter: colorFilter ?? (color == null ? null : ColorFilter.mode(color, colorBlendMode)), clipBehavior: clipBehavior, diff --git a/packages/core/lib/generators/integrations/svg_integration.dart b/packages/core/lib/generators/integrations/svg_integration.dart index dc29412e..247afb1c 100644 --- a/packages/core/lib/generators/integrations/svg_integration.dart +++ b/packages/core/lib/generators/integrations/svg_integration.dart @@ -62,7 +62,7 @@ ${isPackage ? "\n static const String package = '$packageName';" : ''} return SvgPicture( _isVecFormat ? AssetBytesLoader(_assetName, assetBundle: bundle, packageName: package) : - SvgAssetLoader(_assetName, assetBundle: bundle, packageName: package), + SvgAssetLoader(_assetName, assetBundle: bundle, packageName: package, theme: theme), key: key, matchTextDirection: matchTextDirection, width: width, @@ -73,7 +73,6 @@ ${isPackage ? "\n static const String package = '$packageName';" : ''} placeholderBuilder: placeholderBuilder, semanticsLabel: semanticsLabel, excludeFromSemantics: excludeFromSemantics, - theme: theme, colorFilter: colorFilter ?? (color == null ? null : ColorFilter.mode(color, colorBlendMode)), clipBehavior: clipBehavior, cacheColorFilter: cacheColorFilter, diff --git a/packages/core/test_resources/actual_data/assets.gen.dart b/packages/core/test_resources/actual_data/assets.gen.dart index c84322a7..623750cb 100644 --- a/packages/core/test_resources/actual_data/assets.gen.dart +++ b/packages/core/test_resources/actual_data/assets.gen.dart @@ -276,7 +276,7 @@ class SvgGenImage { ? AssetBytesLoader(_assetName, assetBundle: bundle, packageName: package) : SvgAssetLoader(_assetName, - assetBundle: bundle, packageName: package), + assetBundle: bundle, packageName: package, theme: theme), key: key, matchTextDirection: matchTextDirection, width: width, @@ -287,7 +287,6 @@ class SvgGenImage { placeholderBuilder: placeholderBuilder, semanticsLabel: semanticsLabel, excludeFromSemantics: excludeFromSemantics, - theme: theme, colorFilter: colorFilter ?? (color == null ? null : ColorFilter.mode(color, colorBlendMode)), clipBehavior: clipBehavior, diff --git a/packages/core/test_resources/actual_data/assets_directory_path.gen.dart b/packages/core/test_resources/actual_data/assets_directory_path.gen.dart index b5ddfc8a..0071ab5d 100644 --- a/packages/core/test_resources/actual_data/assets_directory_path.gen.dart +++ b/packages/core/test_resources/actual_data/assets_directory_path.gen.dart @@ -194,7 +194,7 @@ class SvgGenImage { ? AssetBytesLoader(_assetName, assetBundle: bundle, packageName: package) : SvgAssetLoader(_assetName, - assetBundle: bundle, packageName: package), + assetBundle: bundle, packageName: package, theme: theme), key: key, matchTextDirection: matchTextDirection, width: width, @@ -205,7 +205,6 @@ class SvgGenImage { placeholderBuilder: placeholderBuilder, semanticsLabel: semanticsLabel, excludeFromSemantics: excludeFromSemantics, - theme: theme, colorFilter: colorFilter ?? (color == null ? null : ColorFilter.mode(color, colorBlendMode)), clipBehavior: clipBehavior, diff --git a/packages/core/test_resources/actual_data/assets_package_parameter.gen.dart b/packages/core/test_resources/actual_data/assets_package_parameter.gen.dart index b448067f..99ae5268 100644 --- a/packages/core/test_resources/actual_data/assets_package_parameter.gen.dart +++ b/packages/core/test_resources/actual_data/assets_package_parameter.gen.dart @@ -192,7 +192,7 @@ class SvgGenImage { ? AssetBytesLoader(_assetName, assetBundle: bundle, packageName: package) : SvgAssetLoader(_assetName, - assetBundle: bundle, packageName: package), + assetBundle: bundle, packageName: package, theme: theme), key: key, matchTextDirection: matchTextDirection, width: width, @@ -203,7 +203,6 @@ class SvgGenImage { placeholderBuilder: placeholderBuilder, semanticsLabel: semanticsLabel, excludeFromSemantics: excludeFromSemantics, - theme: theme, colorFilter: colorFilter ?? (color == null ? null : ColorFilter.mode(color, colorBlendMode)), clipBehavior: clipBehavior, diff --git a/packages/core/test_resources/actual_data/assets_parse_metadata.gen.dart b/packages/core/test_resources/actual_data/assets_parse_metadata.gen.dart index 9eaa2101..8a343ff4 100644 --- a/packages/core/test_resources/actual_data/assets_parse_metadata.gen.dart +++ b/packages/core/test_resources/actual_data/assets_parse_metadata.gen.dart @@ -285,7 +285,7 @@ class SvgGenImage { ? AssetBytesLoader(_assetName, assetBundle: bundle, packageName: package) : SvgAssetLoader(_assetName, - assetBundle: bundle, packageName: package), + assetBundle: bundle, packageName: package, theme: theme), key: key, matchTextDirection: matchTextDirection, width: width, @@ -296,7 +296,6 @@ class SvgGenImage { placeholderBuilder: placeholderBuilder, semanticsLabel: semanticsLabel, excludeFromSemantics: excludeFromSemantics, - theme: theme, colorFilter: colorFilter ?? (color == null ? null : ColorFilter.mode(color, colorBlendMode)), clipBehavior: clipBehavior, diff --git a/packages/core/test_resources/actual_data/assets_svg_integrations.gen.dart b/packages/core/test_resources/actual_data/assets_svg_integrations.gen.dart index 5c8dc7ad..4d9b32b1 100644 --- a/packages/core/test_resources/actual_data/assets_svg_integrations.gen.dart +++ b/packages/core/test_resources/actual_data/assets_svg_integrations.gen.dart @@ -81,7 +81,7 @@ class SvgGenImage { ? AssetBytesLoader(_assetName, assetBundle: bundle, packageName: package) : SvgAssetLoader(_assetName, - assetBundle: bundle, packageName: package), + assetBundle: bundle, packageName: package, theme: theme), key: key, matchTextDirection: matchTextDirection, width: width, @@ -92,7 +92,6 @@ class SvgGenImage { placeholderBuilder: placeholderBuilder, semanticsLabel: semanticsLabel, excludeFromSemantics: excludeFromSemantics, - theme: theme, colorFilter: colorFilter ?? (color == null ? null : ColorFilter.mode(color, colorBlendMode)), clipBehavior: clipBehavior, diff --git a/packages/runner/example/lib/gen/assets.gen.dart b/packages/runner/example/lib/gen/assets.gen.dart index d895b0c0..74af6de4 100644 --- a/packages/runner/example/lib/gen/assets.gen.dart +++ b/packages/runner/example/lib/gen/assets.gen.dart @@ -293,7 +293,7 @@ class SvgGenImage { ? AssetBytesLoader(_assetName, assetBundle: bundle, packageName: package) : SvgAssetLoader(_assetName, - assetBundle: bundle, packageName: package), + assetBundle: bundle, packageName: package, theme: theme), key: key, matchTextDirection: matchTextDirection, width: width, @@ -304,7 +304,6 @@ class SvgGenImage { placeholderBuilder: placeholderBuilder, semanticsLabel: semanticsLabel, excludeFromSemantics: excludeFromSemantics, - theme: theme, colorFilter: colorFilter ?? (color == null ? null : ColorFilter.mode(color, colorBlendMode)), clipBehavior: clipBehavior,