Flutter: shared preferences
问题 I have this function: Future<String> load(SharedPreferences prefs, String fileName) async { prefs = await SharedPreferences.getInstance(); String jsonString = prefs.getString(fileName) ?? ""; if (jsonString.isNotEmpty) { return jsonString; }else{ return ... } } What should I return in the else case? I tried with "" but it doesn't work. 回答1: The answer is "it depends". Namely, it depends on what exactly you are doing with the result of this function, and what a good empty default value means