Skip to content

Commit

Permalink
add dio parameter, deprecate dioOptions (#8)
Browse files Browse the repository at this point in the history
* Added optional Dio parameter

* deprecate `dioOptions`

---------

Co-authored-by: Patrick Wulfe <[email protected]>
Co-authored-by: Joscha <[email protected]>
  • Loading branch information
3 people authored Jan 24, 2024
1 parent bf85e6c commit a791435
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions lib/src/cached_tile_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,29 @@ class CachedTileProvider extends TileProvider {
/// Create a new [CachedTileProvider]
CachedTileProvider({
required CacheStore store,
Dio? dio,
@Deprecated(
'''
This parameter will be removed in version 2.0.0 of flutter_map_cache.
Please use the `dio` parameter instead and provide your own Dio instance.
CachedTileProvider(
dio: Dio(
BaseOptions(...),
),
),
''',
)
BaseOptions? dioOptions,
List<Interceptor>? interceptors,
Duration? maxStale,
CacheKeyBuilder? keyBuilder,
List<int>? hitCacheOnErrorExcept = defaultHitCacheOnErrorExcept,
}) : dio = Dio(dioOptions) {
dio.interceptors.addAll([
if (interceptors != null) ...interceptors,
}) : dio = dio ?? Dio(dioOptions) {
this.dio.options = dioOptions ?? BaseOptions();
this.dio.interceptors.addAll([
...?interceptors,
DioCacheInterceptor(
options: CacheOptions(
store: store,
Expand All @@ -41,6 +56,7 @@ class CachedTileProvider extends TileProvider {
static const List<int> defaultHitCacheOnErrorExcept = [
HttpStatus.unauthorized,
HttpStatus.forbidden,
HttpStatus.badGateway,
];

@override
Expand Down

0 comments on commit a791435

Please sign in to comment.