File tree Expand file tree Collapse file tree 3 files changed +111
-2
lines changed Expand file tree Collapse file tree 3 files changed +111
-2
lines changed Original file line number Diff line number Diff line change 1+ import 'package:json_annotation/json_annotation.dart' ;
2+
3+ /**
4+ * Created by guoshuyu
5+ * Date: 2018-08-10
6+ */
7+ part 'UserOrg.g.dart' ;
8+
9+ @JsonSerializable ()
10+ class UserOrg extends Object with _$UserOrgSerializerMixin {
11+ String login;
12+ int id;
13+ String url;
14+ String description;
15+ @JsonKey (name: "node_id" )
16+ String nodeId;
17+ @JsonKey (name: "repos_url" )
18+ String reposUrl;
19+ @JsonKey (name: "events_url" )
20+ String eventsUrl;
21+ @JsonKey (name: "hooks_url" )
22+ String hooksUrl;
23+ @JsonKey (name: "issues_url" )
24+ String issuesUrl;
25+ @JsonKey (name: "members_url" )
26+ String membersUrl;
27+ @JsonKey (name: "public_members_url" )
28+ String publicMembersUrl;
29+ @JsonKey (name: "avatar_url" )
30+ String avatarUrl;
31+
32+ UserOrg (
33+ this .login,
34+ this .id,
35+ this .url,
36+ this .description,
37+ this .nodeId,
38+ this .reposUrl,
39+ this .eventsUrl,
40+ this .hooksUrl,
41+ this .issuesUrl,
42+ this .membersUrl,
43+ this .publicMembersUrl,
44+ this .avatarUrl,
45+ );
46+
47+ /// A necessary factory constructor for creating a new User instance
48+ /// from a map. We pass the map to the generated _$UserFromJson constructor.
49+ /// The constructor is named after the source class, in this case User.
50+ factory UserOrg .fromJson (Map <String , dynamic > json) => _$UserOrgFromJson (json);
51+
52+ // 命名构造函数
53+ UserOrg .empty ();
54+ }
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ class DEMOWidget extends StatelessWidget {
1818 }
1919}
2020
21- class DemoStateWidget extends StatefulWidget {
21+ class DemoStateWidget extends StatefulWidget {
2222
2323 final String text;
2424
@@ -28,7 +28,8 @@ class DemoStateWidget extends StatefulWidget {
2828 _DemoStateWidgetState createState () => _DemoStateWidgetState (text);
2929}
3030
31- class _DemoStateWidgetState extends State <DemoStateWidget > {
31+ // ignore: mixin_inherits_from_not_object
32+ class _DemoStateWidgetState extends State <DemoStateWidget > with AutomaticKeepAliveClientMixin {
3233
3334 String text;
3435
@@ -57,6 +58,10 @@ class _DemoStateWidgetState extends State<DemoStateWidget> {
5758 });
5859 }
5960
61+
62+ @override
63+ bool get wantKeepAlive => true ;
64+
6065 @override
6166 Widget build (BuildContext context) {
6267 return Container (
You can’t perform that action at this time.
0 commit comments