flutter_mbtiles_extractor 0.0.6

  • README.md
  • Example
  • Installing
  • Versions
  • 71


Basic plugin to extract the data (png tiles) from an .mbtiles file and automatically create the folder structure (../folder_name/{z}/{x}/{y}.png).



Import the dependency in the dart file you will use it.

   import 'package:flutter_mbtiles_extractor/mbtiles_extractor.dart';

In Android you need to add permissions to read and write in the storage of the device. In your project add the following lines to your AndroidManifest.xml file in your project's Android folder.

       <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
       <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

Remember that on API 23 and later you need to ask to the user to grant access for this permissions.

How to use

In the following example you can see how to realize a extraction of one file.

ExtractResult extractResult = await MBTilesExtractor.extractMBTilesFile(
        new ExtractRequest(
          "${dir.path}/volcan_villarica.mbtiles", //This is the name of the file i was testing.
          desiredPath: "${dir.path}/tiles/", //Example of final folder
          requestPermissions: true, //This is for Android 6.0+
          removeAfterExtract: true, //Deletes the +.mbtiles file after the extraction is completed
          stopOnError: true, //Stops is one tile could not be extracted
          returnReference: true, //Returns the list of tiles once the extraction is completed
          onlyReference: false, //If true the reference of tiles is returned but the extraction is not performed

The extraction will return an instance of ExtractResult that contains a code and data. The code determinate the extraction result and could be checked using the isSuccessful() function in ExtractResult class or could be done manually.

    if (extractResult.code == ExtractResult.RESULT_FILE_CORRUPT) {
      //The file could not be read because it was damaged

If the file was extracted successfully the data will contain the path to the folder where the tiles are stored.

    if (extractResult.isSuccessful()) {
        var folder= extractResult.data;
        //Do something

Progress can be tracked by registering the following stream

    StreamSubscription<dynamic> subscription = 
    MBTilesExtractor.onProgress().listen((dynamic event) {
        var percent = event['progress'] / event['total'];
        print("$event, $percent %");
   ExtractResult extractResult = await ...

Extra info

This plugin uses the extracted folder to generate a Google Maps like map so you could make a project that uses offline maps.


The Android part use a library to read the .mbtiles file. The original project for Java:


And the Android version:


NOTE: I included a compiled .jar of this library since it don't exist in Maven or JitPack (at least i couldn't find it). Consider update it if exists a new version.



  • Added progress callback to the extraction. (Thanks to @kengu)
  • Added documentation to MBTilesExtractor class.


  • Added support for XYZ or TMS tile extraction schema. (Thanks to @kengu)
  • Example updated to display the schema update. (Thanks to @kengu)
  • Updated example dependencies.


  • Quick fix. A crash was produced when extracting the metadata of an incomplete mbtiles file.


  • Revision on imports


  • Added asynchronous working so the extraction doesn't freeze the UI while working.

  • Updated the example


  • First release with basic functionality for extracting the tiles from a .mbtiles file.



Demonstrates how to use the flutter_mbtiles_extractor plugin.

Getting Started

For help getting started with Flutter, view our online documentation.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  flutter_mbtiles_extractor: ^0.0.6

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:flutter_mbtiles_extractor/mbtiles_extractor.dart';
import 'package:flutter_mbtiles_extractor/model/extract_request.dart';
import 'package:flutter_mbtiles_extractor/model/extract_result.dart';
import 'package:flutter_mbtiles_extractor/model/mbtiles_metadata.dart';
import 'package:flutter_mbtiles_extractor/model/tile.dart';
Version Uploaded Documentation Archive
0.0.6 Nov 23, 2018 Go to the documentation of flutter_mbtiles_extractor 0.0.6 Download flutter_mbtiles_extractor 0.0.6 archive
0.0.5 Oct 31, 2018 Go to the documentation of flutter_mbtiles_extractor 0.0.5 Download flutter_mbtiles_extractor 0.0.5 archive
0.0.4 Sep 28, 2018 Go to the documentation of flutter_mbtiles_extractor 0.0.4 Download flutter_mbtiles_extractor 0.0.4 archive
0.0.3 Sep 10, 2018 Go to the documentation of flutter_mbtiles_extractor 0.0.3 Download flutter_mbtiles_extractor 0.0.3 archive
0.0.2 Sep 10, 2018 Go to the documentation of flutter_mbtiles_extractor 0.0.2 Download flutter_mbtiles_extractor 0.0.2 archive
0.0.1 Jul 31, 2018 Go to the documentation of flutter_mbtiles_extractor 0.0.1 Download flutter_mbtiles_extractor 0.0.1 archive
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Dec 5, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.7
  • Flutter: 1.0.0


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While there is nothing inherently wrong with versions of 0.0.*, it usually means that the author is still experimenting with the general direction of the API.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.28.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8