skip to Main Content

According to this problem, I figured out, on my m1 mac mini, flutter changes the accented svg assets filename, when it builds the android or ios image.

For example these files,

AA.svg
AÓ.svg
AÍ.svg

are renamed to

AA.svg
AO%CC%81.svg
AI%CC%81.svg

How can I open these renamed files in flutter with the SvgPicture.asset() function?

I tried to open as AÓ.svg, and another way, directly open the accented files as SvgPicture.asset("media/cikkcsoport/AO%CC%81.svg"), and I still get the Unable to load asset: media/cikkcsoport/AO%CC%81.svg error message.

UPDATE

I created a test project, and I use the same svg files as in my main.
In the test project, the accented svg’s also work.
When I check the simulator filesystem, I see, flutter use a different filename encoding in this project.

For example, I get these files:

A%C3%81.svg
A%C3%8D.svg
A%C3%93.svg

Where can I change my flutter project filename encoding?

2

Answers


  1. Chosen as BEST ANSWER

    I couldn't find out, what flutter settings causes the difference in the filename encoding.

    Maybe I created my main flutter project from the command line, and the test project from VSCode with the Flutter: New Project function.

    I can confirm, it is some argument, making the difference, at creating the flutter project.

    I created a new flutter project from VSCode, and copy the relevant files to it.

    Now I can open all my svg-s.


  2. That has nothing to do with flutter, the urls are encoded that way, so you just need to use Uri.decodeFull() from the Uri class to get a valid string.

    final base_name = 'media/cikkcsoport/AÓ.svg';
    final encoded_name = Uri.encodeFull(base_name);   
    final decoded_name = Uri.decodeFull(encoded_name); 
    print('($base_name) $encoded_name -> $decoded_name');
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search