This repository has been archived on 2023-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
LocalSpend-Tracker/lib/common/functions/logout.dart

19 lines
604 B
Dart
Raw Normal View History

import 'package:flutter/material.dart';
import 'package:local_spend/common/apifunctions/request_logout_api.dart';
2019-07-16 11:09:10 +00:00
import 'package:shared_preferences/shared_preferences.dart';
2019-08-27 11:18:02 +00:00
import 'package:local_spend/common/functions/save_logout.dart';
void logout(context) {
2019-08-27 11:18:02 +00:00
_clearLoginDetails().then((_) {
requestLogoutAPI();
Navigator.of(context).pushReplacementNamed('/LoginPage');
});
2019-07-16 11:09:10 +00:00
}
2019-08-27 11:18:02 +00:00
Future<void> _clearLoginDetails() async {
2019-07-16 11:09:10 +00:00
SharedPreferences preferences = await SharedPreferences.getInstance();
await preferences.setString('username', "");
await preferences.setString('password', "");
}