Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions lib/src/tile_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,23 @@ base class CancellableNetworkTileProvider extends TileProvider {
super.headers,
Dio? dioClient,
this.silenceExceptions = false,
}) : _dioClient = dioClient ?? Dio();
}) : _isInternallyCreatedClient = dioClient == null,
_dioClient = dioClient ?? Dio();

/// Whether to ignore exceptions and errors that occur whilst fetching tiles
/// over the network, and just return a transparent tile
final bool silenceExceptions;

/// Long living client used to make all tile requests by [CancellableNetworkImageProvider]
/// for the duration that this provider is alive
///
/// Not automatically closed if created externally and passed as an argument
/// during construction.
final Dio _dioClient;

/// Whether [_dioClient] was created on construction (and not passed in)
final bool _isInternallyCreatedClient;

/// Each [Completer] is completed once the corresponding tile has finished
/// loading
///
Expand Down Expand Up @@ -103,7 +110,7 @@ base class CancellableNetworkTileProvider extends TileProvider {
if (_tilesInProgress.isNotEmpty) {
await Future.wait(_tilesInProgress.values.map((c) => c.future));
}
_dioClient.close();
if (_isInternallyCreatedClient) _dioClient.close();
super.dispose();
}
}
Loading