import 'dart:convert'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:zhiying_comm/util/empty_util.dart'; class SharedPreferencesUtil { static Future> getNetCacheResult(String key) async { if (!EmptyUtil.isEmpty(key)) { SharedPreferences prefs = await SharedPreferences.getInstance(); String cacheResult = prefs.getString(key); // TODO need解密? if (!EmptyUtil.isEmpty(cacheResult)) { Map map = json.decode(cacheResult); if(!EmptyUtil.isEmpty(map)) { return map; } } } return null; } static Future setNetCacheResult(String key, String value) async { if (!EmptyUtil.isEmpty(key) && !EmptyUtil.isEmpty(value)) { SharedPreferences prefs = await SharedPreferences.getInstance(); // TODO need加密? prefs.setString(key, value); } return; } }