Is there any way to use .svg as app icon in flutter?

Viewed 2082

I was using flutter_launcher_icons package to set default app icon in flutter app (specially for android). Now, I have to use a svg file as icon as png icon is not showing correctly in Dark theme android versions in notification bar. But it is showing some errors of NoDecoderForImageFormatException.

pubspec.yaml file config :


flutter_icons:
  #  image_path: "assets/images/icon-128x128.png"
  android: "launcher_icon"
  ios: true
  image_path: "assets/images/logo.svg"

Here is the output of flutter pub run flutter_launcher_icons:main command.


pub run flutter_launcher_icons:main
  ════════════════════════════════════════════
     FLUTTER LAUNCHER ICONS (v0.9.0)                               
  ════════════════════════════════════════════
  
• Creating default icons Android

✓ Successfully generated launcher icons
Unhandled exception:

✗ ERROR: NoDecoderForImageFormatException 
assets/images/logo.svg
#0      decodeImageFile (package:flutter_launcher_icons/utils.dart:37:5)
#1      createDefaultIcons (package:flutter_launcher_icons/android.dart:35:24)
#2      createIconsFromConfig (package:flutter_launcher_icons/main.dart:103:5)
#3      createIconsFromArguments (package:flutter_launcher_icons/main.dart:60:7)
#4      main (file:///home/jspw/Android/Sdk/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_launcher_icons-0.9.0/bin/main.dart:6:3)
#5      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:281:32)
#6      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
pub finished with exit code 255

1 Answers

The package flutter_launcher_icons only uses PNG images to create all the different sizes of logos (hdpi, mdpi, xhdpi etc...)

If you have a problem with Android, did you try to use the adaptive_icon_background and adaptive_icon_foreground attribute?

Related