dev_dependencies:
build_runner: ^2.0.3 #build_runner版本
json_serializable: ^4.1.2 #json_serializable版本
3.1 接口文件
- API:https://www.wanandroid.com/article/list/0/json
3.2 序列化类(Article.dart)
import ‘package:json_annotation/json_annotation.dart’;
part ‘Article.g.dart’;
@JsonSerializable()
class Article {
int errorCode;
String errorMsg;
ArticleData data;
Article(this.errorCode, this.errorMsg, this.data);
factory Article.fromJson(Map<String, dynamic> json) => _$ArticleFromJson(json);
Map<String, dynamic> toJson() => _$ArticleToJson(this);
}
@JsonSerializable()
class ArticleData {
int curPage;
int offset;
bool over;
int pageCount;
int size;
int total;
List datas;
ArticleData(this.curPage, this.offset, this.over, this.pageCount, this.size, this.total, this.datas);
factory ArticleData.fromJson(Map<String, dynamic> json) => _$ArticleDataFromJson(json);
Map<String, dynamic> toJson() => _$ArticleDataToJson(this);
}
@JsonSerializable()
class Person {
String apkLink;
int audit;
String author;
bool canEdit;
int chapterId;
String chapterName;
bool collect;
int courseId;
String desc;
String descMd;
String envelopePic;
bool fresh;
String host;
int id;
String link;
String niceDate;
String niceShareDate;
String origin;
String prefix;
String projectLink;
int publishTime;
int realSuperChapterId;
int selfVisible;
int shareDate;
String shareUser;
int superChapterId;
String superChapterName;
List tags;
String title;
int type;
int userId;
int visible;
int zan;
Person(
this.apkLink,
this.audit,
this.author,
this.canEdit,
this.chapterId,
this.chapterName,
this.collect,
this.courseId,
this.desc,
this.descMd,
this.envelopePic,
this.fresh,
this.host,
this.id,
this.link,
this.niceDate,
this.niceShareDate,
this.origin,
this.prefix,
this.projectLink,
this.publishTime,
this.realSuperChapterId,
this.selfVisible,
this.shareDate,
this.shareUser,
this.superChapterId,
this.superChapterName,
this.tags,
this.title,
this.type,
this.userId,
this.visible,
this.zan);
结尾
我还总结出了互联网公司Android程序员面试涉及到的绝大部分面试题及答案,并整理做成了文档,以及系统的进阶学习视频资料,免费分享给大家。
(包括Java在Android开发中应用、APP框架知识体系、高级UI、全方位性能调优,NDK开发,音视频技术,人工智能技术,跨平台技术等技术资料),希望能帮助到你面试前的复习,且找到一个好的工作,也节省大家在网上搜索资料的时间来学习。