reportError method
- @protected
@protected
Calls all the registered error listeners to notify them of an error that occurred while resolving the image.
If no error listeners are attached, a FlutterError will be reported instead.
Implementation
@protected
void reportError({
String context,
dynamic exception,
StackTrace stack,
InformationCollector informationCollector,
bool silent = false,
}) {
_currentError = FlutterErrorDetails(
exception: exception,
stack: stack,
library: 'image resource service',
context: context,
informationCollector: informationCollector,
silent: silent,
);
final List<ImageErrorListener> localErrorListeners =
_listeners.map<ImageErrorListener>(
(_ImageListenerPair listenerPair) => listenerPair.errorListener
).where(
(ImageErrorListener errorListener) => errorListener != null
).toList();
if (localErrorListeners.isEmpty) {
FlutterError.reportError(_currentError);
} else {
for (ImageErrorListener errorListener in localErrorListeners) {
try {
errorListener(exception, stack);
} catch (exception, stack) {
FlutterError.reportError(
FlutterErrorDetails(
context: 'by an image error listener',
library: 'image resource service',
exception: exception,
stack: stack,
),
);
}
}
}
}