step 26 : fix navigasi ganda di no_login_screen, dan start dari login screen
This commit is contained in:
@@ -21,43 +21,43 @@ class NoLoginSplashScreen extends HookConsumerWidget {
|
||||
SystemUiOverlay.bottom,
|
||||
]);
|
||||
|
||||
useEffect(() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
||||
final shared = await SharedPreferences.getInstance();
|
||||
final bearerString = shared.getString(Constant.bearerName);
|
||||
// useEffect(() {
|
||||
// WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
||||
// final shared = await SharedPreferences.getInstance();
|
||||
// final bearerString = shared.getString(Constant.bearerName);
|
||||
|
||||
if (bearerString == null || bearerString == "null") {
|
||||
Timer(const Duration(seconds: 3), () {
|
||||
Navigator.of(context).pushNamedAndRemoveUntil(
|
||||
noLoginRoute,
|
||||
(route) => false,
|
||||
);
|
||||
});
|
||||
return;
|
||||
}
|
||||
// if (bearerString == null || bearerString == "null") {
|
||||
// Timer(const Duration(seconds: 3), () {
|
||||
// Navigator.of(context).pushNamedAndRemoveUntil(
|
||||
// noLoginRoute,
|
||||
// (route) => false,
|
||||
// );
|
||||
// });
|
||||
// return;
|
||||
// }
|
||||
|
||||
final xmodel = jsonDecode(bearerString);
|
||||
if (xmodel == null) return;
|
||||
// final xmodel = jsonDecode(bearerString);
|
||||
// if (xmodel == null) return;
|
||||
|
||||
final authModel = NoLoginAuthModel(
|
||||
host: xmodel["host"],
|
||||
token: xmodel["token"],
|
||||
client_id: xmodel['client_id'],
|
||||
expire_date: xmodel['expire_date'],
|
||||
isLogin: xmodel['isLogin'],
|
||||
);
|
||||
// final authModel = NoLoginAuthModel(
|
||||
// host: xmodel["host"],
|
||||
// token: xmodel["token"],
|
||||
// client_id: xmodel['client_id'],
|
||||
// expire_date: xmodel['expire_date'],
|
||||
// isLogin: xmodel['isLogin'],
|
||||
// );
|
||||
|
||||
ref.read(noLoginCurrentUserProvider.notifier).state = authModel;
|
||||
// ref.read(noLoginCurrentUserProvider.notifier).state = authModel;
|
||||
|
||||
Timer(const Duration(seconds: 2), () {
|
||||
Navigator.of(context).pushNamedAndRemoveUntil(
|
||||
noLoginHomeRoute,
|
||||
(route) => false,
|
||||
);
|
||||
});
|
||||
});
|
||||
return () {};
|
||||
}, []);
|
||||
// Timer(const Duration(seconds: 2), () {
|
||||
// Navigator.of(context).pushNamedAndRemoveUntil(
|
||||
// noLoginHomeRoute,
|
||||
// (route) => false,
|
||||
// );
|
||||
// });
|
||||
// });
|
||||
// return () {};
|
||||
// }, []);
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: Constant.textWhite,
|
||||
|
||||
Reference in New Issue
Block a user