File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Flutter异常捕获
2+
3+ - ` FlutterError.onError ` 方法。
4+ - ` ErrorWidget ` 组件。
5+
6+ ## 参考资料
7+
8+ - https://juejin.cn/post/7024043812188061703
Original file line number Diff line number Diff line change 11---
22author : 张果
33created_at : 2021-11-12
4- updated_at : 2022-05-04
4+ updated_at : 2022-07-29
55---
66# 异常处理
77
8+ ## 理解异常信息
9+
10+ 怎么读报错信息?怎么复现报错信息?
11+
12+ 一个案例记录,之后考虑用个新案例替换。
13+
14+ 报错信息:
15+
16+ ```
17+ Null check operator used on a null value
18+
19+ This error occurs when you use a bang operator (!) on a nullable instance which wasn't initialized.
20+
21+ CourseWidget:file:///Users/zhangguo/QuantTide/qtclass-app/qtclass-client-flutter/test/course_route_test.dart:12:47
22+ ```
23+
24+ 其中,"12: 47" 是行数+(maybe)字符数。
25+
26+ 经过查找,错误原因是:Lectures属性实际上给了空值,!检查就会让它不通过。
27+
828## 变量作用域
929
1030如何解决变量在try里,后续识别不到导致的错误?
Original file line number Diff line number Diff line change 1+ # 编程调试
2+
3+ 官方文档:https://docs.flutter.dev/testing/code-debugging
4+
5+ 实践:在APP中添加“开发者模式”,通过上述功能实现。
Original file line number Diff line number Diff line change 1+ # 集成测试
2+
3+ 浏览器配置:https://docs.flutter.dev/testing/integration-tests#running-in-a-browser
Original file line number Diff line number Diff line change 1+ # BoxContraint
2+
3+ 异常信息:BoxConstraints forces an infinite width.
4+ 解决办法:套个Flexible。
5+ 参考资料:
6+ - https://docs.flutter.dev/development/ui/layout/box-constraints
7+ - https://stackoverflow.com/questions/52442724/boxconstraints-forces-an-infinite-width
You can’t perform that action at this time.
0 commit comments