import 'package:device_info_plus/device_info_plus.dart'; import 'package:medcify/models/api/login_response.dart'; import 'package:medcify/models/store_item.dart'; import 'package:medcify/network/api_provider.dart'; import 'package:shared_preferences/shared_preferences.dart'; class Storage{ Storage._(); static final Storage instance = Storage._(); late AndroidDeviceInfo deviceInfo; late SharedPreferences sharedPreferences; String razorpayKey = ""; String razorpaySecretKey = ""; Future registerSharedPreferences() async{ final deviceInfoPlugin = DeviceInfoPlugin(); deviceInfo = await deviceInfoPlugin.androidInfo; sharedPreferences = await SharedPreferences.getInstance(); } Future setIsLoggedIn(bool val) async{ await sharedPreferences.setBool("isLoggedIn", val); } Future setMobile(String val) async{ await sharedPreferences.setString("mobile", val); } Future setStoreUrl(String val) async{ await sharedPreferences.setString("storeUrl", val); } Future setStoreId(int val) async{ await sharedPreferences.setInt("id", val); } Future setUser(LoginResponse response) async{ await sharedPreferences.setBool("storeStatus", response.storeStatus ?? false); await sharedPreferences.setString("token", response.token ?? ""); } Future fetchRazorPayData() async{ final response = await ApiProvider.instance.fetchRazorPayData(); if(response.status ?? false){ razorpayKey = response.razorPayKey ?? ""; razorpaySecretKey = response.razorPaySecretKey ?? ""; } } get isLoggedIn => sharedPreferences.getBool("isLoggedIn") ?? false; get storeStatus => sharedPreferences.getBool("storeStatus") ?? false; get mobile => sharedPreferences.getString("mobile") ?? ""; get storeUrl => sharedPreferences.getString("storeUrl") ?? ""; get id => sharedPreferences.getInt("id") ?? 0; get token => sharedPreferences.getString("token") ?? "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImtrayIsImlhdCI6MTY0Mzg3MDM3M30.ddDwVEzkdQPGrJDqpz1XxU8PVaE7Zq3KkxxjZwukX8o"; }