Skip to content

Commit 86c084d

Browse files
committed
增加注释
1 parent e6fa3f3 commit 86c084d

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

lib/common/model/Template.dart

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,28 @@
11
import 'package:json_annotation/json_annotation.dart';
22

3-
/**
4-
* Created by guoshuyu
5-
* Date: 2018-07-31
6-
*/
7-
3+
///关联文件、允许Template访问 Template.g.dart 中的私有方法
4+
///Template.g.dart 是通过命令生成的文件。名称为 xx.g.dart,其中 xx 为当前 dart 文件名称
5+
///Template.g.dart中创建了抽象类_$TemplateSerializerMixin,实现了_$TemplateFromJson方法
86
part 'Template.g.dart';
97

8+
///标志class需要实现json序列化功能
109
@JsonSerializable()
10+
11+
///'xx.g.dart'文件中,默认会根据当前类名如 AA 生成 _$AASerializerMixin
12+
///所以当前类名为Template,生成的抽象类为 _$TemplateSerializerMixin
1113
class Template extends Object with _$TemplateSerializerMixin {
1214

13-
Template();
15+
String name;
16+
17+
int id;
18+
19+
///通过JsonKey重新定义参数名
20+
@JsonKey(name: "push_id")
21+
int pushId;
22+
23+
Template(this.name, this.id, this.pushId);
1424

25+
///'xx.g.dart'文件中,默认会根据当前类名如 AA 生成 _$AAeFromJson方法
26+
///所以当前类名为Template,生成的抽象类为 _$TemplateFromJson
1527
factory Template.fromJson(Map<String, dynamic> json) => _$TemplateFromJson(json);
1628
}

lib/common/model/Template.g.dart

Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)