之前也是记录了很多小组件的实现,这次把所有代码都给放到这里吧
这是效果:
数据(后台数据,不过我这是没的,不要在意这些小细节,忽略吧)
Http().post(url,
pathParams: params,
data: params,
success: (json)
{
studyModel = FindStudyModel.fromJson(json);
}, errorCallback: (error) {
print('error: $error');
});
数据模型(因为后台没数据,为了实现效果,自己添加的,不要在意这些小细节,忽略吧)
/// 学习 model
class FindStudyModel {
///课程 Id
String? courseId;
///课程名称
String? courseName;
///我的学习默认封面图
String? coverImage;
///微课 Id
String? microCourseId;
///微课名称
String? microCourseName;
///课程类型
String? microCourseType;
///我的学习 - 用户身份类型枚举值
int? myStudyUserType;
///学生提问数据列表
List<FindStudyQuestionModel>? userQuestions;
FindStudyModel({
this.courseId,
this.courseName,
this.coverImage,
this.microCourseId,
this.microCourseName,
this.microCourseType,
this.myStudyUserType,
this.userQuestions,
});
FindStudyModel.fromJson(dynamic json) {
courseId = json["courseId"] ?? '';
courseName = json["courseName"] ?? '';
coverImage = json["coverImage"] ?? '';
microCourseId = json["microCourseId"] ?? '';
microCourseName = json["microCourseName"] ?? '';
microCourseType = json["microCourseType"] ?? '';
myStudyUserType = json["myStudyUserType"] ?? 0;
///没数据,没办法,为了实现效果,只有自己造数据了,不要在意这些小细节,忽略吧
userQuestions = [];
for (int index = 0; index < 10; index ++) {
Map map = {
///网上拿的图片
'userAvatar': 'https://imgm.gmw.cn/attachement/jpg/site215/20210812/8692573091945953206.jpg',
'content': '语言攻击$index',
}