From 8a554aa2f8dcf2a92c6ecf33127f3b01923b1d84 Mon Sep 17 00:00:00 2001 From: Sultan Khan Date: Wed, 16 Dec 2020 16:08:41 +0300 Subject: [PATCH 1/2] auth services fixed --- lib/pages/landing/landing_page.dart | 20 ++++++++++--------- .../authentication/auth_provider.dart | 4 ++-- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/pages/landing/landing_page.dart b/lib/pages/landing/landing_page.dart index 2094efd9..c3e1cdf5 100644 --- a/lib/pages/landing/landing_page.dart +++ b/lib/pages/landing/landing_page.dart @@ -151,16 +151,18 @@ class _LandingPageState extends State with WidgetsBindingObserver { _firebaseMessaging.getToken().then((String token) async { sharedPref.setString(PUSH_TOKEN, token); - if (token != null && await sharedPref.getObject(USER_PROFILE) == null) { - DEVICE_TOKEN = token; - checkUserStatus(token); - } else { - getNotificationCount(token); - } + Future.delayed(Duration.zero, () async { + if (token != null && await sharedPref.getObject(USER_PROFILE) == null) { + DEVICE_TOKEN = token; + checkUserStatus(token); + } else if (await sharedPref.getObject(USER_PROFILE) != null) { + getNotificationCount(token); + } - requestPermissions(); - }).catchError((err) { - print(err); + requestPermissions(); + }).catchError((err) { + print(err); + }); }); // // //_firebase Background message handler diff --git a/lib/services/authentication/auth_provider.dart b/lib/services/authentication/auth_provider.dart index 3476435b..27de9760 100644 --- a/lib/services/authentication/auth_provider.dart +++ b/lib/services/authentication/auth_provider.dart @@ -160,8 +160,8 @@ class AuthProvider with ChangeNotifier { }, body: request); return Future.value(localRes); } catch (error) { - print(error); - //throw error; + //print(error); + throw error; } } From eec67ac930bed4fcdb15a8cf269965f97c3d9df4 Mon Sep 17 00:00:00 2001 From: Sultan Khan Date: Wed, 16 Dec 2020 16:38:56 +0300 Subject: [PATCH 2/2] big fixes --- lib/pages/landing/landing_page.dart | 7 +++---- lib/services/authentication/auth_provider.dart | 3 +-- lib/widgets/drawer/app_drawer_widget.dart | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/pages/landing/landing_page.dart b/lib/pages/landing/landing_page.dart index c3e1cdf5..f1ab7c46 100644 --- a/lib/pages/landing/landing_page.dart +++ b/lib/pages/landing/landing_page.dart @@ -158,8 +158,6 @@ class _LandingPageState extends State with WidgetsBindingObserver { } else if (await sharedPref.getObject(USER_PROFILE) != null) { getNotificationCount(token); } - - requestPermissions(); }).catchError((err) { print(err); }); @@ -518,12 +516,12 @@ class _LandingPageState extends State with WidgetsBindingObserver { // themeNotifier.setTheme(defaultTheme); } void checkUserStatus(token) async { - GifLoaderDialogUtils.showMyDialog(context); + //GifLoaderDialogUtils.showMyDialog(context); authService .selectDeviceImei(token) .then((SelectDeviceIMEIRES value) => setUserValues(value)) .catchError((err) { - GifLoaderDialogUtils.hideDialog(context); + //GifLoaderDialogUtils.hideDialog(context); }); } @@ -545,6 +543,7 @@ class _LandingPageState extends State with WidgetsBindingObserver { void setUserValues(value) async { GifLoaderDialogUtils.hideDialog(context); + requestPermissions(); sharedPref.setObject(IMEI_USER_DATA, value); } diff --git a/lib/services/authentication/auth_provider.dart b/lib/services/authentication/auth_provider.dart index 27de9760..d4e6dd22 100644 --- a/lib/services/authentication/auth_provider.dart +++ b/lib/services/authentication/auth_provider.dart @@ -160,8 +160,7 @@ class AuthProvider with ChangeNotifier { }, body: request); return Future.value(localRes); } catch (error) { - //print(error); - throw error; + return Future.value(null); } } diff --git a/lib/widgets/drawer/app_drawer_widget.dart b/lib/widgets/drawer/app_drawer_widget.dart index 24afde74..3a80c598 100644 --- a/lib/widgets/drawer/app_drawer_widget.dart +++ b/lib/widgets/drawer/app_drawer_widget.dart @@ -70,7 +70,7 @@ class _AppDrawerState extends State { padding: EdgeInsets.zero, children: [ Container( - height: SizeConfig.screenHeight * .28, + height: SizeConfig.screenHeight * .30, padding: EdgeInsets.all(15), child: InkWell( child: Column(