| | |
| | | import '../api/http.dart'; |
| | | import 'package:shared_preferences/shared_preferences.dart'; |
| | | |
| | | class ConfigUtil { |
| | | ///保存配置信息 |
| | | static void saveConfig(Map<String, dynamic> map) async { |
| | | SharedPreferences prefs = await SharedPreferences.getInstance(); |
| | | await prefs.setString("config_value", jsonEncode(map)); |
| | | } |
| | | import 'share_preference.dart'; |
| | | |
| | | class ConfigUtil { |
| | | static Future<String?> getConfig(BuildContext context, String key) async { |
| | | SharedPreferences prefs = await SharedPreferences.getInstance(); |
| | | String? result = prefs.getString("config_value"); |
| | | if (result != null) { |
| | | Map<String, dynamic> map = jsonDecode(result); |
| | | return map[key]; |
| | | } else { |
| | | //重新请求 |
| | | ConfigApiUtil.getConfig(context).then((value) { |
| | | if (value == null) { |
| | | return; |
| | | } |
| | | if (value["code"] == 0) { |
| | | saveConfig(value["data"]); |
| | | } |
| | | }); |
| | | } |
| | | return null; |
| | | String? value = await dataMethodChannel.invokeMethod("getConfig", key); |
| | | return value; |
| | | } |
| | | } |
| | | |
| | |
| | | static const String sdkList = "sdkList"; |
| | | } |
| | | |
| | | enum SharePlatform { wx, wxcircle, qq, qqzone, sina } |
| | | enum SharePlatform { all, wx, wxcircle, qq, qqzone, sina } |