class AuthResponse { final String token; final String? username; final String? nickname; /// 头像相对路径。null = 用默认头像 final String? avatar; const AuthResponse({ required this.token, this.username, this.nickname, this.avatar, }); factory AuthResponse.fromJson(Map json) => AuthResponse( token: json['token']?.toString() ?? '', username: json['username']?.toString(), nickname: json['nickname']?.toString(), avatar: json['avatar']?.toString(), ); } class UserInfo { final String? id; final String username; final String nickname; /// 头像相对路径。null = 用默认头像 final String? avatar; const UserInfo({ this.id, required this.username, required this.nickname, this.avatar, }); Map toJson() => { 'id': id, 'username': username, 'nickname': nickname, 'avatar': avatar, }; factory UserInfo.fromJson(Map json) => UserInfo( id: json['id']?.toString(), username: json['username']?.toString() ?? '', nickname: json['nickname']?.toString() ?? '', avatar: json['avatar']?.toString(), ); }