Using Roots & Stores
Last updated
Was this helpful?
Last updated
Was this helpful?
FMTC uses Roots and Stores to structure it's data. Previously, these represented actual directories (hence the reference to directories within the codebase), but now they just represent databases.
There is usually only one root (formed of a directory and some miscellaneous databases) per application, which contains multiple stores (formed of a single database holding a descriptor, multiple tiles, and ).
Once you can access FlutterMapTileCaching.instance
after Initialisation, chaining of methods and accessors is used to access functionality.
Base Chains are used as an intermediate step to access functionality on Roots and Stores
Additional Chains are added to Base Chains to reach the actual functionality.
To get the Root, chain on rootDirectory
(the name of the accessor is a remnant leftover from previous versions).
To get a Store, there are two possible methods. FMTC does not use code generation, so store names are flexible, and so use String
s to access the Store.
This is the recommended method. Always use this method where possible.
call()
/()
gets a StoreDirectory
by the name inside the parentheses.
Note that the store will not be automatically created once accessed, as this requires asynchronous tasks, so it is important to create the store manually (if necessary).
After this, you can chain any of the following members/accessors (each will be accessible on a Root, a Store, or both).
Prefer using asynchronous versions of sub-methods where possible, as these won't block the UI thread.
If running inside an isolate, or blocking the UI thread doesn't matter, use the synchronous versions wherever possible, as they have slightly better performance.
Install
manage
Control, modify, and configure an actual structure ('physical' directory or database) itself
stats
Retrieve statistics about a structure (Root or Store) itself
recovery
Recover failed bulk downloads, and prepare them to restart
import
Import and prepare a store from a previously exported archive file
download
Prepare, start, and manage a store's bulk downloads
metadata
A simple key-value pair store designed for storing simple, store related information
export
Export a store to an archive file, for future importing
migrator
Migrate the incompatible file/directory structure of a previous version