Dart
Install
Section titled “Install”Add the package from pub.dev. It needs Dart 3.11 or later.
dart pub add maplibre_native_ffiWhen it builds, the package downloads the C library for your target.
Choose a backend
Section titled “Choose a backend”The package uses your platform’s default backend. To choose another, map an operating system to a backend in your app’s pubspec:
hooks: user_defines: maplibre_native_ffi: backend: android: vulkanThe operating systems are android, ios, linux, macos, and windows. The
backends are opengl, metal, and vulkan.
Android
Section titled “Android”Initialize the library once per process, before you create a runtime, with the
calling thread’s JNI environment and an Android Context:
initAndroid(NativePointer(jniEnv), NativePointer(context));Get the JNI environment from package:jni, and
the application context from
package:jni_flutter.
Use your own build
Section titled “Use your own build”To link a C library that you built or downloaded, name it in local_build. Name
an install prefix, or a directory with prefixes one level down, such as a CMake
build root. A relative path is relative to the pubspec. A Git dependency on the
package always needs one.
hooks: user_defines: maplibre_native_ffi: local_build: ../maplibre-native-ffi/buildDownload from a mirror
Section titled “Download from a mirror”If your builds can’t reach GitHub, copy the release’s archives to a server of
your own, in a directory named after the release tag, and name the server’s base
URL in release_url. The package still checks each archive against the digest
that it pinned at release.
hooks: user_defines: maplibre_native_ffi: release_url: https://mirror.example.com/maplibre-native-ffi