logout works properly
This commit is contained in:
parent
204cd74544
commit
96fdc01eea
4 changed files with 13 additions and 24 deletions
|
@ -1,17 +1,18 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:local_spend/common/apifunctions/request_logout_api.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:local_spend/common/functions/save_logout.dart';
|
||||
|
||||
void logout(context) {
|
||||
requestLogoutAPI(context);
|
||||
Navigator.of(context).pushReplacementNamed('/LoginPage');
|
||||
_clearLoginDetails();
|
||||
_clearLoginDetails().then((_) {
|
||||
requestLogoutAPI();
|
||||
Navigator.of(context).pushReplacementNamed('/LoginPage');
|
||||
});
|
||||
}
|
||||
|
||||
void _clearLoginDetails() async {
|
||||
Future<void> _clearLoginDetails() async {
|
||||
SharedPreferences preferences = await SharedPreferences.getInstance();
|
||||
|
||||
await preferences.setString('username', "");
|
||||
await preferences.setString('password', "");
|
||||
print("details cleared");
|
||||
}
|
||||
|
|
|
@ -6,6 +6,4 @@ void saveLogout() async {
|
|||
await preferences.setString('LastUser', "");
|
||||
await preferences.setString('LastToken', "");
|
||||
await preferences.setString('LastEmail', "");
|
||||
await preferences.setString('username', "");
|
||||
await preferences.setString('password', "");
|
||||
}
|
||||
|
|
Reference in a new issue