Skip to content

Commit e2436d9

Browse files
committed
feature: 移动微盘草稿到代码仓库
1 parent c72f288 commit e2436d9

6 files changed

Lines changed: 117 additions & 1 deletion

File tree

dart_language/expections.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
author: 张果
3+
created_at: 2021-11-12
4+
updated_at: 2022-05-04
5+
---
6+
# 异常处理
7+
8+
## 变量作用域
9+
10+
如何解决变量在try里,后续识别不到导致的错误?
11+
12+
把变量的声明写到函数前面。本质上这是一个作用域的问题。比如
13+
14+
```dart
15+
Response response;
16+
try {
17+
response = <....>;
18+
}
19+
catch (e) {
20+
throw 'message';
21+
}
22+
return response.data;
23+
```
24+
25+
## 自定义异常类
26+
27+
需要使用`implements`关键字,因为`Exception`是抽象类。另外两个和继承有关的关键字,`extends`是单继承,`with`是Mixin模式的多重继承。
28+
29+
一个Demo如下:
30+
31+
```dart
32+
class QCloudVodPlayVideoApiException implements Exception {
33+
int code;
34+
String message, requestId;
35+
36+
QCloudVodPlayVideoApiException({
37+
this.code,
38+
this.message,
39+
this.requestId,
40+
});
41+
42+
QCloudVodPlayVideoApiException.fromMap(Map<String, dynamic> data){
43+
this.code = data['code'];
44+
this.message = data['message'];
45+
this.requestId = data['requestId'];
46+
}
47+
48+
String toString(){
49+
return """云点播视频播放API请求异常。
50+
* 错误码:$code
51+
* 错误信息:$message
52+
* 腾讯云requestId:$requestId
53+
""";
54+
}
55+
}
56+
```
57+
58+
这里除了基本构造器,还参考Flutter和Dart官方接口风格实现了fromMap构造器以方便直接传入response.data数据。
59+
60+
`toString`方法类似于Python的`__str__`方法,可以改变print到控制台或者log中的格式。

platform_specific/web/routers.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ outlines:
66
- 为什么使用页面路由。Web平台更接近普通网页应用,方便用户通过URL访问特定页面。
77
- Hash模式 vs Path模式(即History模式)
88
- 使用Fluro改造路由为RESTful标准。
9+
notes:
10+
- 小标题都还需要斟酌。
911
---
1012

1113
# 页面路由设置
@@ -34,7 +36,7 @@ void main() {
3436

3537
关键是`setPathUrlStrategy()`,效果等同于官方文档的方法,并且不影响Mobile和Desktop应用。
3638

37-
## RESTful标准URL设置
39+
## RESTful标准设置动态路由
3840

3941
需要路由的原因是,Web网站是以单页应用的形式上线的,要让它看起来像普通网页,可以用网址访问到具体资源,修改路由必不可少。
4042

responsive_and_adaptive/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# 响应式和自适应布局
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
author: 张果
3+
created_at: 2021-10-19
4+
updated_at: 2022-05-04
5+
---
6+
7+
# 响应式和自适应相关第三方库
8+
9+
## 响应式框架
10+
11+
responsive_framework: https://pub.dev/packages/responsive_framework。看起来是一个popular且成熟的库,可以作为技术栈之一。
12+
13+
其他原理差不多的:
14+
- https://pub.dev/packages/responsive
15+
- https://pub.dev/packages/responsive_builder
16+
- https://pub.dev/packages/responsive_ui
17+
- https://pub.dev/packages/flutter_responsive
18+
- https://pub.dev/packages/responsive_sizer
19+
20+
## 响应式组件
21+
22+
- responsive_navigation_bar: https://pub.dev/packages/responsive_navigation_bar。没看到想要的桌面手机响应。
23+
24+
- responsive_scaffold: https://pub.dev/packages/responsive_scaffold。手机桌面响应了,但不是我想要的UI效果。我希望桌面端像一个正常的网页。
25+
26+
## 自适应组件
27+
28+
adaptive_navigation: https://pub.dev/packages/adaptive_navigation。

unclassified/asset.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
created_at: 2022-02-04
3+
---
4+
# Asset
5+
6+
Any assets that are not in the lib/ folder, though, will not get added to the package’s assets bundle unless you specifically include them in pubspec.yaml
7+
8+
https://medium.com/flutter-community/including-assets-in-a-flutter-package-dd4a82a38ca9

widgets/slivers.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Sliver组件
2+
3+
教程:
4+
-「Slivers in Flutter - Part (4)」- https://dhruvnakum.xyz/slivers-in-flutter-part-4
5+
If you've used SafeArea then, SliverSafeArea is also doing the same thing except it takes
6+
sliver as a child instead of Box widget.
7+
8+
组件:
9+
- NestedScrollView: https://api.flutter.dev/flutter/widgets/NestedScrollView-class.html#widgets.NestedScrollView.1
10+
- SliverOverlapAbsorber: https://api.flutter.dev/flutter/widgets/SliverOverlapAbsorber-class.html
11+
- SliverAppBar: https://api.flutter.dev/flutter/material/SliverAppBar-class.html
12+
- SliverToBoxAdapter: https://api.flutter.dev/flutter/widgets/SliverToBoxAdapter-class.html
13+
- SliverPadding: https://api.flutter.dev/flutter/widgets/SliverPadding-class.html
14+
15+
工具:
16+
- sliver_tools: https://pub.dev/packages/sliver_tools
17+
- extended_sliver: https://pub.dev/packages/extended_sliver

0 commit comments

Comments
 (0)