

Flutter/Dart 获取当前的 stacktrace - 技术小黑屋
source link: https://droidyue.com/blog/2021/12/09/how-to-get-current-stacktrace-in-dart-flutter/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Flutter/Dart 获取当前的 Stacktrace
Dec 9th, 2021
出现异常时获取 stacktrace
void _printException() {
try {
1 ~/ 0;
} catch (e, s) {
print('_printException $e; $s');
}
}
对应的 stacktrace 日志信息
_printException IntegerDivisionByZeroException; #0 int.~/ (dart:core-patch/integers.dart:30:7)
#1 _printException (file:///Users/androidyue/Documents/self_host/dart_current_stacktrace/bin/dart_current_stacktrace.dart:10:7)
#2 main (file:///Users/androidyue/Documents/self_host/dart_current_stacktrace/bin/dart_current_stacktrace.dart:3:3)
#3 _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:281:32)
#4 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
非异常出现时获取 stacktrace
如果只是想获取当前 stacktrace,比如用来确定某些方法的执行调用场景。
- 可以通过人为制造 异常 的方式来进行输出打印。
void _printCurrentStacktrace() {
try {
throw 'printCurrentStacktrace';
} catch (e, s) {
print('_printCurrentStacktrace;$s');
}
}
- 不人为制造异常得到 stacktrace(使用
StackTrace.current
)
void _printCurrentStacktraceV2() {
print('_printCurrentStacktraceV2 ${StackTrace.current}');
}

Posted by androidyue Dec 9th, 2021
Dart, Flutter, Stacktrace, Thread
Related Issues not found
Please contact @droidyuecom to initialize the comment
Recommend
-
9
根据StackTrace中java行号定位jsp行号的方法 七月 7, 2019 0 条评论 在做相关插桩的研究的过程中发现针对jsp中编写java代码的情况,因为容...
-
15
On the first ever completely non-technical episode of Stacktrace, John and Rambo answer #askstacktrace questions about everything from local holiday traditions to what their favorite airplanes are. Sponsored by MacS...
-
3
Why is Wrong Stacktrace Printed for My Code?2021-03-13Python531 words 3 mins read 23 times readThe other day, when I was updating the soruce code wit...
-
6
Copy link Collaborator cor3ntin ...
-
5
There are things you can do in Java you rarely see, generally because there is no use for it. However, there are some unusual things in Java that could be surprisingly useful. Chronicle Software
-
6
Flutter 中获取 TextField 中 Text 内容 Feb 27th, 2022 在Flutter 中,TextField 是一个用来输入 文本的 控件。使用起来也很简单,比如这样,就可以轻松实现一个 TextField 来接收用户的输入内容。 TextField(...
-
6
Guides About the Author
-
7
Closed Bug 1007656...
-
6
Flutter Webview 处理回退历史 Jul 12th, 2022 在 App 开发中,我们总会遇到使用 WebView 的情况, 比如 我们打开了 网页A,然后点击 A 中的链接跳转到 B。如果这个时候,我们按一下系统的返回键,预期的应...
-
12
Flutter 处理 Error Setter Not Found AsciiChar 问题 Oct 11th, 2022 当我们进行了 flutter 升级后,有时候运行程序会发现无法...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK