Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
flutter pub add flutter_map_tile_cachingdependency_overrides:
flutter_map_tile_caching:
git:
url: https://github.com/JaffaKetchup/flutter_map_tile_caching.git
# ref: a commit hash, branch name, or tag (otherwise defaults to master)import 'package:flutter_map_tile_caching/flutter_map_tile_caching.dart';
// You'll also need to import flutter_map and (likely) latlong2 seperately// final store = FMTCStore('storeName');
await FMTCStore('storeName').manage.create(); // Refers to the same store as abovefinal mgmt = FMTCStore('storeName').manage;
await mgmt.ready; // Check whether the store exists
await mgmt.create(); // Create the store
await mgmt.delete(); // Empty tiles from the store, and delete it
await mgmt.reset(); // Empty tiles from the store, and reset hits & misses
await mgmt.rename('newStoreName'); // Change the name of the store
await mgmt.removeTilesOlderThan(DateTime.timestamp()); // Empty all tiles last modified before the specified timestampimport 'package:flutter/widgets.dart';
import 'package:flutter_map_tile_caching/flutter_map_tile_caching.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
try {
await FMTCObjectBoxBackend().initialise(...); // The default/built-in backend
} catch (error, stackTrace) {
// See below for error/exception handling
}
// ...
runApp(MyApp());
}FMTCObjectBoxBackend.import 'dart:io';
import 'package:path/path.dart' as path;
import 'package:path_provider/path_provider.dart';
final dir = Directory(
path.join(
(await getApplicationDocumentsDirectory()).absolute.path,
'fmtc',
),
);
await dir.delete(recursive: true);
// Then reinitialise FMTCfinal stats = FMTCStore('storeName').stats;
await stats.all; // Retrieve the size, length, hits, and misses of this store
await stats.size; // Retrieve the total number of KiBs of all tiles' bytes (not 'real total' size)
await stats.length; // Retrieve the number of tiles belonging to this store
await stats.hits; // Retrieve the number of successful tile retrievals when browsing
await stats.misses; // Retrieve number of unsuccessful tile retrievals when browsing
await stats.tileImage(); // Retrieve the tile most recently modified in the specified store
await stats.watchChanges(); // Watch for changes to statistics (including tile events) and metadatafinal stats = FMTCRoot.stats;
await stats.storesAvailable; // List all the available/existing stores
await stats.realSize; // Retrieve the actual total size of the database in KiBs
await stats.size; // Retrieve the total number of KiBs of all tiles' bytes (not 'real total' size) from all stores
await stats.length; // Retrieve the total number of tiles in all stores
await stats.watchRecovery(); // Watch for changes to the recovery system
await stats.watchStores(); // Watch for changes in the specified (or all) storesflutter pub add flutter_map_tile_cachingimport 'package:flutter_map_tile_caching/flutter_map_tile_caching.dart';import 'package:flutter/widgets.dart';
import 'package:flutter_map_tile_caching/flutter_map_tile_caching.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await FMTCObjectBoxBackend().initialise(...);
// ...
runApp(MyApp());
}final rec = FMTCRoot.recovery;
await rec.recoverableRegions; // List all recoverable regions, and whether each one has failed
await rec.recoverableRegions.failedOnly; // List all failed downloads
await stats.getRecoverableRegion(); // Retrieve a specific recoverable region by ID
await stats.cancel(); // Safely remove the specified recoverable regionfinal md = FMTCStore('storeName').metadata;
await md.read; // Retrieve (all) the stored metadata
await md.set(); // Set a single key-value pair (overwriting any existing value for the key)
await md.setBulk(); // Set multiple key-value pairs (overwriting any existing value for each key)
await md.remove(); // Remove the specified key (and corresponding value)
await md.reset(); // Remove all keys (and values)await FMTCRoot.external('~/path/to/file.fmtc').export(['storeName']);

final region = CircleRegion(
LatLng(
final centerCoordinate = LatLng(0, 0)
final region = LineRegion(
[LatLng(
final region = CustomPolygonRegion(
[LatLng(0, 0), LatLng(1, 1), ...], // List of coordinates
);final region = RectangleRegion(
LatLngBounds(LatLng(0, 0), LatLng(1, 1)),
); // ...
await FMTCStore('mapStore').manage.create();
// ...import 'package:flutter_map/flutter_map.dart';
import 'package:flutter_map_tile_caching/flutter_map_tile_caching.dart';
TileLayer(
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
userAgentPackageName: 'com.example.app',
tileProvider: FMTCStore('mapStore').getTileProvider(),
// Other parameters as normal
),
import 'package:flutter_map/flutter_map.dart';
class MapView extends StatefulWidget {
late final tileProvider = FMTCStore('storeName').getTileProvider();
Widget build(BuildContext context) {
return FlutterMap(
// options: MapOptions(),
children: [
TileLayer(
// Other config parameters
tileProvider: tileProvider,
),
],
);
}
}// Get a store directory
final StoreDirectory oldStore = FlutterMapTileCaching.instance('storeName'); // (or `FMTC.`)
// Access the root statistics
final RootDirectory oldRoot = FlutterMapTileCaching.instance.rootDirectory; // (or `FMTC.`)
final RootStats oldRootStats = oldRoot.stats;// Get a store
final FMTCStore newStore = FMTCStore('storeName');
// Access the root statistics
final RootStats newRootStats = FMTCRoot.stats;
// `FMTCRoot` must now be used immediately, because it is not an object instancehttps://tile.myserver.com/{z}/{x}/{y}?api_key=001239876&mode=dark
https://tile.myserver.com/{z}/{x}/{y}?&mode=darkfinal progressStream = FMTCStore('storeName').download.startForeground(
region: downloadableRegion,
// other options...
);