Skip to content

Commit a77fde4

Browse files
author
wushangkun
committed
Add display images
1 parent c10c729 commit a77fde4

File tree

8 files changed

+104
-3
lines changed

8 files changed

+104
-3
lines changed

README.md

Lines changed: 104 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,127 @@
11
# SKGenerateModelTool
22

3+
# SKGenerateModelTool
4+
35

46
![SKGenerateModelTool](https://upload-images.jianshu.io/upload_images/1129777-9c130b4ce345ddf9.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
57

8+
- 支持Objective-C / Swift / Dart
69
- 支持通过URL链接或json字符串一键生成model文件
710
- 支持字符串加密(可设置不同的密钥,开发者可自行修改加密算法)
811
- 支持自定义model父类、自定义model前缀、自定义文件名、自定义作者名
9-
- 支持OC / Swift
1012
- 支持自定义输出文件夹路径
1113
- 兼容YYModel / MJExtension / HandyJSON解析
1214
- 兼容服务端返回“id”字段
13-
- 支持类驼峰命名
15+
- 类驼峰命名
1416

17+
- Support OC / Swift / Dart
1518
- Supports one-click generation of model files through URL links or json strings
1619
- Support string encryption (different keys can be set, developers can modify the encryption algorithm)
1720
- Support custom model parent class, custom model prefix, custom file name, custom author name
18-
- Support OC / Swift
1921
- Support custom output folder path
2022
- Compatible with YYModel / MJExtension analysis
2123
- Compatible server returns "id" field
2224
- Supports hump naming
2325

26+
###### 生成Flutter Dart Model
27+
28+
```
29+
//
30+
// news_response.dart
31+
// SKGenerateModelTool
32+
//
33+
// Created by wushangkun on 2021/01/29.
34+
// Copyright © 2021 SKGenerateModelTool. All rights reserved.
35+
//
36+
37+
part 'news_response.m.dart';
38+
39+
class NewsResponse extends NSObject {
40+
List<SKDataModel> data;
41+
String msg; // success
42+
int code; // 200
43+
44+
NewsResponse fromJson(Map<String, dynamic> json) => _$NewsResponseFromJson(json, this);
45+
Map<String, dynamic> toJson() => _$NewsResponseToJson(this);
46+
}
47+
48+
class SKDataModel extends NSObject {
49+
String title;
50+
String source; // 环球网资讯
51+
String imgsrc;
52+
53+
SKDataModel fromJson(Map<String, dynamic> json) => _$SKDataModelFromJson(json, this);
54+
Map<String, dynamic> toJson() => _$SKDataModelToJson(this);
55+
}
56+
57+
```
58+
59+
实现文件
60+
61+
```
62+
//
63+
// news_response.m.dart
64+
// SKGenerateModelTool
65+
//
66+
// Created by wushangkun on 2021/01/29.
67+
// Copyright © 2021 SKGenerateModelTool. All rights reserved.
68+
//
69+
70+
part of 'news_response.dart';
71+
72+
NewsResponse _$NewsResponseFromJson(Map<String, dynamic> json, NewsResponse instance) {
73+
if(json['data'] != null) {
74+
instance.data = new List<SKDataModel>();
75+
(json['data'] as List).forEach((v) {
76+
instance.data.add(new SKDataModel().fromJson(v));
77+
});
78+
}
79+
if(json['msg'] != null) {
80+
instance.msg = json['msg']?.toString();
81+
}
82+
if(json['code'] != null) {
83+
final code = json['code'];
84+
if(code is String) {
85+
instance.code = int.parse(code);
86+
} else {
87+
instance.code = code?.toInt();
88+
}
89+
}
90+
return instance;
91+
}
92+
93+
Map<String, dynamic> _$NewsResponseToJson(NewsResponse instance) {
94+
final Map<String, dynamic> json = new Map<String, dynamic>();
95+
if(instance.data != null) {
96+
json['data'] = instance.data.map((v) => v.toJson()).toList();
97+
}
98+
json['msg'] = instance.msg;
99+
json['code'] = instance.code;
100+
return json;
101+
}
102+
103+
SKDataModel _$SKDataModelFromJson(Map<String, dynamic> json, SKDataModel instance) {
104+
if(json['title'] != null) {
105+
instance.title = json['title']?.toString();
106+
}
107+
if(json['source'] != null) {
108+
instance.source = json['source']?.toString();
109+
}
110+
if(json['imgsrc'] != null) {
111+
instance.imgsrc = json['imgsrc']?.toString();
112+
}
113+
return instance;
114+
}
115+
116+
Map<String, dynamic> _$SKDataModelToJson(SKDataModel instance) {
117+
final Map<String, dynamic> json = new Map<String, dynamic>();
118+
json['title'] = instance.title;
119+
json['source'] = instance.source;
120+
json['imgsrc'] = instance.imgsrc;
121+
return json;
122+
}
123+
124+
```
24125

25126
###### 生成Model
26127
![生成Model](https://upload-images.jianshu.io/upload_images/1129777-51a3b41012e11c96.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

images/SKEncryptHeader.png

524 KB
Loading

images/dart.png

912 KB
Loading

images/encrypt.png

287 KB
Loading

images/encrypt_result.png

760 KB
Loading

images/flutter1.png

515 KB
Loading

images/flutter2.png

395 KB
Loading

images/home.png

807 KB
Loading

0 commit comments

Comments
 (0)