class Courses { int? id; String? name; String? permalink; String? dateCreated; String? shortDescription; String? price; String? regularPrice; String? salePrice; List? images; List? categories; Courses({ this.id, this.name, this.permalink, this.dateCreated, this.shortDescription, this.price, this.regularPrice, this.salePrice, this.images, this.categories, }); factory Courses.fromJson(Map json) { return Courses( id: json['id'], name: json['name'], permalink: json['permalink'], dateCreated: json['date_created'], shortDescription: json['short_description'], price: json['price'], regularPrice: json['regular_price'], salePrice: json['sale_price'], images: json['images'] != null ? (json['images'] as List) .map((i) => CourseImage.fromJson(i)) .toList() : null, categories: json['categories'] != null ? (json['categories'] as List) .map((i) => Category.fromJson(i)) .toList() : null, ); } Map toJson() { return { 'id': id, 'name': name, 'permalink': permalink, 'date_created': dateCreated, 'short_description': shortDescription, 'price': price, 'regular_price': regularPrice, 'sale_price': salePrice, 'images': images?.map((i) => i.toJson()).toList(), }; } } class Category { int? id; Category({this.id}); factory Category.fromJson(Map json) { return Category( id: json['id'], ); } Map toJson() { return { 'id': id, }; } } class CourseImage { int? id; String? src; String? name; String? alt; CourseImage({this.id, this.src, this.name, this.alt}); factory CourseImage.fromJson(Map json) { return CourseImage( id: json['id'], src: json['src'], name: json['name'], alt: json['alt'], ); } Map toJson() { return { 'id': id, 'src': src, 'name': name, 'alt': alt, }; } }