fix: select platform-compatible icon format in find_platform_image#6381
fix: select platform-compatible icon format in find_platform_image#6381HG-ha wants to merge 3 commits intoflet-dev:mainfrom
Conversation
find_platform_image uses glob.glob to match icon files by base name, then blindly picks images[0]. On NTFS the alphabetical ordering causes .icns (macOS-only) to be selected over .ico/.png when building for Windows, which makes flutter_launcher_icons fail with NoDecoderForImageFormatException. Introduce a per-platform preference list so the method picks the most appropriate format for the target: .ico first on Windows, .icns first on macOS, .png as universal fallback everywhere. Made-with: Cursor
| Find first matching image file by base name and queue it for copy. | ||
| Find the best matching image file for the current target platform. | ||
|
|
||
| When multiple files share the same base name (e.g. ``icon.icns``, |
There was a problem hiding this comment.
Thanks for the PR! Can you remove all double ticks "``" in comments please?
There was a problem hiding this comment.
Done, removed all double backticks. Thanks for the review!
There was a problem hiding this comment.
:) Well, you removed all ticks, not replaced them with a single ticks. It's fine, it's a known issue with Claude/Codex. Put single ticks back please.
There was a problem hiding this comment.
I now understand your meaning. The correction has been made.
|
Your PR adds Also, there is an alternative, simpler approach: Instead of a full preference dict, you could just exclude known-incompatible extensions per platform (e.g. strip |
Summary
find_platform_imageusesglob.globto match icon files by base name, then blindly picksimages[0]. On NTFS the alphabetical ordering causes.icns(macOS-only) to be selected over.ico/.pngwhen building for Windows, makingflutter_launcher_iconsfail withNoDecoderForImageFormatException.This PR introduces a per-platform preferred extension list so that the most appropriate format is selected for each build target:
.ico>.png> others.icns>.png> others.png> othersUnrecognized extensions still sort last, so existing setups with only
.pngfiles are completely unaffected.How to reproduce
icon.icns,icon.ico, andicon.pnginsrc/assets/flet build windows -vChanges
sdk/python/packages/flet-cli/src/flet_cli/commands/build_base.py:_PLATFORM_IMAGE_PREFERENCEclass variable mapping each target platform to a ranked list of preferred image extensionsfind_platform_imageto sort glob results by platform preference before selecting the best matchSummary by Sourcery
Bug Fixes: