fixes tile re-rendering after long rate limit periods without having to zoom/pan

This commit is contained in:
stopflock
2025-08-22 23:44:49 -05:00
parent 01f73322c7
commit f6adffc84e
6 changed files with 221 additions and 0 deletions
+23
View File
@@ -63,6 +63,10 @@ class _MapViewState extends State<MapView> {
// Ensure initial overlays are fetched
WidgetsBinding.instance.addPostFrameCallback((_) {
// Set up tile refresh callback
final tileProvider = Provider.of<TileProviderWithCache>(context, listen: false);
tileProvider.setOnTilesCachedCallback(_onTilesCached);
_refreshCamerasFromProvider();
});
}
@@ -72,6 +76,15 @@ class _MapViewState extends State<MapView> {
_positionSub?.cancel();
_debounce.dispose();
_cameraProvider.removeListener(_onCamerasUpdated);
// Clean up tile refresh callback
try {
final tileProvider = Provider.of<TileProviderWithCache>(context, listen: false);
tileProvider.setOnTilesCachedCallback(null);
} catch (e) {
// Context might be disposed already - that's okay
}
super.dispose();
}
@@ -79,6 +92,14 @@ class _MapViewState extends State<MapView> {
if (mounted) setState(() {});
}
void _onTilesCached() {
// When new tiles are cached, just trigger a widget rebuild
// This should cause the TileLayer to re-render with cached tiles
if (mounted) {
setState(() {});
}
}
void _refreshCamerasFromProvider() {
final appState = context.read<AppState>();
LatLngBounds? bounds;
@@ -159,6 +180,8 @@ class _MapViewState extends State<MapView> {
@override
Widget build(BuildContext context) {
final appState = context.watch<AppState>();