Invalid argument(s): No host specified in URI
🐛 Bug Report
Even if I put a static URL I am still getting the error below
Expected behavior
Expected behavior is that it is supposed to load the image but that is not happening
Reproduction steps
When switching to a screen that does not have cachedNetworkImage widget the error pops up
When the exception was thrown, this was the stack:
#0 _HttpClient._openUrl (dart:_http/http_impl.dart:2752:9)
#1 _HttpClient.openUrl (dart:_http/http_impl.dart:2623:7)
#2 IOClient.send (package:http/src/io_client.dart:117:38)
#3 HttpFileService.get (package:flutter_cache_manager/src/web/file_service.dart:37:44)
#4 WebHelper._download (package:flutter_cache_manager/src/web/web_helper.dart:115:24)
#5 WebHelper._updateFile (package:flutter_cache_manager/src/web/web_helper.dart:97:28)
Configuration
Version: 3.3.1
Platform:
- [ x] :iphone: iOS
- [ x] :robot: Android
I have the same problem
I have the same problem
I resorted to using this package, they resolve this better when it comes to caching: extended_image: ^8.2.0 hope it helps you out. @mazenshawky
Thanks, btw I found that this exception is caught. It doesn't affect the release mode or the flow of screens. It's just a way of informing the developer that the image didn't show.
Yeah that I do know but I just do not like seeing that in my command line hahahaha.
I have the same problem and it stops the execution of the project
@abbasihamed try to use Android Studio or if you are using Vs Code try to use command to run the project
The incoming URL cannot be an empty string, otherwise the above problem will occur.
flutter: ══╡ EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE ╞════════════════════════════════════════════════════
flutter: The following ArgumentError was thrown resolving an image codec:
flutter: Invalid argument(s): No host specified in URI
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #0 _HttpClient._openUrl (dart:_http/http_impl.dart:2752:9)
flutter: #1 _HttpClient.openUrl (dart:_http/http_impl.dart:2623:7)
flutter: #2 IOClient.send (package:http/src/io_client.dart:63:38)
flutter: #3 HttpFileService.get (package:flutter_cache_manager/src/web/file_service.dart:37:44)
flutter: #4 WebHelper._download (package:flutter_cache_manager/src/web/web_helper.dart:115:24)
flutter: #5 WebHelper._updateFile (package:flutter_cache_manager/src/web/web_helper.dart:97:28)
flutter:
I work around this exception by checking the image url before passing them to the CachedNetworkImage using a simple http request:
Future<bool> validateImageUrl(String url) async {
try {
final response = await $http.head(Uri.parse(url));
if (response.statusCode == 200) {
return true;
}
} catch (e) {
axlLog("Image url invalid $url");
}
return false;
}
An additional step could be added to check if the Content-Type is truly an image extension.
I currently have to add this manual step at each of the API request before passing the valid URL to the UI.
Thanks, btw I found that this exception is caught. It doesn't affect the release mode or the flow of screens. It's just a way of informing the developer that the image didn't show.
But if your project use Firebase Crashlytics or any crash report, the error will still reported.
🐛 Bug Report
Even if I put a static URL I am still getting the error below
Expected behavior
Expected behavior is that it is supposed to load the image but that is not happening
Reproduction steps
When switching to a screen that does not have cachedNetworkImage widget the error pops up
When the exception was thrown, this was the stack: #0 _HttpClient._openUrl (dart:_http/http_impl.dart:2752:9) #1 _HttpClient.openUrl (dart:_http/http_impl.dart:2623:7) #2 IOClient.send (package:http/src/io_client.dart:117:38) #3 HttpFileService.get (package:flutter_cache_manager/src/web/file_service.dart:37:44) #4 WebHelper._download (package:flutter_cache_manager/src/web/web_helper.dart:115:24) #5 WebHelper._updateFile (package:flutter_cache_manager/src/web/web_helper.dart:97:28) #6 WebHelper._downloadOrAddToQueue (package:flutter_cache_manager/src/web/web_helper.dart:65:7) Image provider: CachedNetworkImageProvider("", scale: 1.0) Image key: CachedNetworkImageProvider("", scale: 1.0): CachedNetworkImageProvider("", scale: 1.0)
Configuration
Version: 3.3.1
Platform:
- [ x] 📱 iOS
- [ x] 🤖 Android
i'have same error, but the error is the image url is '' or the image url is not right, however auther should check it better Instead of reporting an error directly.
i think the issue arises when combining both firebase and local file i.e, i am entering a default image to display when there is no image available in my profile but when there are image saved to firebase then it works fine this type of error didn't affect the build but i cant find any solution till now
I managed to solve this by adding a url validation check before loading image:
final isValid = Uri.parse(image!).hasAbsolutePath;
if (isValid) {
return CachedNetworkImage(
imageUrl: image ?? 'https://placehold.co/600x400',
fit: BoxFit.cover,
progressIndicatorBuilder: (context, url, downloadProgress) {
return returnShimmerBasedOnImageType(downloadProgress);
},
errorWidget: (context, url, error) {
return Image.asset(
'assets/images/app_logo.png',
fit: BoxFit.cover,
);
},
);
} else {
return Image.asset(
'assets/images/app_logo.png',
fit: BoxFit.cover,
);
}
```
Still Facing Same Issue image issue, Invalid argument(s): No host specified in URI file:///,#0 _HttpClient._openUrl (dart:_http/http_impl.dart:2756:9) Although its local Images and have a validation Check