-
Notifications
You must be signed in to change notification settings - Fork 0
/
storage.dart
38 lines (27 loc) · 905 Bytes
/
storage.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import 'dart:convert';
import 'package:shared_preferences/shared_preferences.dart';
const String _tokenKey = 'access_token';
const String _refreshTokenKey = 'refresh_token';
get _instance => SharedPreferences.getInstance();
Future<bool> setToken(String token) async {
return (await _instance).setString(_tokenKey, token);
}
Future<String> getToken() async {
return (await _instance).getString(_tokenKey);
}
Future<bool> removeToken() async {
return (await _instance).remove(_tokenKey);
}
Future<bool> setRefreshToken(String token) async {
return (await _instance).setString(_refreshTokenKey, token);
}
Future<String> getRefreshToken() async {
return (await _instance).getString(_refreshTokenKey);
}
Future<bool> removeRefreshToken() async {
return (await _instance).remove(_refreshTokenKey);
}
Future removeAllTokens() async {
await removeToken();
await removeRefreshToken();
}