Closed
Description
When an exception is thrown in a Flutter Web application, the stack trace lists .js
files instead of .dart
files, which makes it difficult to reason about and debug.
For example, type in the following application:
void main() {
throw "My Hello World Exception";
}
When I run this I get:
Error: My Hello World Exception
at Object.throw_ [as throw] (http://localhost:43337/dart_sdk.js:5041:11)
at main$ (http://localhost:43337/packages/test2/main.dart.lib.js:12:15)
at main (http://localhost:43337/web_entrypoint.dart.lib.js:33:29)
at main.next (<anonymous>)
at http://localhost:43337/dart_sdk.js:37403:33
at _RootZone.runUnary (http://localhost:43337/dart_sdk.js:37274:59)
at _FutureListener.thenAwait.handleValue (http://localhost:43337/dart_sdk.js:32530:29)
at handleValueCallback (http://localhost:43337/dart_sdk.js:33057:49)
at Function._propagateToListeners (http://localhost:43337/dart_sdk.js:33095:17)
at _Future.new.[_completeWithValue] (http://localhost:43337/dart_sdk.js:32943:23)
at http://localhost:43337/dart_sdk.js:32194:46
at _RootZone.runUnary (http://localhost:43337/dart_sdk.js:37274:59)
at _FutureListener.then.handleValue (http://localhost:43337/dart_sdk.js:32530:29)
at handleValueCallback (http://localhost:43337/dart_sdk.js:33057:49)
at Function._propagateToListeners (http://localhost:43337/dart_sdk.js:33095:17)
at _Future.new.[_completeWithValue] (http://localhost:43337/dart_sdk.js:32943:23)
at async._AsyncCallbackEntry.new.callback (http://localhost:43337/dart_sdk.js:32964:35)
at Object._microtaskLoop (http://localhost:43337/dart_sdk.js:37526:13)
at _startMicrotaskLoop (http://localhost:43337/dart_sdk.js:37532:13)
at http://localhost:43337/dart_sdk.js:33303:9
Breakpoints work correctly, so it seems that the JS <--> Dart mapping infrastructure does work correctly.
I'm using Android Studio and Chromium on Ubuntu 20.04.
Flutter doctor:
flutter doctor -v
[✓] Flutter (Channel stable, 2.2.3, on Linux, locale en_US.UTF-8)
• Flutter version 2.2.3 at /home/user/flutter
• Framework revision f4abaa0735 (7 weeks ago), 2021-07-01 12:46:11 -0700
• Engine revision 241c87ad80
• Dart version 2.13.4
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /home/user/Android/Sdk
• Platform android-30, build-tools 30.0.3
• Java binary at: /home/user/Downloads/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.8+0-b944-P17168821)
✗ Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/linux#android-setup for more details.
[✓] Chrome - develop for the web
• CHROME_EXECUTABLE = chromium
[✓] Android Studio (version 4.2)
• Android Studio at /home/user/Downloads/android-studio
• Flutter plugin version 58.0.1
• Dart plugin version 202.8488
• Java version OpenJDK Runtime Environment (build 11.0.8+0-b944-P17168821)
[✓] IntelliJ IDEA Ultimate Edition (version 2020.2)
• IntelliJ at /snap/intellij-idea-ultimate/current
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
[✓] Connected device (1 available)
• Chrome (web) • chrome • web-javascript • Chromium 86.0.4240.75 snap