getCachedValidatedProxies method

  1. @override
Future<List<ProxyModel>> getCachedValidatedProxies()
override

Gets the cached validated proxies

Implementation

@override
Future<List<ProxyModel>> getCachedValidatedProxies() async {
  final jsonString = sharedPreferences.getString(cachedValidatedProxiesKey);

  if (jsonString == null) {
    return [];
  }

  try {
    final jsonList = json.decode(jsonString) as List;
    return jsonList
        .map((item) => ProxyModel.fromJson(item as Map<String, dynamic>))
        .toList();
  } catch (e) {
    throw ProxyFetchException('Failed to parse cached validated proxies: $e');
  }
}