Skip to content

Support publishing Flutter plugin + Dart standalone hybrid packages #3563

@dcharkes

Description

@dcharkes

I was under the impression that we could publish Flutter plugins that also run in Dart standalone (ignoring the Flutter plugin code) by a pubspec with:

name: mylib_source
description: A new Flutter FFI plugin project.
version: 0.0.1
homepage:

environment:
  sdk: ">=2.17.0 <3.0.0"
  # no flutter:

dependencies:

dev_dependencies:

flutter:
  plugin:
    platforms:
      android:
        package: com.example.mylib_source
        ffiPlugin: true
      ios:
        ffiPlugin: true
      macos:
        ffiPlugin: true
      linux:
        ffiPlugin: true
      windows:
        ffiPlugin: true

This works locally with both the Flutter and Dart standalone SDK. (For example dart pub get && dart test and flutter pub get && flutter test, where dart is not from the Flutter SDK.)

However, pub does not support publishing this:

$ dart pub publish --dry-run
// ...
Package validation found the following error:
* pubspec.yaml allows Flutter SDK version 1.9.x, which does not support the flutter.plugin.platforms key.
  Please consider increasing the Flutter SDK requirement to ^1.10.0 (environment.sdk.flutter)
  
  See https://flutter.dev/docs/development/packages-and-plugins/developing-packages#plugin
Sorry, your package is missing a requirement and can't be published yet.
For more information, see: https://dart.dev/tools/pub/cmd/pub-lish.

Adding the flutter key makes dart pub get fail:

Resolving dependencies... 
Because jni requires the Flutter SDK, version solving failed.

Flutter users should run `flutter pub get` instead of `dart pub get`.

As far as I can see, the only workaround is to publish two packages.

cc @mahesh-hegde @jonasfj

edit: duplicate of #2606

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions