Build & Test codecov License: Apache 2.0

H3 Flutter

Cross‑platform Flutter plugin for Uber's H3 library. Internally it delegates to h3_ffi on the VM and to h3_web on the web.

final h3Factory = const H3Factory();
final h3 = h3Factory.load();
// Get hexagons in specified triangle.
final hexagons = h3.polyfill(
  resolution: 5,
  coordinates: [
    GeoCoord(20.4522, 54.7104),
    GeoCoord(37.6173, 55.7558),
    GeoCoord(39.7015, 47.2357),
  ],
);

There are also a few methods ported from the JS library Geojson2H3. To access them, instantiate the Geojson2H3 class using const Geojson2H3(h3). It uses package:geojson2h3 internally.

Setup

Mobile, Desktop

Add h3_flutter package to pubspec.yaml, import it, and load, no further actions required.

import 'package:h3_flutter/h3_flutter.dart';

final h3 = const H3Factory().load();
final geojson2h3 = Geojson2H3(h3);

Web

Web version is built on top of h3-js v4.2.1, you have to include it.
Add next line to your index.html:

<script defer src="https://unpkg.com/h3-js@4.2.1"></script>

Note: Make sure to place this