Using Roots & Stores
How It Works
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 Isar 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 metadata).
Chaining
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.
Base Chains
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).
Examples in this documentation will usually assume that the stores are already created/ready.
Additional Chains
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.
manage
Control, modify, and configure an actual structure ('physical' directory or database) itself
stats
Retrieve statistics about a structure (Root or Store) itself
Looking to modify the underlying databases youself?
This is not recommended, as they are carefully crafted to work with FMTC internal state. But, if you've read through the FMTC code and understand it, and you need to, you may import the internal APIs usually intended for modules.
Import 'fmtc_module_api.dart' from the same package
Install Isar
Last updated