Skip to content
pubscout

source_map_stack_trace

2.1.2, released 2 years ago by tools.dart.dev

Converts dart2js-compiled JavaScript stack traces into readable native Dart stack traces.

WASM-readyQuiet but busy
$ flutter pub add source_map_stack_trace
Source repository

What it does

It maps obfuscated or minified JavaScript stack traces generated by dart2js back to the original Dart source code and line numbers using source maps. This makes debugging web apps compiled from Dart much easier.

AI-written summary of version 2.1.2, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You are debugging a Flutter or Dart web application compiled with dart2js.
  • You need to translate JS stack traces to original Dart files and line numbers.

Skip it when

  • You are working exclusively on mobile or desktop native targets where dart2js is not used.
  • You do not have access to the source maps generated during compilation.

Strengths

  • Seamlessly converts cryptic JS stack traces into readable Dart ones.
  • Handles mapping for package URIs and dart: SDK libraries.

Weaknesses

  • Requires proper source maps to be generated and provided alongside the stack trace.
  • Limited utility outside of Dart web environments.

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
3
import 'package:source_map_stack_trace/source_map_stack_trace.dart';

void main() {
  var jsTrace = // Get a StackTrace generated by dart2js.
  var mapping = // Get a source map mapping the JS to the Dart source.

  var dartTrace = mapStackTrace(jsTrace, sourceMap);
  print(dartTrace);
}

Alternatives

Packages that do the same job and could replace source_map_stack_trace.

Works with

Packages commonly used together with source_map_stack_trace: ones it builds on, ones built on it, and its own family.