getSize method
Implementation
@VoltronMethod(kFuncGetSize)
bool getSize(String url, JSPromise promise) {
var img = getImage(url);
img.resolve(const ImageConfiguration()).addListener(ImageStreamListener(
(image, sync) {
var img = image.image;
var params = VoltronMap();
params.push('width', img.width);
params.push('height', img.height);
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;
}