Sometimes when I call this code:
Widget displayImage(BuildContext context, MyBook book) {
if (book.coverUrl != null) {
try {
return Image.network(book.coverUrl!,
errorBuilder: (context, error, stackTrace) {
return Text('No nimage');
});
} on Exception {
return Text('No nImage');
}
} else {
return Text('No nImage');
}
}
I receive the message
════════ Exception caught by image resource service ══════════════════
Invalid argument(s): No host specified in
URI file:///home/alan/FlutterProjects/books/null
═══════════════════════════════════════════════════════
(file:///home/alan/FlutterProjects/books/
is my app’s path. book.coverUrl
is a String
.)
The online image displays properly, despite the Exception message.
What causes this? Do I need to fix it?