handleCachedImageProvider static method
Implementation
static Future<ImageProvider> handleCachedImageProvider(String imageUrl) async {
if(imageUrl.isEmpty) {
imageUrl = AppProperties.getAppLogoUrl();
}
// On web, skip the http.get validation — it doubles fetch requests
// and triggers 429 rate limits from Google CDN. Just return the provider directly.
if (kIsWeb) {
return platformImageProvider(imageUrl);
}
try {
Uri uri = Uri.parse(imageUrl);
if(uri.host.isNotEmpty) {
http.Response response = await http.get(uri);
if (response.statusCode == 200) {
return platformImageProvider(imageUrl);
} else {
return platformImageProvider(AppProperties.getAppLogoUrl());
}
}
} catch (e, st){
NeomErrorLogger.recordError(e, st, module: 'neom_commons', operation: 'handleCachedImageProvider');
}
return platformImageProvider(AppProperties.getAppLogoUrl());
}