class UserProfile { const UserProfile({ required this.id, required this.email, this.firstName, this.lastName, this.preferredLanguage, }); final String id; final String email; final String? firstName; final String? lastName; final String? preferredLanguage; String get displayName => [firstName, lastName].where((s) => s != null && s.isNotEmpty).join(' '); factory UserProfile.fromJson(Map j) => UserProfile( id: j['id'] as String, email: j['email'] as String, firstName: _str(j['first_name']), lastName: _str(j['last_name']), preferredLanguage: _str(j['preferred_language']), ); static String? _str(dynamic v) { final s = v as String?; return (s == null || s.isEmpty) ? null : s; } }