Skip to content

Commit 47a4882

Browse files
ZhuJHuajosxha
andauthored
feat(fmc): update cache store dependencies (#82)
Bump version to 1.5.3 Fix #81 --------- Co-authored-by: Joscha Eckert <34318751+josxha@users.noreply.github.com>
1 parent 3d346e5 commit 47a4882

File tree

14 files changed

+84
-52
lines changed

14 files changed

+84
-52
lines changed

.github/FUNDING.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github: [ "josxha" ]
2+
custom: [ "https://paypal.me/joschaeckert" ]

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ functionality of [flutter_map](https://pub.dev/packages/flutter_map).
1919

2020
## Packages
2121

22-
### [flutter_map_cache](https://pub.dev/packages/flutter_map_cache)
22+
### [flutter_map_cache](https://github.com/josxha/flutter_map_plugins/tree/main/flutter_map_cache)
2323

2424
[![Pub Version](https://img.shields.io/pub/v/flutter_map_cache)](https://pub.dev/packages/flutter_map_cache)
2525
[![likes](https://img.shields.io/pub/likes/flutter_map_cache?logo=flutter)](https://pub.dev/packages/flutter_map_cache)
@@ -33,7 +33,7 @@ storage backend you would possibly want.
3333
and flutter_map.
3434
- Support for tile cancellation
3535

36-
### [flutter_map_compass](https://pub.dev/packages/flutter_map_compass)
36+
### [flutter_map_compass](https://github.com/josxha/flutter_map_plugins/tree/main/flutter_map_compass)
3737

3838
[![Pub Version](https://img.shields.io/pub/v/flutter_map_compass)](https://pub.dev/packages/flutter_map_compass)
3939
[![likes](https://img.shields.io/pub/likes/flutter_map_compass?logo=flutter)](https://pub.dev/packages/flutter_map_compass)
@@ -42,7 +42,7 @@ storage backend you would possibly want.
4242
A compass for flutter_map that indicates the map rotation. It rotates the map
4343
back to north on top when clicked.
4444

45-
### [flutter_map_maplibre](https://pub.dev/packages/flutter_map_maplibre)
45+
### [flutter_map_maplibre](https://github.com/josxha/flutter_map_plugins/tree/main/flutter_map_maplibre)
4646

4747
[![Pub Version](https://img.shields.io/pub/v/flutter_map_maplibre)](https://pub.dev/packages/flutter_map_maplibre)
4848
[![likes](https://img.shields.io/pub/likes/flutter_map_maplibre?logo=flutter)](https://pub.dev/packages/flutter_map_maplibre)
@@ -51,7 +51,7 @@ back to north on top when clicked.
5151
Performant Mapbox Vector Tiles (MVT) support for flutter_map powered by native
5252
MapLibre SDKs.
5353

54-
### [flutter_map_mbtiles](https://pub.dev/packages/flutter_map_mbtiles)
54+
### [flutter_map_mbtiles](https://github.com/josxha/flutter_map_plugins/tree/main/flutter_map_mbtiles)
5555

5656
[![Pub Version](https://img.shields.io/pub/v/flutter_map_mbtiles)](https://pub.dev/packages/flutter_map_mbtiles)
5757
[![likes](https://img.shields.io/pub/likes/flutter_map_mbtiles?logo=flutter)](https://pub.dev/packages/flutter_map_mbtiles)
@@ -64,7 +64,7 @@ flutter_map tile layers.
6464
for the MBTiles support.
6565
- MBTiles is a file format to store map tiles in a single SQLite database.
6666

67-
### [flutter_map_pmtiles](https://pub.dev/packages/flutter_map_pmtiles)
67+
### [flutter_map_pmtiles](https://github.com/josxha/flutter_map_plugins/tree/main/flutter_map_pmtiles)
6868

6969
[![Pub Version](https://img.shields.io/pub/v/flutter_map_pmtiles)](https://pub.dev/packages/flutter_map_pmtiles)
7070
[![likes](https://img.shields.io/pub/likes/flutter_map_pmtiles?logo=flutter)](https://pub.dev/packages/flutter_map_pmtiles)
@@ -80,7 +80,7 @@ flutter_map tile layers.
8080
learn more about
8181
PMTiles.
8282

83-
### [vector_map_tiles_mbtiles](https://pub.dev/packages/vector_map_tiles_mbtiles)
83+
### [vector_map_tiles_mbtiles](https://github.com/josxha/flutter_map_plugins/tree/main/vector_map_tiles_mbtiles)
8484

8585
[![Pub Version](https://img.shields.io/pub/v/vector_map_tiles_mbtiles)](https://pub.dev/packages/vector_map_tiles_mbtiles)
8686
[![likes](https://img.shields.io/pub/likes/vector_map_tiles_mbtiles?logo=flutter)](https://pub.dev/packages/vector_map_tiles_mbtiles)
@@ -94,7 +94,7 @@ adds support for vector tiles to flutter_map.
9494
for the MBTiles support.
9595
- MBTiles is a file format to store map tiles in a single SQLite database.
9696

97-
### [vector_map_tiles_pmtiles](https://pub.dev/packages/vector_map_tiles_pmtiles)
97+
### [vector_map_tiles_pmtiles](https://github.com/josxha/flutter_map_plugins/tree/main/vector_map_tiles_pmtiles)
9898

9999
[![Pub Version](https://img.shields.io/pub/v/vector_map_tiles_pmtiles)](https://pub.dev/packages/vector_map_tiles_pmtiles)
100100
[![likes](https://img.shields.io/pub/likes/vector_map_tiles_pmtiles?logo=flutter)](https://pub.dev/packages/vector_map_tiles_pmtiles)

example/lib/flutter_map_cache/cache_store_types.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import 'dart:io';
22

33
import 'package:dio_cache_interceptor/dio_cache_interceptor.dart';
4-
import 'package:dio_cache_interceptor_db_store/dio_cache_interceptor_db_store.dart';
5-
import 'package:dio_cache_interceptor_file_store/dio_cache_interceptor_file_store.dart';
6-
import 'package:dio_cache_interceptor_hive_store/dio_cache_interceptor_hive_store.dart';
74
import 'package:flutter/material.dart';
5+
import 'package:http_cache_drift_store/http_cache_drift_store.dart';
6+
import 'package:http_cache_file_store/http_cache_file_store.dart';
7+
import 'package:http_cache_hive_store/http_cache_hive_store.dart';
88

99
enum CacheStoreTypes {
1010
memCache('MemCache'),
@@ -18,7 +18,7 @@ enum CacheStoreTypes {
1818

1919
CacheStore getCacheStore(String path) => switch (this) {
2020
CacheStoreTypes.memCache => MemCacheStore(),
21-
CacheStoreTypes.dbCache => DbCacheStore(
21+
CacheStoreTypes.dbCache => DriftCacheStore(
2222
databasePath: path,
2323
databaseName: 'DbCacheStore',
2424
),
@@ -33,7 +33,7 @@ enum CacheStoreTypes {
3333

3434
CacheStore getCacheStoreWeb() => switch (this) {
3535
CacheStoreTypes.memCache => MemCacheStore(),
36-
CacheStoreTypes.dbCache => DbCacheStore(
36+
CacheStoreTypes.dbCache => DriftCacheStore(
3737
databasePath: '', // ignored on web
3838
databaseName: 'DbCacheStore',
3939
),

example/pubspec.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ dependencies:
1818
connectivity_plus: ^6.0.0
1919
path_provider: ^2.0.15
2020
dio: ^5.2.0+1
21-
dio_cache_interceptor: ^3.4.2
22-
dio_cache_interceptor_db_store: ^6.0.0
23-
dio_cache_interceptor_file_store: ^1.2.2
24-
dio_cache_interceptor_hive_store: ^4.0.0
21+
dio_cache_interceptor: ^4.0.0
22+
http_cache_drift_store: ^7.0.0
23+
http_cache_file_store: ^2.0.0
24+
http_cache_hive_store: ^5.0.0
2525
sqlite3_flutter_libs: ^0.5.15
2626
# vector_map_tiles: ^8.0.0
2727
# vector_tile_renderer: ^6.0.0

flutter_map_cache/CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
## [2.0.0] 2025-04-06
2+
3+
- Use
4+
[dio_cache_interceptor: ^4.0.0](https://pub.dev/packages/dio_cache_interceptor/changelog#400)
5+
- Remove deprecated `dioOptions` parameter
6+
- Add
7+
[hitCacheOnNetworkFailure](https://pub.dev/documentation/dio_cache_interceptor/latest/dio_cache_interceptor/CacheOptions/hitCacheOnNetworkFailure.html)
8+
- Remove `hitCacheOnErrorExcept` in favor of the
9+
new [hitCacheOnErrorCodes](https://pub.dev/documentation/dio_cache_interceptor/latest/dio_cache_interceptor/CacheOptions/hitCacheOnErrorCodes.html)
10+
11+
Please update your integration and used store packages according to
12+
the [Getting Started section](https://pub.dev/packages/flutter_map_cache#getting-started).
13+
More information can be found in
14+
the [dio_cache_interceptor changelog](https://pub.dev/packages/dio_cache_interceptor/changelog#400).
15+
116
## [1.5.2] 2025-02-05
217

318
- Support for flutter_map v6, v7 and v8

flutter_map_cache/README.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@ Supported storage backends are:
4040
| In-Memory | - For testing purposes<br/>- `flutter_map` has memory caching itself |
4141
| File System | - Easy to setup, no additional storage backend package required<br/>- potentially slower than using a database |
4242
| [Drift](https://pub.dev/packages/drift) | - SQLite database<br/>- good platform support |
43-
| [Hive](https://pub.dev/packages/hive) | - key-value database<br/>- easy to integrate |
44-
| [ObjectBox](https://pub.dev/packages/objectbox) | - NoSQL, ACID compliant<br/>- Fast library<br/>- More complex integration |
45-
| [Isar](https://pub.dev/packages/isar) | - NoSQL<br/>- Fast library<br/>- More complex integration |
43+
| [Hive CE](https://pub.dev/packages/hive_ce) | - key-value database<br/>- easy to integrate |
44+
| [ObjectBox](https://pub.dev/packages/objectbox) | - NoSQL database<br/>- More complex integration |
45+
| [Isar](https://pub.dev/packages/isar) | - NoSQL database<br/>- More complex integration |
46+
| [Sembast](https://pub.dev/packages/sembast) | - NoSQL database |
4647

4748
Other storage backends will be supported as soon as the underlying package
4849
[dio_cache_interceptor](https://pub.dev/packages/dio_cache_interceptor) supports
@@ -60,22 +61,28 @@ dependencies:
6061
path_provider: ^2.1.2 # in case the storage backend requires a path
6162

6263
# drift
63-
dio_cache_interceptor_db_store: ^5.1.0
64+
http_cache_drift_store: ^7.0.0
6465
sqlite3_flutter_libs: ^0.5.15
6566

6667
# file system
67-
dio_cache_interceptor_file_store: ^1.2.2
68+
http_cache_file_store: ^2.0.0
6869

6970
# hive
70-
dio_cache_interceptor_hive_store: ^3.2.1
71+
http_cache_hive_store: ^5.0.0
7172

7273
# objectbox
73-
dio_cache_interceptor_objectbox_store: ^1.1.3
74+
http_cache_objectbox_store: ^2.0.0
7475
objectbox_flutter_libs: ^1.4.1
7576

7677
# isar
78+
http_cache_isar_store: ^2.0.0
7779
isar: ^3.1.0+1
7880
isar_flutter_libs: ^3.1.0+1
81+
82+
# sembast
83+
http_cache_sembast_store: ^1.0.0
84+
sembast: ^3.8.4+1
85+
sembast_web: ^2.4.1
7986
```
8087
8188
2. ⚠️ Some storage backends have their own required setups. Please check them
@@ -181,7 +188,7 @@ class MyMap extends StatelessWidget {
181188
import 'dart:io';
182189
183190
import 'package:dio_cache_interceptor/dio_cache_interceptor.dart';
184-
import 'package:dio_cache_interceptor_file_store/dio_cache_interceptor_file_store.dart';
191+
import 'package:http_cache_file_store/http_cache_file_store.dart';
185192
import 'package:flutter/material.dart';
186193
import 'package:flutter_map/flutter_map.dart';
187194
import 'package:flutter_map_cache/flutter_map_cache.dart';

flutter_map_cache/lib/src/cached_tile_provider.dart

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,13 @@ class CachedTileProvider extends TileProvider {
1919
required CacheStore store,
2020
CachePolicy cachePolicy = CachePolicy.forceCache,
2121
Dio? dio,
22-
@Deprecated(
23-
'''
24-
This parameter will be removed in version 2.0.0 of flutter_map_cache.
25-
26-
Please use the `dio` parameter instead and provide your own Dio instance.
27-
28-
CachedTileProvider(
29-
dio: Dio(
30-
BaseOptions(...),
31-
),
32-
),
33-
''',
34-
)
35-
BaseOptions? dioOptions,
3622
List<Interceptor>? interceptors,
3723
Duration? maxStale,
3824
CacheKeyBuilder? keyBuilder,
39-
List<int>? hitCacheOnErrorExcept = defaultHitCacheOnErrorExcept,
40-
}) : dio = dio ?? Dio(dioOptions ?? BaseOptions()) {
25+
List<int> hitCacheOnErrorCodes =
26+
CachedTileProvider.defaultHitCacheOnErrorCodes,
27+
bool hitCacheOnNetworkFailure = true,
28+
}) : dio = dio ?? Dio() {
4129
this.dio.interceptors.addAll([
4230
...?interceptors,
4331
DioCacheInterceptor(
@@ -47,7 +35,8 @@ class CachedTileProvider extends TileProvider {
4735
policy: cachePolicy,
4836
maxStale: maxStale,
4937
keyBuilder: keyBuilder ?? CacheOptions.defaultCacheKeyBuilder,
50-
hitCacheOnErrorExcept: hitCacheOnErrorExcept,
38+
hitCacheOnErrorCodes: hitCacheOnErrorCodes,
39+
hitCacheOnNetworkFailure: hitCacheOnNetworkFailure,
5140
),
5241
),
5342
]);
@@ -56,14 +45,13 @@ class CachedTileProvider extends TileProvider {
5645
/// dio http client
5746
final Dio dio;
5847

59-
/// list of http status codes that will not hit the cache, e.g. if the user
60-
/// needs authentication or the server is currently not able to handle the
61-
/// request
62-
static const List<int> defaultHitCacheOnErrorExcept = [
63-
HttpStatus.unauthorized,
64-
HttpStatus.forbidden,
65-
HttpStatus.badGateway,
66-
];
48+
/// List of HTTP status codes that allow to return a previous cached
49+
/// response.
50+
///
51+
/// If a request fails with a status code in this list,
52+
/// the cached response (if available) will be used instead of treating
53+
/// the error as a complete failure.
54+
static const List<int> defaultHitCacheOnErrorCodes = [HttpStatus.notFound];
6755

6856
@override
6957
bool get supportsCancelLoading => true;

flutter_map_cache/pubspec.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
name: flutter_map_cache
22
description: A slim yet powerful caching plugin for flutter_map tile layers.
3-
version: 1.5.2
3+
version: 2.0.0
44
repository: https://github.com/josxha/flutter_map_plugins
55
issue_tracker: https://github.com/josxha/flutter_map_plugins/issues
66
resolution: workspace
7-
87
topics: [ flutter-map, map, cache, dio ]
8+
funding:
9+
- https://paypal.me/joschaeckert
10+
- https://github.com/sponsors/josxha
911

1012
platforms:
1113
android:
@@ -20,7 +22,7 @@ environment:
2022

2123
dependencies:
2224
dio: ^5.2.0+1
23-
dio_cache_interceptor: ^3.4.2
25+
dio_cache_interceptor: ^4.0.0
2426
flutter:
2527
sdk: flutter
2628
flutter_map: ">=6.0.0 <9.0.0"

flutter_map_compass/pubspec.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ issue_tracker: https://github.com/josxha/flutter_map_plugins/issues
55
topics: [ flutter-map, map ]
66
version: 1.1.1
77
resolution: workspace
8+
funding:
9+
- https://paypal.me/joschaeckert
10+
- https://github.com/sponsors/josxha
811

912
environment:
1013
sdk: '>=3.6.0 <4.0.0'

flutter_map_maplibre/pubspec.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ topics: [ flutter-map, map, vector, maplibre, mvt ]
55
repository: https://github.com/josxha/flutter_map_plugins
66
issue_tracker: https://github.com/josxha/flutter_map_plugins/issues
77
resolution: workspace
8+
funding:
9+
- https://paypal.me/joschaeckert
10+
- https://github.com/sponsors/josxha
811

912
environment:
1013
sdk: '>=3.7.0 <4.0.0'

flutter_map_mbtiles/pubspec.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ repository: https://github.com/josxha/flutter_map_plugins
55
issue_tracker: https://github.com/josxha/flutter_map_plugins/issues
66
topics: [ flutter-map, mbtiles, map ]
77
resolution: workspace
8+
funding:
9+
- https://paypal.me/joschaeckert
10+
- https://github.com/sponsors/josxha
811

912
environment:
1013
sdk: ">=3.6.0 <4.0.0"

flutter_map_pmtiles/pubspec.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ issue_tracker: https://github.com/josxha/flutter_map_plugins/issues
55
topics: [ flutter-map, map, pmtiles ]
66
version: 1.0.5
77
resolution: workspace
8+
funding:
9+
- https://paypal.me/joschaeckert
10+
- https://github.com/sponsors/josxha
811

912
environment:
1013
sdk: '>=3.6.0 <4.0.0'

vector_map_tiles_mbtiles/pubspec.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ issue_tracker: https://github.com/josxha/flutter_map_plugins/issues
55
topics: [ flutter-map, vector-map-tiles, map, mbtiles ]
66
version: 1.2.1
77
resolution: workspace
8+
funding:
9+
- https://paypal.me/joschaeckert
10+
- https://github.com/sponsors/josxha
811

912
environment:
1013
sdk: '>=3.6.0 <4.0.0'

vector_map_tiles_pmtiles/pubspec.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ issue_tracker: https://github.com/josxha/flutter_map_plugins/issues
55
topics: [ flutter-map, vector-map-tiles, map, pmtiles ]
66
version: 1.5.1
77
resolution: workspace
8+
funding:
9+
- https://paypal.me/joschaeckert
10+
- https://github.com/sponsors/josxha
811

912
environment:
1013
sdk: '>=3.6.0 <4.0.0'

0 commit comments

Comments
 (0)