Debug the Paused on exception
Issue
To debug the Paused on exception
issue in your Flutter web project, follow these steps:
-
Check the debug console for any error messages or stack traces that might provide more information about the exception.
-
If there are no visible errors, try pressing the “Resume” button (or F5) in VS Code to continue execution and see if the app proceeds or if it reveals more information about the exception.
-
If resuming doesn’t help, restart the app using the “Restart” button (Ctrl+Shift+F5) in VS Code. Note that in some cases, the
Paused on exception
message might persist even after restarting, which is a known issue. -
If the issue persists, try the following:
- Run Flutter clean and rebuild your project.
- Check your
pubspec.yaml
file for any recent changes or errors. - Disable and re-enable developer settings on your device if you’re using a physical device.
- Use the VS Code Flutter debugging toolbar to step through your code:
- Use “Step Over” (F10) to execute the current line and move to the next one.
- Use “Step Into” (F11) to dive into function calls.
- Use “Step Out” (Shift + F11) to complete the current function and return to the caller.
-
If you suspect the issue is related to asynchronous code, consider using the
completerex
package to help identify completers that never complete. -
Ensure that you don’t have any catch statements that might be swallowing exceptions.
-
If the app seems to be freezing, try running it in release mode using the
--release
flag to see if the issue persists. - As a last resort, use the binary chop method: comment out half of your code and gradually add it back until you identify the problematic section.
If none of these steps resolve the issue, you may need to provide more details about your specific code and the exact point where the exception occurs for further assistance.