skip to Main Content

I am struggling to get an image from app’s documents directory. The image is called ’10 sept 202316/32/57′. And when I am trying to fetch it, I get this error:

Cannot retrieve length of file, path = ‘…/10 sept 202316/32/57’

It seems that Flutter considers ‘/10 sept 202316’ and ‘/32’ in the name of file as paths to subdirectories which is not the case. I wonder if there is a way to explain Flutter that those are actually parts of the file name?

P.S: Dunno if it matters, but the image is originally saved from the same App written on Swift (which I am currently rewriting on Flutter). And in Swift original file name was ’10 sept 202316:32:57, but for some reason when it’s saved to app’s directory all ‘:’ are changed to ‘/’

2

Answers


  1. Chosen as BEST ANSWER

    Looks like I found a workaround. Loop through all files in directory and rename those containing '/'


  2. I’ve searched a bit about this issue,

    Having special chars in file names is often not recommended, especially because those characters might have some unwanted side effects depending on the programming language we are using, and in the specific case of the / character, it means different things depending on the Operating System, or environment that is running your application.

    Notice that a / in a web application represents a subroute for the path, in Linux means it’s a subdirectory, while in Windows the same char for that is the inverted bar , which is also used to escape reserved characters in a lot of programming languages.

    // Comment Example:
    /* Multi-line comment Example */
    n -> new line
    t -> tab space
    print(" This is an " escaped quote")
    

    There are some recent bug-tracking issues regarding using special chars in file names for Flutter, which might or might not be related to your issue.

    If you’d like, try to escape the problematic character from the file names.
    If you are using strings for the file names, try to escape the problematic chars from the file name string, by replacing / with /.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search