tree: 2da059df2a47ee44e521645346096bdcf856f309 [path history] [tgz]
  1. android/
  2. bin/
  3. example/
  4. java/
  5. lib/
  6. linux/
  7. macos/
  8. src/
  9. test/
  10. third_party/
  11. tool/
  12. windows/
  13. .gitignore
  14. .metadata
  15. analysis_options.yaml
  16. CHANGELOG.md
  17. dart_test.yaml
  18. ffigen.yaml
  19. ffigen_exts.yaml
  20. LICENSE
  21. pubspec.yaml
  22. README.md
pkgs/jni/README.md

Build Status Coverage Status pub package package publisher

jni

This is a support library to access JNI from Dart / Flutter code. This provides the common infrastructure to bindings generated by jnigen, as well as some utility methods.

This library contains:

  • Functions to access the JNIEnv and JavaVM variables from JNI, and wrapper functions to those provided by JNI. JNIEnv is exposed via GlobalJniEnv type which provides a thin abstraction over JNIEnv, so that it can be used from multiple threads.
  • Functions to spawn a JVM on desktop platforms (Jni.spawn).
  • Some Android-specific helpers (get application context and current activity references).
  • JObject class, which provides base class for classes generated by jnigen.
  • Commonly used Java classes like JList, JMap, JInteger, ...

Apart from being the base library for code generated by jnigen this can also be used for one-off uses of the JNI and debugging. To generate type-safe bindings from Java libraries, use jnigen.

Documentation

The test/ directory contains files with comments explaining the basics of this module, and the example/ directory contains a flutter example which also touches some Android-specifics.

Using this library assumes some familiarity with JNI - it's threading model and object references, among other things.