Skip to content

Commit c12405a

Browse files
committed
Changed parameters for provideTile to support vector tiles in future and remove unnecessary parameters
1 parent b9aaf09 commit c12405a

File tree

4 files changed

+15
-16
lines changed

4 files changed

+15
-16
lines changed

example/lib/src/screens/main/map_view/components/download_progress/download_progress_masker.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class DownloadProgressMasker extends StatefulWidget {
2828
final int minZoom;
2929
final int maxZoom;
3030
final int tileSize;
31-
final TileLayer child;
31+
final Widget child;
3232

3333
// To reset after a download, the `key` must be changed
3434

lib/src/providers/image_provider/image_provider.dart

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class _FMTCImageProvider extends ImageProvider<_FMTCImageProvider> {
4646
MultiFrameImageStreamCompleter(
4747
codec: provideTile(
4848
coords: coords,
49-
options: options,
49+
networkUrl: provider.getTileUrl(coords, options),
5050
provider: provider,
5151
key: key,
5252
finishedLoadingBytes: finishedLoadingBytes,
@@ -72,9 +72,9 @@ class _FMTCImageProvider extends ImageProvider<_FMTCImageProvider> {
7272

7373
/// {@macro fmtc.tileProvider.provideTile}
7474
static Future<Uint8List> provideTile({
75-
required TileCoordinates coords,
76-
required TileLayer options,
75+
required String networkUrl,
7776
required FMTCTileProvider provider,
77+
TileCoordinates? coords,
7878
Object? key,
7979
void Function()? startedLoading,
8080
void Function()? finishedLoadingBytes,
@@ -92,7 +92,7 @@ class _FMTCImageProvider extends ImageProvider<_FMTCImageProvider> {
9292
scheduleMicrotask(() => PaintingBinding.instance.imageCache.evict(key));
9393
}
9494

95-
if (currentTLIR != null) {
95+
if (currentTLIR != null && coords != null) {
9696
currentTLIR.error = error;
9797

9898
provider.tileLoadingInterceptor!
@@ -121,8 +121,7 @@ class _FMTCImageProvider extends ImageProvider<_FMTCImageProvider> {
121121
final Uint8List bytes;
122122
try {
123123
bytes = await _internalTileBrowser(
124-
coords: coords,
125-
options: options,
124+
networkUrl: networkUrl,
126125
provider: provider,
127126
requireValidImage: requireValidImage,
128127
currentTLIR: currentTLIR,

lib/src/providers/image_provider/internal_tile_browser.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
part of '../../../flutter_map_tile_caching.dart';
55

66
Future<Uint8List> _internalTileBrowser({
7-
required TileCoordinates coords,
8-
required TileLayer options,
7+
required String networkUrl,
98
required FMTCTileProvider provider,
109
required bool requireValidImage,
1110
required _TLIRConstructor? currentTLIR,
@@ -27,7 +26,6 @@ Future<Uint8List> _internalTileBrowser({
2726
}
2827
}
2928

30-
final networkUrl = provider.getTileUrl(coords, options);
3129
final matcherUrl = provider.urlTransformer?.call(networkUrl) ?? networkUrl;
3230

3331
currentTLIR?.networkUrl = networkUrl;

lib/src/providers/tile_provider/tile_provider.dart

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,7 @@ class FMTCTileProvider extends TileProvider {
300300
}
301301

302302
/// {@template fmtc.tileProvider.provideTile}
303-
/// Use FMTC's caching logic to get the bytes of the specific tile (at
304-
/// [coords]) with the specified [TileLayer] options and [FMTCTileProvider]
305-
/// provider
303+
/// Use FMTC's caching logic to get the bytes of the tile at [networkUrl]
306304
///
307305
/// > [!IMPORTANT]
308306
/// > Note that this will actuate the cache writing mechanism as if a normal
@@ -321,6 +319,10 @@ class FMTCTileProvider extends TileProvider {
321319
///
322320
/// ---
323321
///
322+
/// [coords] is required to enable functioning of
323+
/// [FMTCTileProvider.tileLoadingInterceptor]. If the tile loading interceptor
324+
/// is not in use, providing coordinates is not necessary.
325+
///
324326
/// [key] is used to control the [ImageCache], and should be set when in a
325327
/// context where [ImageProvider.obtainKey] is available.
326328
///
@@ -342,16 +344,16 @@ class FMTCTileProvider extends TileProvider {
342344
/// to be decoded (now or at a later time).
343345
/// {@endtemplate}
344346
Future<Uint8List> provideTile({
345-
required TileCoordinates coords,
346-
required TileLayer options,
347+
required String networkUrl,
348+
TileCoordinates? coords,
347349
Object? key,
348350
void Function()? startedLoading,
349351
void Function()? finishedLoadingBytes,
350352
bool requireValidImage = false,
351353
}) =>
352354
_FMTCImageProvider.provideTile(
353355
coords: coords,
354-
options: options,
356+
networkUrl: networkUrl,
355357
provider: this,
356358
key: key,
357359
startedLoading: startedLoading,

0 commit comments

Comments
 (0)