demangleStackTrace property

StackTraceDemangler demangleStackTrace
getter/setter pair

Called by the Flutter framework before attempting to parse a StackTrace.

Some StackTrace implementations have a different toString format from what the framework expects, like ones from package:stack_trace. To make sure we can still parse and filter mangled StackTraces, the framework first calls this function to demangle them.

This should be set in any environment that could propagate an unusual stack trace to the framework. Otherwise, the default behavior is to assume all stack traces are in a format usually generated by Dart.

The following example demangles package:stack_trace traces by converting them into VM traces, which the framework is able to parse:

FlutterError.demangleStackTrace = (StackTrace stack) {
  // Trace and Chain are classes in package:stack_trace
  if (stack is Trace) {
    return stack.vmTrace;
  }
  if (stack is Chain) {
    return stack.toTrace().vmTrace;
  }
  return stack;
};

Implementation

static StackTraceDemangler demangleStackTrace = _defaultStackTraceDemangler;