Initial commit: Penyerahan final Source code Tugas Akhir
This commit is contained in:
73
lib/helper/user_info.dart
Normal file
73
lib/helper/user_info.dart
Normal file
@ -0,0 +1,73 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
|
||||
class UsersInfo {
|
||||
final storage = new FlutterSecureStorage();
|
||||
|
||||
Future setToken(String? value) async {
|
||||
final SharedPreferences pref = await SharedPreferences.getInstance();
|
||||
return pref.setString("token", value!);
|
||||
}
|
||||
|
||||
Future setRefreshToken(String? value) async {
|
||||
final SharedPreferences pref = await SharedPreferences.getInstance();
|
||||
return pref.setString('refresh_token', value!);
|
||||
}
|
||||
|
||||
Future setEmail(String? value) async {
|
||||
final SharedPreferences pref = await SharedPreferences.getInstance();
|
||||
return pref.setString("email", value!);
|
||||
}
|
||||
|
||||
Future setIdUser(int? value) async {
|
||||
final SharedPreferences pref = await SharedPreferences.getInstance();
|
||||
return pref.setInt('idUser', value!);
|
||||
}
|
||||
|
||||
setListData(String key, List<String> value) async {
|
||||
SharedPreferences myPrefs = await SharedPreferences.getInstance();
|
||||
myPrefs.setStringList(key, value);
|
||||
}
|
||||
|
||||
Future setStateintro(String? value) async {
|
||||
await storage.write(key: 'intro', value: value);
|
||||
}
|
||||
|
||||
Future<List<String>?> getListData(String key) async {
|
||||
SharedPreferences myPrefs = await SharedPreferences.getInstance();
|
||||
return myPrefs.getStringList(key);
|
||||
}
|
||||
|
||||
Future<String?> getToken() async {
|
||||
final SharedPreferences pref = await SharedPreferences.getInstance();
|
||||
return pref.getString("token");
|
||||
}
|
||||
|
||||
Future<String?> getRefreshToken() async {
|
||||
final SharedPreferences pref = await SharedPreferences.getInstance();
|
||||
return pref.getString("refresh_token");
|
||||
}
|
||||
|
||||
Future<String?> getEmail() async {
|
||||
final SharedPreferences pref = await SharedPreferences.getInstance();
|
||||
return pref.getString("email");
|
||||
}
|
||||
|
||||
Future<int?> getIdUser() async {
|
||||
final SharedPreferences pref = await SharedPreferences.getInstance();
|
||||
return pref.getInt("idUser");
|
||||
}
|
||||
|
||||
Future<String?> getStateintro() async {
|
||||
// String value = await storage.read(key: 'intro');
|
||||
print(await storage.read(key: 'intro'));
|
||||
return await storage.read(key: 'intro');
|
||||
}
|
||||
|
||||
Future logout() async {
|
||||
final SharedPreferences pref = await SharedPreferences.getInstance();
|
||||
pref.clear();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user