mirror of
https://github.com/Dvorinka/1356.git
synced 2026-06-04 12:02:56 +00:00
Added core data models, repositories, and utilities
This commit is contained in:
@@ -76,4 +76,38 @@ class User extends Equatable {
|
||||
createdAt,
|
||||
updatedAt,
|
||||
];
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'username': username,
|
||||
'email': email,
|
||||
'avatar_url': avatarUrl,
|
||||
'bio': bio,
|
||||
'is_public_profile': isPublicProfile,
|
||||
'countdown_start_date': countdownStartDate?.toIso8601String(),
|
||||
'countdown_end_date': countdownEndDate?.toIso8601String(),
|
||||
'created_at': createdAt.toIso8601String(),
|
||||
'updated_at': updatedAt.toIso8601String(),
|
||||
};
|
||||
}
|
||||
|
||||
factory User.fromJson(Map<String, dynamic> json) {
|
||||
return User(
|
||||
id: json['id'] as String,
|
||||
username: json['username'] as String,
|
||||
email: json['email'] as String,
|
||||
avatarUrl: json['avatar_url'] as String?,
|
||||
bio: json['bio'] as String?,
|
||||
isPublicProfile: json['is_public_profile'] as bool? ?? false,
|
||||
countdownStartDate: json['countdown_start_date'] != null
|
||||
? DateTime.parse(json['countdown_start_date'] as String)
|
||||
: null,
|
||||
countdownEndDate: json['countdown_end_date'] != null
|
||||
? DateTime.parse(json['countdown_end_date'] as String)
|
||||
: null,
|
||||
createdAt: DateTime.parse(json['created_at'] as String),
|
||||
updatedAt: DateTime.parse(json['updated_at'] as String),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user