30 lines
549 B
Dart
30 lines
549 B
Dart
class User {
|
|
final String id;
|
|
final String name;
|
|
final String email;
|
|
|
|
const User({
|
|
required this.id,
|
|
required this.name,
|
|
required this.email,
|
|
});
|
|
|
|
// Optional: Factory constructor to create from JSON
|
|
factory User.fromJson(Map<String, dynamic> json) {
|
|
return User(
|
|
id: json['id'] ?? '',
|
|
name: json['name'] ?? '',
|
|
email: json['email'] ?? '',
|
|
);
|
|
}
|
|
|
|
// Optional: Convert to JSON
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'id': id,
|
|
'name': name,
|
|
'email': email,
|
|
};
|
|
}
|
|
}
|