Encountering image path format issue

43 Views Asked by At

Encountering image path format issue in Flutter: expected 'images/animal/dog.png' but VS Code generates 'images\animal\dog.png'. Is this a Flutter error or a logical consideration? Seeking guidance on resolution.

as shown here

1

There are 1 best solutions below

0
Marcin Wróblewski On BEST ANSWER

Your development machine is using Windows, which is using \ as directory delimiter. In contrary, Android, iOS, macOS, and Linux are using / for the same purpose.

VS Code is generating a file path valid for the OS it’s running on, but I presume you’re developing an app for different OS. If you’d develop for Windows it’ll be the correct path.

To automatically manage path delimiters per target platform in you app use the path package.