Flutter stutter II


Welcome back to another edition of Flutter Stutter, where we talk about the problems with running Flutter apps in debug mode. This week, I want to go over a couple of issues that prevent debug mode from even starting.

One thing that can terminate debug mode before it even starts is if you’re trying to debug a file that doesn’t have a .dart extension. This can happen when you’re in a text file, like I often am because I keep notes on all my Flutter projects in a “Notes.txt” file. You’ll usually get an error message like “you don’t have an extension for debugging…” and if you’ve never seen this before, it might not be so obvious what the solution is. What you’ll want to do is switch the focus to another file, by clicking on a file with a .dart extension, and then hit “start debugging.”

Another reason for debug mode not launching is if there are any errors in your program. Here, we’re talking about critical errors, not style or syntax errors, that will cause the program to crash. If you click into the “problems” tab in the lower left portion of your IDE, at least that’s where it is VS code, you’ll see a list of issues that should be looked at. A lot of times these issues don’t prevent the program from launching because they aren’t too serious. You might see problem messages like “prefer const with constant constructors,” “unused import: <package name>,” and “avoid ‘print’ calls in production code.” These are all minor issues or suggestions to optimize the code. They are usually preceded by an icon with the letter “i” in a blue circle. In contrast, problem messages that start with a red “x” icon need to be looked at, as debug mode will not start if they exist. These problems usually indicate that something is wrong with the code, so click on the message and it will direct you to the line of code where the problem lies. Try hovering the mouse over the problematic code. Flutter is pretty smart and will suggest a “quick fix” that very often resolves the issue.

Alright, that’s it for this week’s Flutter Stutter. Come back next week for the final installment.

Print Friendly, PDF & Email

Leave a Reply

Your email address will not be published. Required fields are marked *