File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
lib/src/layer/tile_layer/tile_provider Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,8 @@ class NetworkTileProvider extends TileProvider {
3636 super .headers,
3737 Client ? httpClient,
3838 this .silenceExceptions = false ,
39- }) : _httpClient = httpClient ?? RetryClient (Client ());
39+ }) : _isInternallyCreatedClient = httpClient == null ,
40+ _httpClient = httpClient ?? RetryClient (Client ());
4041
4142 /// Whether to ignore exceptions and errors that occur whilst fetching tiles
4243 /// over the network, and just return a transparent tile
@@ -45,8 +46,14 @@ class NetworkTileProvider extends TileProvider {
4546 /// Long living client used to make all tile requests by
4647 /// [MapNetworkImageProvider] for the duration that this provider is
4748 /// alive
49+ ///
50+ /// Not automatically closed if created externally and passed as an argument
51+ /// during construction.
4852 final Client _httpClient;
4953
54+ /// Whether [_httpClient] was created on construction (and not passed in)
55+ final bool _isInternallyCreatedClient;
56+
5057 /// Each [Completer] is completed once the corresponding tile has finished
5158 /// loading
5259 ///
@@ -76,7 +83,8 @@ class NetworkTileProvider extends TileProvider {
7683 if (_tilesInProgress.isNotEmpty) {
7784 await Future .wait (_tilesInProgress.values.map ((c) => c.future));
7885 }
79- _httpClient.close ();
86+ if (_isInternallyCreatedClient) _httpClient.close ();
87+
8088 super .dispose ();
8189 }
8290}
You can’t perform that action at this time.
0 commit comments