@@ -49,7 +49,7 @@ class _ProfilePageState extends State<ProfilePage> {
49
49
iconTheme: IconThemeData (color: Colors .white),
50
50
backgroundColor: Colors .transparent,
51
51
actions: < Widget > [
52
- authstate.profileUserModel == null
52
+ authstate.isbusy
53
53
? SizedBox .shrink ()
54
54
: PopupMenuButton <Choice >(
55
55
onSelected: (d) {},
@@ -64,7 +64,7 @@ class _ProfilePageState extends State<ProfilePage> {
64
64
),
65
65
],
66
66
flexibleSpace: FlexibleSpaceBar (
67
- background: authstate.profileUserModel == null
67
+ background: authstate.isbusy
68
68
? SizedBox .shrink ()
69
69
: Stack (
70
70
children: < Widget > [
@@ -235,6 +235,17 @@ class _ProfilePageState extends State<ProfilePage> {
235
235
}
236
236
}
237
237
238
+ /// This meathod called when user pressed back button
239
+ /// When profile page is about to close
240
+ /// Maintain minimum user's profile in profile page list
241
+ Future <bool > _onWillPop () async {
242
+ final state = Provider .of <AuthState >(context, listen: false );
243
+
244
+ /// It will remove last user's profile from profileUserModelList
245
+ state.removeLastUser ();
246
+ return true ;
247
+ }
248
+
238
249
@override
239
250
Widget build (BuildContext context) {
240
251
var state = Provider .of <FeedState >(context);
@@ -244,72 +255,74 @@ class _ProfilePageState extends State<ProfilePage> {
244
255
if (state.feedlist != null && state.feedlist.length > 0 ) {
245
256
list = state.feedlist.where ((x) => x.userId == id).toList ();
246
257
}
247
- return Scaffold (
248
- backgroundColor: list != null && list.isNotEmpty
249
- ? TwitterColor .mystic
250
- : TwitterColor .white,
251
- floatingActionButton: isMyProfile ? _floatingActionButton () : null ,
252
- body: CustomScrollView (
253
- physics: ClampingScrollPhysics (),
254
- slivers: < Widget > [
255
- getAppbar (),
256
- authstate.profileUserModel == null
257
- ? _emptyBox ()
258
- : SliverToBoxAdapter (
259
- child: Container (
260
- color: Colors .white,
261
- child: authstate.profileUserModel == null
262
- ? SizedBox .shrink ()
263
- : UserNameRowWidget (
264
- user: authstate.profileUserModel,
265
- isMyProfile: isMyProfile,
266
- ),
267
- ),
268
- ),
269
- SliverList (
270
- delegate: SliverChildListDelegate (
271
- authstate.profileUserModel == null
272
- ? [
273
- Container (
274
- height: fullHeight (context) - 180 ,
275
- child: CustomScreenLoader (
276
- height: double .infinity,
277
- width: fullWidth (context),
278
- backgroundColor: Colors .white,
279
- )
280
- )
281
- ]
282
- : list == null || list.length < 1
283
- ? [
284
- Container (
285
- padding:
286
- EdgeInsets .only (top: 50 , left: 30 , right: 30 ),
287
- child: NotifyText (
288
- title: isMyProfile
289
- ? 'You haven\' t post any Tweet yet'
290
- : '${authstate .profileUserModel .userName } hasn\' t Tweeted yet' ,
291
- subTitle: isMyProfile
292
- ? 'Tap tweet button to add new'
293
- : 'Once he\' ll do, they will be shown up here' ,
258
+ return WillPopScope (
259
+ onWillPop: _onWillPop,
260
+ child: Scaffold (
261
+ backgroundColor: list != null && list.isNotEmpty
262
+ ? TwitterColor .mystic
263
+ : TwitterColor .white,
264
+ floatingActionButton: isMyProfile ? _floatingActionButton () : null ,
265
+ body: CustomScrollView (
266
+ physics: ClampingScrollPhysics (),
267
+ slivers: < Widget > [
268
+ getAppbar (),
269
+ authstate.isbusy
270
+ ? _emptyBox ()
271
+ : SliverToBoxAdapter (
272
+ child: Container (
273
+ color: Colors .white,
274
+ child: authstate.isbusy
275
+ ? SizedBox .shrink ()
276
+ : UserNameRowWidget (
277
+ user: authstate.profileUserModel,
278
+ isMyProfile: isMyProfile,
294
279
),
295
- )
296
- ]
297
- : list
298
- .map (
299
- (x) => Container (
300
- color: TwitterColor .white,
301
- child: Tweet (
302
- model: x,
303
- isDisplayOnProfile: true ,
304
- trailing: TweetBottomSheet ().tweetOptionIcon (
305
- context, x, TweetType .Tweet ),
280
+ ),
281
+ ),
282
+ SliverList (
283
+ delegate: SliverChildListDelegate (
284
+ authstate.isbusy
285
+ ? [
286
+ Container (
287
+ height: fullHeight (context) - 180 ,
288
+ child: CustomScreenLoader (
289
+ height: double .infinity,
290
+ width: fullWidth (context),
291
+ backgroundColor: Colors .white,
292
+ ))
293
+ ]
294
+ : list == null || list.length < 1
295
+ ? [
296
+ Container (
297
+ padding:
298
+ EdgeInsets .only (top: 50 , left: 30 , right: 30 ),
299
+ child: NotifyText (
300
+ title: isMyProfile
301
+ ? 'You haven\' t post any Tweet yet'
302
+ : '${authstate .profileUserModel .userName } hasn\' t Tweeted yet' ,
303
+ subTitle: isMyProfile
304
+ ? 'Tap tweet button to add new'
305
+ : 'Once he\' ll do, they will be shown up here' ,
306
306
),
307
- ),
308
- )
309
- .toList (),
310
- ),
311
- )
312
- ],
307
+ )
308
+ ]
309
+ : list
310
+ .map (
311
+ (x) => Container (
312
+ color: TwitterColor .white,
313
+ child: Tweet (
314
+ model: x,
315
+ isDisplayOnProfile: true ,
316
+ trailing: TweetBottomSheet ().tweetOptionIcon (
317
+ context, x, TweetType .Tweet ),
318
+ ),
319
+ ),
320
+ )
321
+ .toList (),
322
+ ),
323
+ )
324
+ ],
325
+ ),
313
326
),
314
327
);
315
328
}
0 commit comments