The package allows to use H3 library directly in your Flutter application

Build & Test codecov License: Apache 2.0

H3 FLUTTER

H3 version: 3.7.2

The package allows to use H3 library directly in your Flutter application

The package uses C version under the hood. Works via FFI, bindings are automatically generated using ffigen

Few functions were adopted to allow work with them in a "safe" mode:

// 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),
  ],
);

But most of them are not. You still can use them, but it's more complicated, because you'll need to work directly with FFI (calloc, malloc and everything). If you want to try, you can use h3c singletone.

The package also contains few methods from JS library Geojson2H3.

Setup

Just add the package to pubspec.yaml and that's all.


Tests

To make tests work you need to execute prepare_tests.sh script. The script builds h3 library from C code.
The script is designed for macOS and therefore it probably work only under this system.

How to update the package to match latest H3 version

~Good luck~

You need cmake tool, if you're on macos use next command:

brew install cmake # install cmake

Clone h3 repository and prepare everything:

git clone https://github.com/uber/h3 tmp/h3_sources 
# git checkout ... - checkout on commit you need, currently stable versions are in stable-3.x branch
mkdir tmp/h3_sources/build
cd tmp/h3_sources/build

Generate h3api.h file and copy it to c/h3lib folder:

cmake ..
rm -rf ../../../c/h3lib // recreate the folder to remove old h3 files
mkdir ../../../c/h3lib

cp src/h3lib/include/h3api.h ../../../c/h3lib

Copy other source files (*.h and *.c) to the folder.

cd ..
cp src/h3lib/include/* ../../c/h3lib
cp src/h3lib/lib/* ../../c/h3lib

Copy c/h3lib folder to ios and macos folders with sync_h3lib.sh script:

sh sync_h3lib.sh

You need to add .h and .c files to the project using XCode if you want to launch example (for iOS and macOS).
You can face some build errors, in my case i just followed xcode instructions to solve them.

Code generation tool called ffigen is used to create C-to-Dart bindings.
To run it, you need to install LLVM:

brew install llvm

If you're using M1 Mac, as of now, you need to install x86 version of LLVM, to do it you need to install x86 version of Homebrew.

All H3 public functions should be specified in ffigen.yaml file Run flutter pub run ffigen --config ffigen.yaml to generate bindings

Comments
  • h3_flutter 0.6.0 build fail on Android

    h3_flutter 0.6.0 build fail on Android

    I'm using this plug-in very well.

    Recently, I update h3_flutter version from 0.4.2 to 0.6.0 in my project because want to support not only mobile but also web. And android build fails with the folloing error. (iOS, Web is OK)

    [ ] Execution failed for task ':h3_flutter:configureCMakeDebug[arm64-v8a]'. [ ] > [CXX1400] Gradle project cmake.path is /Users/user/flutter/.pub-cache/hosted/pub.dartlang.org/h3_flutter-0.6.0/c/h3lib/CMakeLists.txt but that file doesn't exist

    It occurs when you create a new project and add only h3_flutter. If you need more information, please let me know.

  • h3_flutter 0.6.1 build fail on Android

    h3_flutter 0.6.1 build fail on Android

    Thank your for responding quickly :)

    image But same issue occurs in 0.6.1. The reproduction occurs when you create a new project, add h3_flutter ^0.6.1 to pubspect.yml, and build it as an Android target. I'd appreciate it if you could check it again. :)

    Originally posted by @orgeslayer in https://github.com/festelo/h3_dart/issues/11#issuecomment-1181810911

  • Dart Implementation i.e. no Flutter dependency

    Dart Implementation i.e. no Flutter dependency

    Thanks for your work on this package.

    I am interested in using this library in Dart server-side, without the Flutter dependency. Is this a consideration on your part? If not I will issue a pull request.

  • Build error

    Build error

    GeneratedPluginRegistrant.m:18:4: error: unknown receiver 'H3FlutterPlugin'; did you mean 'SwiftH3FlutterPlugin'? [H3FlutterPlugin registerWithRegistrar:[registry registrarForPlugin:@"H3FlutterPlugin"]]; ^~~~~~~~~~~~~~~ SwiftH3FlutterPlugin In module 'h3_flutter' imported from /Users/niltondiniz/Projects/Nilton/h3_test/ios/Runner/GeneratedPluginRegistrant.m:12: /Users/niltondiniz/Projects/Nilton/h3_test/build/ios/Debug-iphonesimulator/h3_flutter/h3_flutter.framework/Headers/h3_flutter-Swift.h:444:12: note: 'SwiftH3FlutterPlugin' declared here @interface SwiftH3FlutterPlugin : NSObject ^ 1 error generated. note: Using new build system note: Planning note: Build preparation complete note: Building targets in parallel

  • help building h3 on windows 10

    help building h3 on windows 10

    Hello, i have tried to build h3lib as a shared library on windows using the guide here https://github.com/uber/h3/blob/master/dev-docs/build_windows.md using the sources located in h3_ffi-0.6.0\c\h3lib but the build process produces a *.lib file (strangely) which is not usable with h3_dart. Running h3_dart-master\h3_dart\example\ffi\src\main.dart produces

    Unhandled exception:
    Invalid argument(s): Failed to lookup symbol 'h3IsValid': error code 127
    #0      DynamicLibrary.lookup (dart:ffi-patch/ffi_dynamic_library_patch.dart:34:70)
    #1      H3C._h3IsValidPtr (package:h3_ffi/src/generated/generated_bindings.dart:615:66)
    #2      H3C._h3IsValidPtr (package:h3_ffi/src/generated/generated_bindings.dart)
    #3      H3C._h3IsValid (package:h3_ffi/src/generated/generated_bindings.dart:616:27)
    #4      H3C._h3IsValid (package:h3_ffi/src/generated/generated_bindings.dart)
    #5      H3C.h3IsValid (package:h3_ffi/src/generated/generated_bindings.dart:609:12)
    #6      H3Ffi.h3IsValid (package:h3_ffi/src/h3_ffi.dart:23:17)
    #7      main (file:///D:/temp/h3_dart-master/h3_dart/example/ffi/src/main.dart:7:22)
    #8      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:297:19)
    #9      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)
    

    can anyone provide a few hints to build the lib on windows ?

  • h3_flutter on Linux, `failed to lookup symbol` error

    h3_flutter on Linux, `failed to lookup symbol` error

    I am trying to use h3_flutter as suggested in https://github.com/festelo/h3_dart#mobile-desktop

    import 'package:h3_flutter/h3_flutter.dart';
    [...]
    
        final h3 = const H3Factory().load();
    
        var pol = <LatLng>[];
        try {
        pol = h3
            .h3ToGeoBoundary(BigInt.parse("0x" + h3ix))
            .map((e) => LatLng(e.lat, e.lon))
            .toList();
        } catch (e) {
          print(e);
          continue;
        }
    

    I get exception:

    flutter: Invalid argument(s): Failed to lookup symbol 'h3ToGeoBoundary': /home/tomk/myapp/build/linux/x64/debug/bundle/lib/libflutter_linux_gtk.so: undefined symbol: h3ToGeoBoundary
    

    Do I need to supply the so library myself? Where should I put the compiled C library, and how should I pass the path to h3_flutter initialization?

    Thanks for answering!

  • h3_flutter - Support for Linux and Windows

    h3_flutter - Support for Linux and Windows

    hey, thanks for a great package, it seems it's the best h3 implementation in Dart.

    How likely is it to have Linux and Web support? It seems you are using the Uber's C lib. Does that mean that Linux support could be done analogically to MacOS, but Web support is not likely? Because converting/compiling the C to Javascript is not possible?

    For an H3 Dart package to work on all the supported platforms, does it mean that it should be totally written in Dart? Like this is all written in Go? https://github.com/isbang/h3go

    Thanks for answering and Great Work!

A package to use Material side sheet into your Flutter project. Learn more about side sheet at Material.io
A package to use Material side sheet into your Flutter project. Learn more about side sheet at Material.io

Side Sheet A package to use Material side sheet into your Flutter project. Learn more about side sheet at Material.io Platform Support Android iOS Mac

Aug 25, 2022
Handcrafted Flutter application well organized and easy to understand and easy to use.

Handcrafted Flutter application well organized and easy to understand and easy to use.

Feb 1, 2022
Flutter app where you can find your information about your Favorite Super Cars ⚡❤

Super Cars App (Flutter) ⚡ Now you can freely discover and browse your Favourite Super Cars ❤ . Speed! ?? Getting Started This project is a starting p

Apr 13, 2022
Galaxy simulation that runs directly into your terminal !

ASCII-galaxy-simulation (Work in progress) Current result : Two galaxies colliding Goal : Galaxy with black hole (Should make the galaxies more stable

Nov 26, 2022
Flutter-Clock-and-Reminder-App - a highly functional clock and reminder app developed on flutter framework.

clock_app A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if thi

Aug 4, 2022
This plugin allows Flutter desktop apps to defines system tray.

tray_manager This plugin allows Flutter desktop apps to defines system tray. tray_manager Platform Support Quick Start Installation ⚠️ Linux requireme

Dec 22, 2022
This plugin allows Flutter desktop apps to Auto launch on startup / login.

This plugin allows Flutter desktop apps to Auto launch on startup / login.

Dec 18, 2022
This plugin allows Flutter desktop apps to defines system/inapp wide hotkey (i.e. shortcut).

hotkey_manager This plugin allows Flutter desktop apps to defines system/inapp wide hotkey (i.e. shortcut). hotkey_manager Platform Support Quick Star

Jan 6, 2023
Program that allows you to get the source code of a website's home page without doing it manually. Use it at your own risk.

Website-Homepage-Grabber Install one of the folders x64 or x32 if the program doesn't work(probably because you don't have visual studio installed) If

Feb 19, 2022
Working example for local_flutter_notification package in Flutter. Includes setting notification at custom time, daily, weekly.

local_notification_example Working example for local_flutter_notification package in Flutter. Includes setting notification at custom time, daily, wee

Oct 3, 2021
A Flutter package that two widgets switch with clipper.
A Flutter package that two widgets switch with clipper.

flutter_switch_clipper A Flutter package that two widgets switch with clipper. 1.使用 SwitchCipper( initSelect: true, child: const Icon(Icons.fa

Nov 18, 2022
Onboard package for Flutter project.

Easy Onboard It is an easy to use package for flutter projects. Usage First, include the package in your project.Then add the code below to the widget

Feb 8, 2022
Flutter Paint application

paintr A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if this i

Nov 8, 2021
Flutter TODO application for cs50 final project with hive database.
Flutter TODO application for cs50 final project with hive database.

TODO application TODO apllication for CS50 final project with flutter framework. Video Demo: https://youtu.be/91qB2TgGXTc Description: This is my Fina

Jul 25, 2022
PyAerotech: An Opensource Python Library or interfacing directly with the Aerotech A3200 Controlle

PyAerotech: An Opensource Python Library or interfacing directly with the Aerotech A3200 Controller pyAerotech is an additional Opensource Python libr

Aug 22, 2022
Simple Software Application Package Installer for CachyOS which helps setting up & installing applications

cachyos-packageinstaller Simple Software Application Package Installer. Requirements C++20 feature required (tested with GCC 11.1.0 and Clang 13(clang

Jul 1, 2022
Plays native alert sound and shows native dialogs/alerts in your Flutter app.
Plays native alert sound and shows native dialogs/alerts in your Flutter app.

flutter_platform_alert 2021 © Weizhong Yang a.k.a zonble. A simple plugin to present native alerts, including playing alert sounds and showing alert d

Dec 21, 2022
Assembly HellGate implementation that directly calls Windows System Calls and displays the PPID of the explorer.exe process
Assembly HellGate implementation that directly calls Windows System Calls and displays the PPID of the explorer.exe process

Custom HellsGate Implementation Assembly HellGate implementation that directly calls Windows System Calls and displays the PPID of the explorer.exe pr

Oct 18, 2022
An implementation of a Windows loader that can load dynamic-linked libraries (DLLs) directly from memory

memory-module-loader memory-module-loader is an implementation of a Windows loader that can load dynamic-link libraries (DLLs) directly from memory. T

Nov 21, 2022