Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter - Is there a way to see which line of the code throws an error?

Tags:

flutter

dart

I am new to Flutter. So sorry if my question is silly...

In Flutter is there a way to see which line throws an error?

E.g. I have this in console.

enter image description here

And this in the stimulator.

enter image description here

Can I understand from it which line throws it?

like image 749
Shalugin Avatar asked Jan 20 '20 02:01

Shalugin


2 Answers

enter image description hereYou can see the line of code that has error in your screenshot bro, all you need to do is read it and we can see that the error is in #1.

it says that you story.dart has error on line 200

like image 143
Qonvex620 Avatar answered Oct 20 '22 09:10

Qonvex620


Using the console See all the files in blue on the console? They represent all files (yours and those from the Flutter SDK and libraries) connected to the error message.

There is a high chance that the line that throws an/the error is not from the libraries but from your own code. So, what do you have to do?

Scan all files in blue that are from your own code and look for the one that has the strongest relationship with the error message.

For example, in your case, story.dart is your own code. Ctrl + click on story.dart files in blue to see the line that may have caused the error/exception. In your case, there is a high chance that you are trying to read or delete an element from an empty list.

You can also use the VSCode debugger to do this

like image 29
orimdominic Avatar answered Oct 20 '22 09:10

orimdominic