User.fromJson constructor

User.fromJson(
  1. Map<String, dynamic> json
)

Creates a user instance from a JSON map.

Implementation

factory User.fromJson(Map<String, dynamic> json) {
  return User(
    id: json['id'] as int,
    username: json['username'] as String?,
    image: json['image'] as String?,
    tier: json['tier'] as String?,
    status: json['status'] as String?,
    isModerator: json['isModerator'] as bool?,
    createdAt: json['createdAt'] != null
        ? DateTime.parse(json['createdAt'] as String)
        : null,
    displayName: json['displayName'] as String?,
    filePreferences: json['filePreferences'] != null
        ? UserFilePreferences.fromJson(
            json['filePreferences'] as Map<String, dynamic>,
          )
        : null,
    banned: json['bannedAt'] != null ? true : false,
  );
}