i’m using flutter for an android and ios application and it works great but i have problems with debuging.
Why isn’t there more informations about errors and prints in the debug console? It’s the first language that i use that does not show the file and the line where the error occurs. The language is so modern in many ways but so basic in others.
Same thing with print() why doesn’t it show the line and file where it’s written up? I’m loosing my mind trying to find what cause errors in this language and i don’t get why it would be so hard when every other language does it..
Here a real world example, today i wake to my app giving this error :
E/flutter ( 3085): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: FormatException: Unexpected end of input (at
character 1)
How am i supposed to debug this ?.. I have no informations whatsoever..
Thanks in advance for any tips on this.
2
Answers
I see directly from your error that you are trying to parse some response (Probably a json), which is not a valid json. I guess the server is down, you are not authenticated, etc. and can not get the desired json to parse.
How would I proceed:
First consider where the error occurs. Does it happen when starting the app, when calling a page, when pressing a button, etc.?
Once you have found the location, simply set a breakpoint and step through until you find the cause of the error.
To your question:
Normally, there should be much more information there. Restart your IDE completely and look in the console, if there is not more there now.
I’ve had the same problem, it was really frustrating try to figure out what’s wrong. But I am finding Flutter docs really useful for any purpose. You’ve probably looked into it but in case you haven’t already I’m pasting the related link here. They explain everything.
In the case of your error, I can’t make a pretty good guess. There should be a lot more information in your logs. Maybe your Flutter project is not running on debugging mode. You can turn it on by simply running the app with the command line:
In case of you want to debug in high level, here is the DevTools docs which I find very useful too. Hope that helps.