import "dart:convert"; class User { int? id; String email; String? name; String? role; User({ this.id, required this.email, this.name, this.role, }); bool get isViewer => role == null || role?.toUpperCase() == 'VIEWER'; bool get isCollaborator => role != null && role?.toUpperCase() == 'COLLABORATOR'; Map toMap() { return {'id': id, 'email': email, 'name': name, 'role': role}; } static fromMap(Map? map) { if (map == null) return null; return User( id: map['id'], email: map['email'], name: map['name'], role: map['role'] ?? 'VIEWER', ); } String toJson() => json.encode(toMap()); factory User.fromJson(String source) => User.fromMap(json.decode(source)); }