1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| class SharedPreferences { SharedPreferences._(this._preferenceCache);
static const String _prefix = 'flutter.'; static SharedPreferences _instance; static Future<SharedPreferences> getInstance() async { if (_instance == null) { final Map<Object, Object> fromSystem = await _kChannel.invokeMethod('getAll'); assert(fromSystem != null); final Map<String, Object> preferencesMap = <String, Object>{}; for (String key in fromSystem.keys) { assert(key.startsWith(_prefix)); preferencesMap[key.substring(_prefix.length)] = fromSystem[key]; } _instance = SharedPreferences._(preferencesMap); } return _instance; }
|