diff --git a/lib/models/user.dart b/lib/models/user.dart new file mode 100644 index 0000000..20ef7c1 --- /dev/null +++ b/lib/models/user.dart @@ -0,0 +1,30 @@ +class User { + final String? name; + final String? email; + List? followingList; + + User({required this.name, required this.email, this.followingList}); + + Map toJson() { + return { + 'userName': name, + 'email': email, + }; + } + + factory User.fromJson(Map json) { + return User( + name: json['userName'] as String?, + email: json['email'] as String?, + followingList: json['followingList'] != null ? List.from(json['followingList']) : null + ); + } + + User copyWith({String? name, String? email, List? followingList}) { + return User( + name: name ?? this.name, + email: email ?? this.email, + followingList: followingList ?? this.followingList + ); + } +}