import 'package:shared_preferences/shared_preferences.dart'; class LocalShare { static Future _prefs = SharedPreferences.getInstance(); static Future saveData(String key, String value) async { SharedPreferences prefs = await _prefs; prefs.setString(key, value); // 其他数据类型可以使用prefs.setInt, prefs.setBool等 } static Future readData(String key) async { SharedPreferences prefs = await _prefs; String data = prefs.getString(key) ?? ''; return data; } }