fetchCepFromServices function
Implementation
Future<Cep> fetchCepFromServices(String cepWithLeftPad) async {
final results = await Future.wait([
fetchCorreiosService(cepWithLeftPad),
fetchViaCepService(cepWithLeftPad)
]).catchError((e) async {
if (e is SimpleError) {
print('[ViaCepFlutter - SimpleError] ' + (e.message ?? ''));
} else if (e is ServiceError) {
print('[ViaCepFlutter - ServiceError] ' + (e.message ?? ''));
}
});
return results[0];
}