dart-lang / dart-lang/native

Support standalone target without requiring Flutter SDK

Open
#645 8 comments 6 reactions 0 assignees View on GitHub
package:jni package:jnigen type-enhancement
Dominant language
Dart
Stars
275
Forks
144
Avg merge
2d 10h
Merged PRs (30d)
47

Description

### Status Quo:

Flutter SDK is needed even if we are using `dart` command only - due to the way `package:jni` is packaged.

In theory it is possible to comment out flutter-specific parts and use the same module from standalone and flutter targets. But due to problems with `pub`, we are not able to do it. [pub#3563](https://github.com/dart-lang/pub/issues/3563).

There are 2 parts where we need the flutter features.

* The initialization plugin: `JniPlugin.Java`, android only.
* FFI asset bundling: `ffiPlugin: true` directive, all flutter targets.

### Proposed Design:

There should be 2 packages, `package:jni` and `package:flutter_jni_interface`

The latter doesn't need to be touched by user code, apart from being included in pubspec. Latter being a flutter-specific plugin, it handles initializing android JNI behind the scenes, or packaging the DLL.

### Open questions:

* This doesn't probably solve the FFI plugin packaging problem. - Because as I am aware, `ffiPlugin` expects native code at `src/`.
* Can `flutter_jni_interface` be nested in `package:jni`? This will change latter's native source path to `flutter_jni_interface/src`. But only our setup scripts need to be changed to accommodate this.

### Disadvantages:

* Flutter users will have to add 2 packages instead of 1.

cc: @dcharkes

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.