Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid value: Not in inclusive range #2

Open
davidcz95 opened this issue Jun 23, 2021 · 3 comments
Open

Invalid value: Not in inclusive range #2

davidcz95 opened this issue Jun 23, 2021 · 3 comments

Comments

@davidcz95
Copy link

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

@izzabellerina
Copy link

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

@davidcz95
Copy link
Author

davidcz95 commented Jun 24, 2021

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.

@izzabellerina
Copy link

@davidcz95 Thank you so much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants