SHARE
TWEET

model

a guest Jan 19th, 2020 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import 'dart:convert';
  2.  
  3. class Penilaian {
  4.   int idPenilaian;
  5.   int projectId;
  6.   String title;
  7.   int idVendor;
  8.   String vendorInstansi;
  9.   String vendorWebsite;
  10.   int kinerja;
  11.   int ketepatan;
  12.   int komunikasi;
  13.  
  14.   Penilaian({
  15.     this.idPenilaian,
  16.     this.projectId,
  17.     this.title,
  18.     this.idVendor,
  19.     this.vendorInstansi,
  20.     this.vendorWebsite,
  21.     this.kinerja,
  22.     this.ketepatan,
  23.     this.komunikasi,
  24.   });
  25.  
  26.   factory Penilaian.fromJson(Map<String, dynamic> json) => Penilaian(
  27.         idPenilaian: json["id_penilaian"],
  28.         projectId: json["project_id"],
  29.         title: json["title"],
  30.         idVendor: json["id_vendor"],
  31.         vendorInstansi: json["vendor_instansi"],
  32.         vendorWebsite: json["vendor_website"],
  33.         kinerja: json["kinerja"],
  34.         ketepatan: json["ketepatan"],
  35.         komunikasi: json["komunikasi"],
  36.       );
  37.  
  38.   Map<String, dynamic> toJson() => {
  39.         "id_penilaian": idPenilaian,
  40.         "project_id": projectId,
  41.         "title": title,
  42.         "id_vendor": idVendor,
  43.         "vendor_instansi": vendorInstansi,
  44.         "vendor_website": vendorWebsite,
  45.         "kinerja": kinerja,
  46.         "ketepatan": ketepatan,
  47.         "komunikasi": komunikasi,
  48.       };
  49.  
  50.   @override
  51.   String toString() {
  52.     return 'Penilaian{id_penilaian: $idPenilaian, project_id: $projectId, title: $title, id_vendor: $idVendor, vendor_instansi: $vendorInstansi, vendor_website: $vendorWebsite, kinerja: $kinerja, ketepatan: $ketepatan, komunikasi: $komunikasi}';
  53.   }
  54. }
  55.  
  56. /* fungsi untuk melakukan konversi respon dari API ke
  57. class model */
  58. List<Penilaian> penilaianFromJson(String jsonData) {
  59.   final data = json.decode(jsonData);
  60.   return List<Penilaian>.from(
  61.       data.map((item) => Penilaian.fromJson(item)).toList());
  62. }
  63.  
  64. /* fungsi untuk melakukan konversi dari
  65. class model ke JSON Format dalam bentuk String*/
  66.  
  67. String penilaianToJson(Penilaian data) {
  68.   final jsonData = data.toJson();
  69.   return jsonEncode(jsonData);
  70. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top