import 'package:equatable/equatable.dart'; class CartsModel extends Equatable { CartsModel({ this.status, this.error, required this.data, this.totalPayment, this.potonganKupon, }); final int? status; final bool? error; final List data; final int? potonganKupon; final String? totalPayment; factory CartsModel.fromJson(Map json) => CartsModel( status: json["status"], error: json["error"], data: List.from( json["data"].map((x) => DataCartsModel.fromJson(x))), potonganKupon: json["potongan_kupon"], totalPayment: json["total_payment"], ); Map toJson() => { "status": status, "error": error, "data": List.from(data.map((x) => x.toJson())), "total_payment": totalPayment, }; @override // TODO: implement props List get props => []; } class DataCartsModel extends Equatable { DataCartsModel({ this.cartId, this.courseId, this.title, this.price, this.instructor, this.thumbnail, this.discountPrice, this.discountFlag, this.totalDiscount, this.student, required this.review, this.fotoProfile, this.coupon, this.finalPrice, this.potonganKupon, }); final String? cartId; final String? courseId; final String? title; final String? price; final String? instructor; final String? thumbnail; final String? discountPrice; final String? discountFlag; final int? totalDiscount; final String? student; final List review; final dynamic fotoProfile; final Coupon? coupon; final String? finalPrice; final String? potonganKupon; factory DataCartsModel.fromJson(Map json) => DataCartsModel( cartId: json["cart_id"], courseId: json["course_id"], title: json["title"], price: json["price"], instructor: json["instructor"], thumbnail: json["thumbnail"], discountPrice: json["discount_price"], discountFlag: json["discount_flag"], totalDiscount: json["total_discount"], student: json["student"], review: List.from(json["review"].map((x) => Review.fromJson(x))), fotoProfile: json["foto_profile"], coupon: json["coupon"] == null ? null : Coupon.fromJson(json["coupon"]), potonganKupon: json["potongan_kupon"], finalPrice: json["final_price"], ); Map toJson() => { "cart_id": cartId, "course_id": courseId, "title": title, "price": price, "instructor": instructor, "thumbnail": thumbnail, "discount_price": discountPrice, "discount_flag": discountFlag, "total_discount": totalDiscount, "student": student, "review": List.from(review.map((x) => x.toJson())), "foto_profile": fotoProfile, "coupon": coupon, "final_price": finalPrice }; @override // TODO: implement props List get props => [finalPrice]; } class Coupon { Coupon({ this.id, this.typeCoupon, this.codeCoupon, this.value, this.finalPrice, }); final String? id; final String? typeCoupon; final String? codeCoupon; final String? value; final int? finalPrice; factory Coupon.fromJson(Map json) => Coupon( id: json["id"], typeCoupon: json["type_coupon"], codeCoupon: json["code_coupon"], value: json["value"], finalPrice: json["final_price"], ); Map toJson() => { "id": id, "type_coupon": typeCoupon, "code_coupon": codeCoupon, "value": value, "final_price": finalPrice, }; } class Review { Review({ this.totalReview, this.avgRating, }); final String? totalReview; final int? avgRating; factory Review.fromJson(Map json) => Review( totalReview: json["total_review"], avgRating: json["avg_rating"] == null ? null : json["avg_rating"], ); Map toJson() => { "total_review": totalReview, "avg_rating": avgRating == null ? null : avgRating, }; }