我试图将 textEditing 控制器的值保存在 sharedPrefrences 中,我将它的值保存为字符串,但后来我不知道如何检索字符串的值并将其设置回 textEditingController ,这是我的代码:
void saveSubmitScreenPrefs(String phone, String number, String neighborhood,
String houseNumber, String streetNumber) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
prefs.setString("phone", phone);
prefs.setString("number", number);
prefs.setString("neighborhood", neighborhood);
prefs.setString("houseNumber", houseNumber);
prefs.setString("streetNumber", streetNumber);
print("saved the sumbit fields!");
}
void loadSubmitScreenPrefs() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
nameController = prefs.get("name").;
phoneNumberController = prefs.get("phone");
neighborhoodController = prefs.get("neighborhood");
streetNumberController = prefs.get("streetNumber");
houseNumberController = prefs.get("houseNumber");
notifyListeners();
}