-
Notifications
You must be signed in to change notification settings - Fork 38
Closed
Labels
Description
Package
flutter_map_cache
Bug Description
Hi,
when I try to implement FlutterMapCache with HiveCacheStore as in the description I get the following error message:
The argument type 'HiveCacheStore' can't be assigned to the parameter type 'CacheStore'.
Steps to Reproduce
Just implement like in the example
Expected Results
Map caching
Actual Results
TypeError
Code Sample
pubspec.yaml
cupertino_icons: ^1.0.8
go_router: ^14.6.0
flutter_map: ^7.0.0
flutter_map_cache: ^1.3.0
path_provider: ^2.1.2
http_cache_hive_store: ^5.0.0
dio_cache_interceptor: ^4.0.3
import 'package:flutter_map/flutter_map.dart' show TileProvider;
import 'package:flutter_map_cache/flutter_map_cache.dart';
import 'package:http_cache_hive_store/http_cache_hive_store.dart' show HiveCacheStore;
import 'package:path_provider/path_provider.dart' show getTemporaryDirectory;
Future<TileProvider> createTileProvider() async {
final dir = await getTemporaryDirectory();
final cacheStore = HiveCacheStore(
'${dir.path}${Platform.pathSeparator}HiveCacheStore',
hiveBoxName: 'HiveCacheStore',
);
return CachedTileProvider(store: cacheStore);
}
FlutterMap(
mapController: mapController,
options: MapOptions(),
children: [
FutureBuilder(
future: createTileProvider(),
builder: (context, snapshot) {
if (snapshot.hasError) {
debugPrint('ERROR: CACHE MAP');
cacheStore = null;
}
if (snapshot.hasData) {
cacheStore = snapshot.data!;
}
return TileLayer(
retinaMode: false,
userAgentPackageName: 'com.xxx.yyy',
tileProvider: cacheStore,
urlTemplate:
'https://api.mapbox.com/styles/v1/{styleID}/tiles/256/{z}/{x}/{y}@2x?access_token={accessToken}',
additionalOptions: {
'styleID': 'xxxx',
'accessToken': 'yyyyy'
});
}),
]);
}
Platforms
iOS
Reactions are currently unavailable