FMTC Docs
Project Links💝 Support Me
v8
v8
  • flutter_map_tile_caching
  • Is FMTC Right For Me?
  • Get Started
    • Quickstart
    • Installation
    • Additional Setup
    • Example Application
  • Usage
    • Initialisation
    • Using Roots & Stores
      • Management
      • Statistics
      • Metadata
      • Recovery
      • Migrator (v6 -> v7)
    • flutter_map Integration
    • Global Settings
    • Full API Reference
  • Bulk Downloading
    • Introduction
    • 1️⃣Create A Region
    • 2️⃣Prepare For Downloading
    • 3️⃣Start In Foreground
      • Buffering
      • 4️⃣Listen For Progress
    • 3️⃣Start In Background
      • Limitations
    • Cancel Download
  • Import & Export
    • Introduction
    • Importing
    • Exporting
  • Migration
    • v7 -> v8 Migration
    • v6 -> v7 Migration
  • Known Issues
  • Credits
  • flutter_map Docs
Powered by GitBook

© Luka Stillingfleet (JaffaKetchup)

On this page
  • Tile Provider Settings
  • Cache Behavior
  • Obscuring Query Parameters
  • Check If A Tile Is Cached

Was this helpful?

Export as PDF
  1. Usage

flutter_map Integration

PreviousRecoveryNextGlobal Settings

Last updated 2 years ago

Was this helpful?

Stores also have the method getTileProvider(). This is the point of integration with flutter_map, providing browse caching through a custom image provider, and can be used as so:

import 'package:flutter_map/flutter_map.dart';

TileLayer(
    // urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
    // userAgentPackageName: 'com.example.app',
    tileProvider: FMTC.instance('storeName').getTileProvider(),
    // Other parameters as normal
),

Tile Provider Settings

This method (and others) optionally take a FMTCTileProviderSettings. These configure the behaviour of the tile provider. Defaults to the settings specified in the Global Settings, or the package default (see table below) if that is not specified.

FMTCTileProviderSettings can take the following arguments:

Parameter
Description
Default
Parameter
Description
Default
Parameter
Description
Default
Parameter
Description
Default

Cache Behavior

This enumerable contains 3 values, which are used to dictate which logic should be used to store and retrieve tiles from the store.

Value
Explanation

cacheFirst

Get tiles from the local cache if possible.

Only uses the Internet if it doesn't exist, or to update it if it has expired.

onlineFirst

Get tiles from the Internet if possible.

Updates every cached tile every time it is fetched (ignores expiry).

cacheOnly

Only get tiles from the local cache, and throw an error if not found.

Recommended for dedicated offline modes.

Obscuring Query Parameters

If you've got a value (such as a token or a key) in the URL's query parameters (the key-value pairs list found after the '?') that you need to keep secret or that changes frequently, make use of obscuredQueryParams.

Pass it the list of query keys who's values need to be removed/omitted/obscured in storage. For example, 'api_key' would remove the 'api_key', and any other characters until the next key-value pair, or the end of the URL, as seen below:

https://tile.myserver.com/{z}/{x}/{y}?api_key=001239876&mode=dark
https://tile.myserver.com/{z}/{x}/{y}?&mode=dark

Since v3, FMTC relies on URL equality to find tiles within a store during browsing. This method is therefore necessary in cases where a token changes periodically.

Check If A Tile Is Cached

A backport of this functionality to v6 is also available - see , and install it through GitHub: .

Determine the logic used during handling storage and retrieval of browse caching

CacheBehavior.cacheFirst

cachedValidDuration: Duration

Length of time a tile remains valid, after which it must be fetched again (ignored in onlineFirst mode)

const Duration(days: 16)

maxStoreLength: int

Maximum number of tiles allowed in a cache store (deletes oldest tile)

0: disabled

obscuredQueryParams: List<String>

[]: empty

this branch on GitHub

behavior:

See

Obscuring Query Parameters
CacheBehavior
checkTileCached method - FMTCTileProvider class - flutter_map_tile_caching library - Dart API
From github.com
Logo