@@ -8,21 +8,25 @@ class WanResp {
88
99 WanResp .fromParams ({this .errorCode, this .errorMsg, this .data});
1010
11- factory WanResp (jsonStr) => jsonStr is String ? WanResp .fromJson (json.decode (jsonStr)) : WanResp .fromJson (jsonStr);
11+ factory WanResp (jsonStr) =>
12+ jsonStr == null ? null : jsonStr is String ? new WanResp .fromJson (json.decode (jsonStr)) : new WanResp .fromJson (
13+ jsonStr);
1214
1315 WanResp .fromJson (jsonRes) {
1416 errorCode = jsonRes['errorCode' ];
1517 errorMsg = jsonRes['errorMsg' ];
16- data = [];
18+ data = jsonRes[ 'data' ] == null ? null : [];
1719
18- for (var dataItem in jsonRes['data' ]){
19- data. add ( new Data .fromJson (dataItem));
20+ for (var dataItem in data == null ? [] : jsonRes['data' ]) {
21+ data. add (dataItem == null ? null : new Data .fromJson (dataItem));
2022 }
2123 }
2224
2325 @override
2426 String toString () {
25- return '{"errorCode": $errorCode ,"errorMsg": ${errorMsg != null ?'${json .encode (errorMsg )}' :'null' },"data": $data }' ;
27+ return '{"errorCode": $errorCode ,"errorMsg": ${errorMsg != null
28+ ? '${json .encode (errorMsg )}'
29+ : 'null' },"data": $data }' ;
2630 }
2731}
2832
@@ -45,16 +49,17 @@ class Data {
4549 parentChapterId = jsonRes['parentChapterId' ];
4650 visible = jsonRes['visible' ];
4751 name = jsonRes['name' ];
48- children = [];
52+ children = jsonRes[ 'children' ] == null ? null : [];
4953
50- for (var childrenItem in jsonRes['children' ]){
51- children. add ( new Children .fromJson (childrenItem));
54+ for (var childrenItem in children == null ? [] : jsonRes['children' ]) {
55+ children. add (childrenItem == null ? null : new Children .fromJson (childrenItem));
5256 }
5357 }
5458
5559 @override
5660 String toString () {
57- return '{"courseId": $courseId ,"id": $id ,"order": $order ,"parentChapterId": $parentChapterId ,"visible": $visible ,"name": ${name != null ?'${json .encode (name )}' :'null' },"children": $children }' ;
61+ return '{"courseId": $courseId ,"id": $id ,"order": $order ,"parentChapterId": $parentChapterId ,"visible": $visible ,"name": ${name !=
62+ null ? '${json .encode (name )}' : 'null' },"children": $children }' ;
5863 }
5964}
6065
@@ -68,7 +73,8 @@ class Children {
6873 String name;
6974 List <dynamic > children;
7075
71- Children .fromParams ({this .courseId, this .id, this .order, this .parentChapterId, this .visible, this .name, this .children});
76+ Children .fromParams (
77+ {this .courseId, this .id, this .order, this .parentChapterId, this .visible, this .name, this .children});
7278
7379 Children .fromJson (jsonRes) {
7480 courseId = jsonRes['courseId' ];
@@ -77,16 +83,17 @@ class Children {
7783 parentChapterId = jsonRes['parentChapterId' ];
7884 visible = jsonRes['visible' ];
7985 name = jsonRes['name' ];
80- children = [];
86+ children = jsonRes[ 'children' ] == null ? null : [];
8187
82- for (var childrenItem in jsonRes['children' ]){
83- children.add (childrenItem);
88+ for (var childrenItem in children == null ? [] : jsonRes['children' ]) {
89+ children.add (childrenItem);
8490 }
8591 }
8692
8793 @override
8894 String toString () {
89- return '{"courseId": $courseId ,"id": $id ,"order": $order ,"parentChapterId": $parentChapterId ,"visible": $visible ,"name": ${name != null ?'${json .encode (name )}' :'null' },"children": $children }' ;
95+ return '{"courseId": $courseId ,"id": $id ,"order": $order ,"parentChapterId": $parentChapterId ,"visible": $visible ,"name": ${name !=
96+ null ? '${json .encode (name )}' : 'null' },"children": $children }' ;
9097 }
9198}
9299
0 commit comments