Created
April 27, 2023 06:01
-
-
Save mqhamdam/4e616336e84ff5d57738b7d6418943c9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import 'package:freezed_annotation/freezed_annotation.dart'; | |
import 'package:jjogji/domain/core/value_object.dart'; | |
import 'package:jjogji/domain/user/user.dart'; | |
import 'package:jjogji/domain/user/value_objects.dart'; | |
import 'package:json_annotation/json_annotation.dart'; | |
part 'user_dto.freezed.dart'; | |
part 'user_dto.g.dart'; | |
@freezed | |
abstract class UserDto with _$UserDto { | |
factory UserDto({ | |
required String uuid, | |
required String userName, | |
required String? userID, | |
required bool isVerified, | |
required int postCount, | |
required int followersCount, | |
required int followingCount, | |
required String? avatarImageUrl, | |
required String? backgroundImageUrl, | |
}) = _UserDto; | |
factory UserDto.fromDomain(User user) => UserDto( | |
uuid: user.uuid.getOrCrash(), | |
userName: user.userName.getOrCrash(), | |
userID: user.userID?.getOrCrash(), | |
isVerified: user.isVerified, | |
postCount: user.postCount, | |
followersCount: user.followersCount, | |
followingCount: user.followingCount, | |
avatarImageUrl: user.avatarImageUrl?.getOrCrash(), | |
backgroundImageUrl: user.backgroundImageUrl?.getOrCrash(), | |
); | |
factory UserDto.fromJson(Map<String, dynamic> json) => | |
_$UserDtoFromJson(json); | |
// Map<String, dynamic> toJson() => _$UserDtoToJson(this); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment