/user_model.dart Secret
Created
June 16, 2024 13:58
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UserModel { | |
String username; | |
DateTime createdAt; | |
DateTime updatedAt; | |
String userId; | |
UserModel({ | |
required this.username, | |
required this.createdAt, | |
required this.updatedAt, | |
required this.userId, | |
}); | |
factory UserModel.fromJson(Map<String, dynamic> json) { | |
return UserModel( | |
username: json['username'], | |
createdAt: DateTime.parse(json['createdAt']), | |
updatedAt: DateTime.parse(json['updatedAt']), | |
userId: json['userId'], | |
); | |
} | |
Map<String, dynamic> toJson() { | |
return { | |
'username': username, | |
'createdAt': createdAt.toIso8601String(), | |
'updatedAt': updatedAt.toIso8601String(), | |
'userId': userId, | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment