Advertisement
BlackBoY_

p

Feb 6th, 2023
1,071
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 1.39 KB | None | 0 0
  1. import 'package:shared_preferences/shared_preferences.dart';
  2.  
  3.  
  4. class HelperFunctions {
  5.   // keys
  6.   static String userLoggedInKey = "LOGGEDINKEY";
  7.   static String userNameKey = "USERNAMEKEY";
  8.   static String userEmailKey = "USEREMAILKEY";
  9.  
  10.  
  11. //saving the data to SF
  12.   static Future<bool?> saveUserLoggedInStatus(bool isUserLoggedIn) async {
  13.     SharedPreferences sf = await SharedPreferences.getInstance();
  14.     return await sf.setBool(userLoggedInKey, isUserLoggedIn);
  15.   }
  16.  
  17.   static Future<bool?> saveUserNameSF(String userName) async {
  18.     SharedPreferences sf = await SharedPreferences.getInstance();
  19.     return await sf.setString(userNameKey, userName);
  20.   }
  21.  
  22.   static Future<bool?> saveUserEmailSF(String userEmail) async {
  23.     SharedPreferences sf = await SharedPreferences.getInstance();
  24.     return await sf.setString(userEmailKey, userEmail);
  25.   }
  26.  
  27.  
  28. // getting the data from SF
  29.   static Future<bool?> getUserLoggedInStatus() async {
  30.     SharedPreferences sf = await SharedPreferences.getInstance();
  31.     return sf.getBool(userLoggedInKey);
  32.   }
  33.  
  34.   static Future<String?> getUserEmailFromSF() async {
  35.     SharedPreferences sf = await SharedPreferences.getInstance();
  36.     return sf.getString(userEmailKey);
  37.   }
  38.  
  39.   static Future<String?> getUserNameFromSF() async {
  40.     SharedPreferences sf = await SharedPreferences.getInstance();
  41.     return sf.getString(userNameKey);
  42.   }
  43.  
  44. }
  45.  
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement