@@ -6,7 +6,10 @@ class UserProfile {
66 final String createTime; // 时间戳字符串
77 final String ? personalSign; // 个性签名
88 final String ? introduction; // 介绍
9- final String ? avatar;
9+ final String ? _avatarBase;
10+ final int avatarVersion;
11+
12+ String ? get avatar => _avatarBase != null ? '$_avatarBase ?v=$avatarVersion ' : null ;
1013
1114 UserProfile ({
1215 required this .uid,
@@ -16,8 +19,9 @@ class UserProfile {
1619 required this .createTime,
1720 this .personalSign,
1821 this .introduction,
19- this .avatar,
20- });
22+ String ? avatar,
23+ this .avatarVersion = 0 ,
24+ }) : _avatarBase = avatar;
2125
2226 factory UserProfile .fromJson (Map <String , dynamic > json) {
2327 return UserProfile (
@@ -33,7 +37,8 @@ class UserProfile {
3337 }
3438
3539 factory UserProfile .fromServerJson (
36- Map <String , dynamic > json, String avatarUrl) {
40+ Map <String , dynamic > json, String avatarUrl,
41+ {int avatarVersion = 0 }) {
3742 return UserProfile (
3843 uid: json['uid' ].toString (),
3944 username: json['username' ] as String ,
@@ -43,6 +48,7 @@ class UserProfile {
4348 personalSign: json['personal_sign' ] as String ? ,
4449 introduction: json['introduction' ] as String ? ,
4550 avatar: avatarUrl,
51+ avatarVersion: avatarVersion,
4652 );
4753 }
4854
@@ -55,7 +61,7 @@ class UserProfile {
5561 'create_time' : createTime,
5662 if (personalSign != null ) 'personal_sign' : personalSign,
5763 if (introduction != null ) 'introduction' : introduction,
58- if (avatar != null ) 'avatar' : avatar ,
64+ if (_avatarBase != null ) 'avatar' : _avatarBase ,
5965 };
6066 }
6167
0 commit comments