import 'package:geosmart/model/setting.dart'; import 'package:shared_preferences/shared_preferences.dart'; class SettingService { final String _host = "host"; final String _id = "id"; Future getSharedPreferences() async { return await SharedPreferences.getInstance(); } Future setSetting(SettingModel setting) async { SharedPreferences sharedPreferences = await this.getSharedPreferences(); sharedPreferences.setString(_host, setting.host); sharedPreferences.setString(_id, setting.id); return await getSetting(); } Future clearSetting() async { SharedPreferences sharedPreferences = await this.getSharedPreferences(); sharedPreferences.remove(_host); sharedPreferences.remove(_id); return await getSetting(); } Future getSetting() async { SharedPreferences sharedPreferences = await this.getSharedPreferences(); return SettingModel( sharedPreferences.getString(_host), sharedPreferences.getString(_id), ); } }