prefetch method
Implementation
@VoltronMethod(kFuncPrefetch)
bool prefetch(String url, JSPromise promise) {
var img = getImage(url);
// img.obtainKey(ImageConfiguration());
// ImageCache().
img.resolve(const ImageConfiguration()).addListener(ImageStreamListener(
(image, sync) {
var img = image.image;
var params = VoltronMap();
params.push('width', img.width);
params.push('height', img.width);
promise.resolve(params);
},
onError: (exception, stackTrace) {
var err = FlutterErrorDetails(
context: ErrorDescription('image failed to precache'),
library: 'image resource service',
exception: exception,
stack: stackTrace,
silent: true,
);
var params = VoltronMap();
params.push('code', 10002);
params.push('msg', err.toString());
promise.reject(params);
},
));
return true;
}