import 'package:shared_preferences/shared_preferences.dart'; import 'package:slothmu/business_logic/auth/oauth.dart'; enum Settings { instanceUrl, username, } void saveSetting(Settings setting, dynamic value) async { final prefs = await SharedPreferences.getInstance(); } Future saveInstanceUrl(String url) async { final prefs = await SharedPreferences.getInstance(); return await prefs.setString("instance-url", url); } Future loadInstanceUrl() async { final prefs = await SharedPreferences.getInstance(); String? possibleReturn = prefs.getString("instance-url"); if (possibleReturn == null) { return "example.com"; } else { return possibleReturn; } } Future saveUsername(String username) async { final prefs = await SharedPreferences.getInstance(); return await prefs.setString("username", username); } Future saveAuthCode(String code) async { final prefs = await SharedPreferences.getInstance(); return await prefs.setString("authcode", code); } Future loadAuthCode() async { final prefs = await SharedPreferences.getInstance(); String? code = prefs.getString("authcode"); if (code == null) { return ""; } return code; }