Skip to content

Commit ebd6f0a

Browse files
committed
feature: 增加异常处理相关
1 parent 6f4c4a5 commit ebd6f0a

5 files changed

Lines changed: 44 additions & 1 deletion

File tree

app/error.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Flutter异常捕获
2+
3+
- `FlutterError.onError`方法。
4+
- `ErrorWidget`组件。
5+
6+
## 参考资料
7+
8+
- https://juejin.cn/post/7024043812188061703

dart_language/expections.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,30 @@
11
---
22
author: 张果
33
created_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里,后续识别不到导致的错误?

testing/debug_programmatically.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# 编程调试
2+
3+
官方文档:https://docs.flutter.dev/testing/code-debugging
4+
5+
实践:在APP中添加“开发者模式”,通过上述功能实现。

testing/integration_test.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# 集成测试
2+
3+
浏览器配置:https://docs.flutter.dev/testing/integration-tests#running-in-a-browser

widgets/boxconstraints.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
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

0 commit comments

Comments
 (0)