You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
1.7 KiB
73 lines
1.7 KiB
import 'package:flutter/cupertino.dart'; |
|
|
|
import 'user_role_model.dart'; |
|
|
|
class UserModel { |
|
String? id; |
|
String? username; |
|
String? fullname; |
|
String? email; |
|
String? nip; |
|
String? no_hp; |
|
String? jenis_kelamin; |
|
String? address; |
|
String? password; |
|
int? role_id; |
|
int? warehouse_id; |
|
String? token; |
|
|
|
UserRoleModel? role; |
|
|
|
UserModel({ |
|
this.id, |
|
this.username, |
|
this.fullname, |
|
this.email, |
|
this.nip, |
|
this.no_hp, |
|
this.jenis_kelamin, |
|
this.address, |
|
this.password, |
|
this.role_id, |
|
this.warehouse_id, |
|
this.token, |
|
this.role, |
|
}); |
|
|
|
UserModel.fromJson(Map<String, dynamic> json) { |
|
id = json['id'].toString(); |
|
username = json['username']; |
|
fullname = json['fullname']; |
|
email = json['email']; |
|
nip = json['nip']; |
|
no_hp = json['no_hp']; |
|
jenis_kelamin = json['jenis_kelamin']; |
|
address = json['address']; |
|
password = json['password']; |
|
role_id = |
|
json['role_id'] != null ? int.parse(json['role_id'].toString()) : null; |
|
warehouse_id = json['warehouse_id'] != null |
|
? int.parse(json['warehouse_id'].toString()) |
|
: null; |
|
token = json['token'].toString(); |
|
role = json['role'] != null ? UserRoleModel.fromJson(json['role']) : null; |
|
} |
|
|
|
Map<String, dynamic> toJson() { |
|
return { |
|
'id': id.toString(), |
|
'username': username, |
|
'email': email, |
|
'fullname': fullname, |
|
'nip': nip, |
|
'no_hp': no_hp, |
|
'jenis_kelamin': jenis_kelamin, |
|
'address': address, |
|
'password': password, |
|
'role_id': role_id.toString(), |
|
'warehouse_id': warehouse_id.toString(), |
|
'token': token.toString(), |
|
'role': role!.toJson(), |
|
}; |
|
} |
|
}
|
|
|