170 lines
3.9 KiB
Dart
170 lines
3.9 KiB
Dart
|
// To parse this JSON data, do
|
||
|
//
|
||
|
// final viewUsermodel = viewUsermodelFromJson(jsonString);
|
||
|
|
||
|
import 'dart:convert';
|
||
|
|
||
|
ViewUsermodel viewUsermodelFromJson(String str) =>
|
||
|
ViewUsermodel.fromJson(json.decode(str));
|
||
|
|
||
|
String viewUsermodelToJson(ViewUsermodel data) => json.encode(data.toJson());
|
||
|
|
||
|
class ViewUsermodel {
|
||
|
bool success;
|
||
|
String message;
|
||
|
Data data;
|
||
|
|
||
|
ViewUsermodel({
|
||
|
required this.success,
|
||
|
required this.message,
|
||
|
required this.data,
|
||
|
});
|
||
|
|
||
|
factory ViewUsermodel.fromJson(Map<String, dynamic> json) => ViewUsermodel(
|
||
|
success: json["success"],
|
||
|
message: json["message"],
|
||
|
data: Data.fromJson(json["data"]),
|
||
|
);
|
||
|
|
||
|
Map<String, dynamic> toJson() => {
|
||
|
"success": success,
|
||
|
"message": message,
|
||
|
"data": data.toJson(),
|
||
|
};
|
||
|
|
||
|
@override
|
||
|
String toString() {
|
||
|
return "$data";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
class Data {
|
||
|
int id;
|
||
|
String name;
|
||
|
String username;
|
||
|
String password;
|
||
|
String detail;
|
||
|
int createdBy;
|
||
|
int modifiedBy;
|
||
|
DateTime createdAt;
|
||
|
DateTime updatedAt;
|
||
|
List<User> users;
|
||
|
|
||
|
Data({
|
||
|
required this.id,
|
||
|
required this.name,
|
||
|
required this.username,
|
||
|
required this.password,
|
||
|
required this.detail,
|
||
|
required this.createdBy,
|
||
|
required this.modifiedBy,
|
||
|
required this.createdAt,
|
||
|
required this.updatedAt,
|
||
|
required this.users,
|
||
|
});
|
||
|
|
||
|
factory Data.fromJson(Map<String, dynamic> json) => Data(
|
||
|
id: json["id"],
|
||
|
name: json["name"],
|
||
|
username: json["username"],
|
||
|
password: json["password"],
|
||
|
detail: json["detail"],
|
||
|
createdBy: json["created_by"],
|
||
|
modifiedBy: json["modified_by"],
|
||
|
createdAt: DateTime.parse(json["created_at"]),
|
||
|
updatedAt: DateTime.parse(json["updated_at"]),
|
||
|
users: List<User>.from(json["users"].map((x) => User.fromJson(x))),
|
||
|
);
|
||
|
|
||
|
Map<String, dynamic> toJson() => {
|
||
|
"id": id,
|
||
|
"name": name,
|
||
|
"username": username,
|
||
|
"password": password,
|
||
|
"detail": detail,
|
||
|
"created_by": createdBy,
|
||
|
"modified_by": modifiedBy,
|
||
|
"created_at": createdAt.toIso8601String(),
|
||
|
"updated_at": updatedAt.toIso8601String(),
|
||
|
"users": List<dynamic>.from(users.map((x) => x.toJson())),
|
||
|
};
|
||
|
|
||
|
@override
|
||
|
String toString() {
|
||
|
return "$users";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
class User {
|
||
|
int id;
|
||
|
String name;
|
||
|
String email;
|
||
|
dynamic emailVerifiedAt;
|
||
|
DateTime createdAt;
|
||
|
DateTime updatedAt;
|
||
|
Pivot pivot;
|
||
|
|
||
|
User({
|
||
|
required this.id,
|
||
|
required this.name,
|
||
|
required this.email,
|
||
|
required this.emailVerifiedAt,
|
||
|
required this.createdAt,
|
||
|
required this.updatedAt,
|
||
|
required this.pivot,
|
||
|
});
|
||
|
|
||
|
factory User.fromJson(Map<String, dynamic> json) => User(
|
||
|
id: json["id"],
|
||
|
name: json["name"],
|
||
|
email: json["email"],
|
||
|
emailVerifiedAt: json["email_verified_at"],
|
||
|
createdAt: DateTime.parse(json["created_at"]),
|
||
|
updatedAt: DateTime.parse(json["updated_at"]),
|
||
|
pivot: Pivot.fromJson(json["pivot"]),
|
||
|
);
|
||
|
|
||
|
Map<String, dynamic> toJson() => {
|
||
|
"id": id,
|
||
|
"name": name,
|
||
|
"email": email,
|
||
|
"email_verified_at": emailVerifiedAt,
|
||
|
"created_at": createdAt.toIso8601String(),
|
||
|
"updated_at": updatedAt.toIso8601String(),
|
||
|
"pivot": pivot.toJson(),
|
||
|
};
|
||
|
|
||
|
@override
|
||
|
String toString() {
|
||
|
return "$id";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
class Pivot {
|
||
|
int credId;
|
||
|
int userId;
|
||
|
DateTime createdAt;
|
||
|
DateTime updatedAt;
|
||
|
|
||
|
Pivot({
|
||
|
required this.credId,
|
||
|
required this.userId,
|
||
|
required this.createdAt,
|
||
|
required this.updatedAt,
|
||
|
});
|
||
|
|
||
|
factory Pivot.fromJson(Map<String, dynamic> json) => Pivot(
|
||
|
credId: json["cred_id"],
|
||
|
userId: json["user_id"],
|
||
|
createdAt: DateTime.parse(json["created_at"]),
|
||
|
updatedAt: DateTime.parse(json["updated_at"]),
|
||
|
);
|
||
|
|
||
|
Map<String, dynamic> toJson() => {
|
||
|
"cred_id": credId,
|
||
|
"user_id": userId,
|
||
|
"created_at": createdAt.toIso8601String(),
|
||
|
"updated_at": updatedAt.toIso8601String(),
|
||
|
};
|
||
|
}
|