loris/lib/business_logic/settings.dart
2022-06-30 17:34:09 +02:00

30 lines
793 B
Dart

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