elementOnLoad function
Returns a Future<bool> for when img
loads.
Implementation
Future<bool> elementOnLoad(ImageElement img) {
var completer = Completer<bool>();
img.onLoad.listen((e) => completer.complete(true),
onError: (e) => completer.complete(false));
return completer.future;
}