setFromResponse method
Set the image file from http response and url
Implementation
Future<void> setFromResponse({
required final Response response,
required final String url,
final int? maxSize
}) 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,
maxSize : maxSize,
extension : _e.last
).then((r) {
_file = r.platformFile;
_bytes = r.platformFile.bytes;
_error = r.error;
_hasImage = !r.error;
_extension = _e.last;
notifyListeners();
})
: await PlatformTools().setFile(
response : response,
maxSize : maxSize,
extension: _e.last
).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();
}
}