Skip to content

Invalid value: Not in inclusive range #2

Open

Description

@davidcz95

Hello,

Is there anything we can do for this annoying problem when the encoder encodes string with backslashes etc and then dart can't read it correctly and I am still getting Invalid value: Not in inclusive range when decoding it

Activity

  1. izzabellerina commented on Jun 24, 2021

    @izzabellerina

    same as me, RangeError (index): Invalid value: Not in inclusive range 0..1155: 1156

  2. davidcz95 commented on Jun 24, 2021

    @davidcz95
    Author

    Hi, I have found a solution for my use case so maybe it will help some1 too:

    • if you have a backslash "\" in your string you need to use string.replaceAll(r'\', r'\\'); and this I knew but what I didnt know is that in my case I am sending encodedPolyline to my database through rest api and I was doing string.replaceAll(r'\', r'\\'); on the string that I got back from the database but the string in the database was already without the backslash so I has to use that method on the string that I was sending to db so instead of 'y{zvH{n{fBV^V\PTLR' i had 'y{zvH{n{fBV^V\\PTLR' and in the process of sending it to the db one backslash is removed and when I get it back it is all ready to decode.
    • also the sign '^' is causing problems so also string.replaceAll('^', r'\^'); is needed.

    I hope I explained it clear enough and I also hope that no other signs will cause trouble but I will wrap decoding method in try & catch just to be safe.

  3. izzabellerina commented on Jul 1, 2021

    @izzabellerina

    @davidcz95 Thank you so much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions