dnfield / flutter_svg

SVG parsing, rendering, and widget library for Flutter
MIT License
1.66k stars 454 forks source link

Issues with rendering SVG with colorFilter #1026

Open ajimal1992 opened 7 months ago

ajimal1992 commented 7 months ago

Overview

Flutter SVG renders correctly for version 3.10.6 but rendered differently/wrongly for version 3.16.5 when used with colorFilter.

Expected result (running with version 3.10.6)

image

Actual result (running with version 3.16.5)

image
flutter doctor -v (running with version 3.10.6) ``` [✓] Flutter (Channel stable, 3.10.6, on macOS 14.2.1 23C71 darwin-arm64 (Rosetta), locale en-US) • Flutter version 3.10.6 on channel stable at /Users/ajmohame/sdk/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision f468f3366c (6 months ago), 2023-07-12 15:19:05 -0700 • Engine revision cdbeda788a • Dart version 3.0.6 • DevTools version 2.23.1 [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) • Android SDK at /Users/ajmohame/Library/Android/sdk • Platform android-34, build-tools 34.0.0 • Java binary at: /Users/ajmohame/Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 15.0.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15A507 • CocoaPods version 1.14.3 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2023.1) • Android Studio at /Users/ajmohame/Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314) [✓] IntelliJ IDEA Ultimate Edition (version 2023.2.2) • IntelliJ at /Applications/IntelliJ IDEA.app • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart [✓] VS Code (version 1.85.1) • VS Code at /Users/ajmohame/Applications/Visual Studio Code.app/Contents • Flutter extension version 3.80.0 [✓] Connected device (3 available) • iPhone 15 Pro Max (mobile) • AB39AAEC-B46A-4333-8BC6-EFC487072106 • ios • com.apple.CoreSimulator.SimRuntime.iOS-17-0 (simulator) • macOS (desktop) • macos • darwin-arm64 • macOS 14.2.1 23C71 darwin-arm64 (Rosetta) • Chrome (web) • chrome • web-javascript • Google Chrome 120.0.6099.199 [✓] Network resources • All expected network resources are available. • No issues found! ```
flutter doctor -v (running with version 3.16.5) ``` [✓] Flutter (Channel stable, 3.16.5, on macOS 14.2.1 23C71 darwin-arm64, locale en-US) • Flutter version 3.16.5 on channel stable at /Users/ajmohame/sdk/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 78666c8dc5 (3 weeks ago), 2023-12-19 16:14:14 -0800 • Engine revision 3f3e560236 • Dart version 3.2.3 • DevTools version 2.28.4 [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) • Android SDK at /Users/ajmohame/Library/Android/sdk • Platform android-34, build-tools 34.0.0 • Java binary at: /Users/ajmohame/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 15.0.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15A507 • CocoaPods version 1.14.3 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2023.1) • Android Studio at /Users/ajmohame/Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314) [✓] IntelliJ IDEA Ultimate Edition (version 2023.2.2) • IntelliJ at /Applications/IntelliJ IDEA.app • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart [✓] VS Code (version 1.85.1) • VS Code at /Users/ajmohame/Applications/Visual Studio Code.app/Contents • Flutter extension version 3.80.0 [✓] Connected device (3 available) • iPhone 15 Pro Max (mobile) • AB39AAEC-B46A-4333-8BC6-EFC487072106 • ios • com.apple.CoreSimulator.SimRuntime.iOS-17-0 (simulator) • macOS (desktop) • macos • darwin-arm64 • macOS 14.2.1 23C71 darwin-arm64 • Chrome (web) • chrome • web-javascript • Google Chrome 120.0.6099.199 [✓] Network resources • All expected network resources are available. • No issues found! ```
Sample code ```dart class TestView extends StatelessWidget { const TestView({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, body: Center( child: SvgPicture.asset( "assets/images/sample.svg", colorFilter: const ColorFilter.mode( Colors.green, BlendMode.color, ), ), ), ); } } ```
Sample SVG ```xml ```
sejong2401 commented 7 months ago

Try use BlendMode.srcATop instead of BlendMode.color.

3kdeveloper commented 7 months ago

try this: SvgPicture.asset('svg path', colorFilter: const ColorFilter.mode( AppColors.whiteColor, BlendMode.srcIn)),

jonahwilliams commented 4 months ago

Hi, Flutter team member here. If you're hitting Impeller specific rendering bugs you need to file them on the main flutter repo. We do not triage this repo, so these will be missed.