setFromResponse method
Set the image file from http response and url
Implementation
Future<void> setFromResponse({required Response response, required String url}) async {
List<String> _e = url.split(".");
if (_e.length <= 1) throw Exception("url dont have extension");
try{
kIsWeb
? await PlatformTools().setFile(response: response, headers: headers).then((r) {
_file = r.platformFile;
_bytes = r.platformFile.bytes;
_error = r.error;
_hasImage = !r.error;
_extension = _e.last;
notifyListeners();
})
: await PlatformTools().setFile(response: response).then((r) {
_file = r.platformFile;
_bytes = r.platformFile.bytes;
_error = r.error;
_hasImage = !r.error;
_extension = _e.last;
notifyListeners();
});
} catch (e){
debugPrint('n_image_piker e1: $e');
_reset(error: true);
notifyListeners();
}
}