getCachedProxies method

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

Gets the cached proxies

Implementation

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

  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 proxies: $e');
  }
}