在Flutter中有没有一种方法可以将.svg作为应用程序图标使用?

4

我正在使用flutter_launcher_icons包在Flutter应用程序中设置默认应用程序图标(特别是针对Android)。 现在,我必须使用一个svg文件作为图标,因为在通知栏的暗主题Android版本中,png图标显示不正确。 但是它会显示一些NoDecoderForImageFormatException错误。

pubspec.yaml文件配置:


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

这里是运行flutter pub run flutter_launcher_icons:main命令的输出结果。


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


你找到路了吗? - undefined
1个回答

1

flutter_launcher_icons只使用PNG图像来创建所有不同大小的标志(hdpi,mdpi,xhdpi等...)

如果您在Android上遇到问题,是否尝试使用adaptive_icon_backgroundadaptive_icon_foreground属性?


通知图标完全变暗,而主要图标则是彩色的。在黑暗主题下,只有图标的形状是可理解的。 - Mehedi Hasan Shifat
你尝试使用 adaptive_icon_foreground 属性了吗? - BLKKKBVSIK

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接