getNextProxy method
Gets the next proxy from the internal list
Implementation
@override
Proxy? getNextProxy() {
if (_proxies.isEmpty || _countryCodes.isEmpty) {
return null;
}
// Get the current country code
final countryCode = _countryCodes[_currentCountryIndex];
// Get the proxies for the current country
final countryProxies = _proxiesByCountry[countryCode] ?? [];
if (countryProxies.isEmpty) {
// Move to the next country
_currentCountryIndex = (_currentCountryIndex + 1) % _countryCodes.length;
_currentProxyIndex = 0;
return getNextProxy();
}
// Get the current proxy
final proxy = countryProxies[_currentProxyIndex];
// Move to the next proxy in the current country
_currentProxyIndex = (_currentProxyIndex + 1) % countryProxies.length;
// If we've gone through all proxies in the current country, move to the next country
if (_currentProxyIndex == 0) {
_currentCountryIndex = (_currentCountryIndex + 1) % _countryCodes.length;
}
return proxy;
}