问题
If some code returns a future and determines that the future should return "Error" or "Exception" how can a stack trace be passed to Completer.completeException(exception, stackTrace);
回答1:
If I understand correctly: when you catch an exception in dart, you can also catch the stack trace:
try {
// something
} catch(e, stacktrace) {
myCompleter.completeException(e, stacktrace);
}
回答2:
If you're not in a catch block, you can use StackTrace.current
来源:https://stackoverflow.com/questions/13963837/how-do-you-get-the-current-stacktrace-in-dart-for-a-completer-completeexception