-
-
Notifications
You must be signed in to change notification settings - Fork 894
Labels
Description
What is the bug?
The tileBuilder function of a tile layer is only invoked on an image error if an errorImage has been passed. Therefore, it is not possible to construct a custom error widget in the tile builder itself.
How can we reproduce it?
Create a tile layer with a URL template which produces an error, e.g. https://example.com/{z}/{y}/{x}.
FlutterMap(
children: [
TileLayer(
urlTemplate: 'https://example.com/{z}/{y}/{x}',
tileBuilder: (context, tileWidget, tile) {
if (tile.loadError) { // This is never true
return Icon(Icons.cancel);
}
return tileWidget;
},
),
],
);Note that the builder never returns the icon since loadError is always false.
Do you have a potential solution?
In TileImage._onImageLoadError, notifyListeners() is only invoked in _display(), which in turn is only called if errorImage != null. To trigger a rebuild even if errorImage is not set, listeners should be notified in that case as well.