@@ -32,7 +32,7 @@ class UserPage extends StatefulWidget {
32
32
class _UserPageState extends State <UserPage > {
33
33
late String _appVersion;
34
34
late SettingConfig config = SettingConfig ();
35
- late User ? _me;
35
+ User ? _me;
36
36
late String _baseUrl;
37
37
final FocusNode _proxyUrlFocusNode = FocusNode ();
38
38
final TextEditingController _proxyUrlController = TextEditingController ();
@@ -74,12 +74,13 @@ class _UserPageState extends State<UserPage> {
74
74
super .initState ();
75
75
_fetchAppVersion ();
76
76
_loadSettingConfig ();
77
+ _fetchMe ();
77
78
}
78
79
79
- Future <User ? > _fetchMe () async {
80
+ Future <void > _fetchMe () async {
80
81
await _fetchBaseUrl ();
81
82
_me = await UserApi ().getMe ();
82
- return _me ;
83
+ setState (() {}) ;
83
84
}
84
85
85
86
Future <String > _fetchBaseUrl () async {
@@ -97,51 +98,40 @@ class _UserPageState extends State<UserPage> {
97
98
}
98
99
99
100
Widget _buildAppbarUser () {
100
- return FutureBuilder (
101
- future: _fetchMe (),
102
- builder: (BuildContext context, AsyncSnapshot snapshot) {
103
- if (snapshot.connectionState == ConnectionState .done) {
104
- if (snapshot.hasError) {
105
- return Text ("Load api base url error: ${snapshot .error }" );
106
- } else {
107
- return Row (
108
- children: [
109
- CircleAvatar (
110
- radius: 28 , // 半径控制头像的大小
111
- backgroundImage: NetworkImage (
112
- UrlUtils .getCoverUrl (_baseUrl, _me? .avatar ?? "" )),
113
- ),
114
- const SizedBox (
115
- width: 10 ,
116
- ),
117
- Column (
118
- crossAxisAlignment: CrossAxisAlignment .start,
119
- children: [
120
- Text (
121
- getAvatarTitle (_me),
122
- style: const TextStyle (fontSize: 28 ),
123
- ),
124
- if (_me? .introduce != null )
125
- Align (
126
- alignment: Alignment .bottomCenter,
127
- child: Text (
128
- _me? .introduce ?? "" ,
129
- style: const TextStyle (
130
- fontSize: 15 , // 字体大小
131
- fontWeight: FontWeight .w500, // 字体粗细
132
- color: Colors .grey, // 字体颜色
133
- ),
134
- ),
135
- ),
136
- ],
101
+ if (_me == null ) return const CircularProgressIndicator ();
102
+ return Row (
103
+ children: [
104
+ CircleAvatar (
105
+ radius: 28 , // 半径控制头像的大小
106
+ backgroundImage: NetworkImage (
107
+ UrlUtils .getCoverUrl (_baseUrl, _me? .avatar ?? "" )),
108
+ ),
109
+ const SizedBox (
110
+ width: 10 ,
111
+ ),
112
+ Column (
113
+ crossAxisAlignment: CrossAxisAlignment .start,
114
+ children: [
115
+ Text (
116
+ getAvatarTitle (_me),
117
+ style: const TextStyle (fontSize: 28 ),
118
+ ),
119
+ if (_me? .introduce != null )
120
+ Align (
121
+ alignment: Alignment .bottomCenter,
122
+ child: Text (
123
+ _me? .introduce ?? "" ,
124
+ style: const TextStyle (
125
+ fontSize: 15 , // 字体大小
126
+ fontWeight: FontWeight .w500, // 字体粗细
127
+ color: Colors .grey, // 字体颜色
137
128
),
138
- ],
139
- );
140
- }
141
- } else {
142
- return const CircularProgressIndicator ();
143
- }
144
- });
129
+ ),
130
+ ),
131
+ ],
132
+ ),
133
+ ],
134
+ );;
145
135
}
146
136
147
137
@override
0 commit comments