@@ -18,6 +18,7 @@ import 'package:flutter_app/resources/widgets/app_loader_widget.dart';
1818import 'package:flutter_app/resources/widgets/safearea_widget.dart' ;
1919import 'package:flutter_app/resources/widgets/woosignal_ui.dart' ;
2020import 'package:nylo_framework/nylo_framework.dart' ;
21+ import 'package:wp_json_api/exceptions/invalid_user_token_exception.dart' ;
2122import 'package:wp_json_api/models/responses/wc_customer_info_response.dart' ;
2223import 'package:wp_json_api/wp_json_api.dart' ;
2324
@@ -49,6 +50,14 @@ class _AccountDetailPageState extends State<AccountDetailPage>
4950 try {
5051 wcCustomerInfoResponse = await WPJsonAPI .instance
5152 .api ((request) => request.wcCustomerInfo (userToken));
53+ } on InvalidUserTokenException catch (_) {
54+ showToastNotification (
55+ context,
56+ title: trans ("Oops!" ),
57+ description: trans ("Something went wrong" ),
58+ style: ToastNotificationStyleType .DANGER ,
59+ );
60+ await authLogout (context);
5261 } on Exception catch (_) {
5362 showToastNotification (
5463 context,
@@ -89,7 +98,17 @@ class _AccountDetailPageState extends State<AccountDetailPage>
8998 if (activeBody == null ) {
9099 return SizedBox .shrink ();
91100 }
101+ String userAvatar;
102+ String userFirstName = "" ;
103+ String userLastName = "" ;
104+ if (_wcCustomerInfoResponse != null && _wcCustomerInfoResponse.data != null ) {
105+ userAvatar = _wcCustomerInfoResponse.data.avatar;
92106
107+ userFirstName = _wcCustomerInfoResponse
108+ .data.firstName;
109+ userLastName = _wcCustomerInfoResponse
110+ .data.lastName;
111+ }
93112 return Scaffold (
94113 appBar: AppBar (
95114 leading: widget.showLeadingBackButton
@@ -123,13 +142,9 @@ class _AccountDetailPageState extends State<AccountDetailPage>
123142 children: < Widget > [
124143 Container (
125144 margin: EdgeInsets .only (top: 10 ),
126- child: CircleAvatar (
127- backgroundImage: NetworkImage (
128- _wcCustomerInfoResponse != null
129- ? _wcCustomerInfoResponse.data.avatar
130- : "" ,
131- ),
132- ),
145+ child: userAvatar != null ? CircleAvatar (
146+ backgroundImage: NetworkImage (userAvatar),
147+ ) : Icon (Icons .account_circle_rounded, size: 65 ,),
133148 height: 90 ,
134149 width: 90 ,
135150 ),
@@ -146,18 +161,13 @@ class _AccountDetailPageState extends State<AccountDetailPage>
146161 MainAxisAlignment .spaceAround,
147162 children: < Widget > [
148163 Text (
149- (_wcCustomerInfoResponse == null
150- ? ""
151- : [
152- _wcCustomerInfoResponse
153- .data.firstName,
154- _wcCustomerInfoResponse
155- .data.lastName
156- ]
157- .where ((t) =>
158- (t != null || t != "" ))
159- .toList ()
160- .join (" " )),
164+ [
165+ userFirstName,
166+ userLastName
167+ ].where ((t) =>
168+ (t != null || t != "" ))
169+ .toList ()
170+ .join (" " ),
161171 style: TextStyle (
162172 fontSize: 20 ,
163173 fontWeight: FontWeight .w600,
0 commit comments