-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support publishing Flutter plugin + Dart standalone hybrid packages #3563
Comments
For me the result depends only on which SDK
It's confirmed also by the CI behaviour. The check in which I used setup-dart action failed. I updated it to use flutter-action and it passed. |
Context: We did this years ago because older versions of the Flutter SDK didn't support I suppose we could tweak the behavior such that the Flutter SDK constraint is expressed as a minimum Dart SDK constraint. @sigurdm, any thoughts? |
A few thoughts: We need to have some story to tell here, but I'm not entirely sure how this kind of module should be published. I feel it is somewhat surprising for a package that works as a dart-only package has a Could it be that there should be two packages, one having the dart ffi part, and another one importing the other, and wrapping it as a flutter plugin? Even if that is technically feasible there would be downsides to that:
|
@sigurdm another downside is that all your downstream packages have to do the same.
The contract is that the plugin is used to bundle the same native code for the same Dart API. But that contract is not enforced. |
Adds workaround for dart-lang/pub#3563 which requires using Flutter's `dart` command if a package lists a Flutter SDK constraint even if the package does not depend on Flutter.
Adds workaround for dart-lang/pub#3563 which requires using Flutter's `dart` command if a package lists a Flutter SDK constraint even if the package does not depend on Flutter.
Adds workaround for dart-lang/pub#3563 which requires using Flutter's `dart` command if a package lists a Flutter SDK constraint even if the package does not depend on Flutter.
Adds workaround for dart-lang/pub#3563 which requires using Flutter's `dart` command if a package lists a Flutter SDK constraint even if the package does not depend on Flutter.
* chore(aft): Make base commands sync There isn't any value with these being async since it's okay to block in this context. And sync makes everything easier to work with. commit-id:6743d9d4 * feat(aft): Changelog/version commands commit-id:0c17379d * fix(aws_common): Logger initialization Fixes an issue in logger initialization where the initial plugin is not registered to the root plugin. commit-id:063fbfe0 * fix(aft): Versioning algorithm and performance commit-id:c45852ad * chore(aft): Clean up commit-id:de10a06e * chore(aft): Update README commit-id:8261f867 * chore(aft): Update tests Expand e2e tests to incude changelog/pubspec changes commit-id:e9757240 * chore(aft): Update dependencies commit-id:4509edf2 * chore(aft): Bump dependencies commit-id:14f44d17 * chore(aft): Enforce changelog update includes commits Changelog updates should only be made with a non-empty list of commits. commit-id:4eccafce * chore(aft): Add `promptYesNo` helper commit-id:8544885f * chore(aft): Refine `isExample` Refine the definition of `isExample` to be more precise and not require workarounds. commit-id:51cc0ac0 * chore(aft): Change `aft version` to `aft version-bump` commit-id:0526b477 * chore(aft): Remove from mono_repo The package libgit2dart, while it can be used in Dart-only packages tricks pub into thinking it has a dependency on Flutter. mono_repo cannot handle this discrepancy. commit-id:ec27a8d2 * fix(aft): Publish constraints Fixes constraints around publishing checks and which packages to consider for publishing. commit-id:937ee042 * chore(aft): Publish command checks Improves publish command checks by removing `pubspec_overrides` and not splitting the pre-publish and publish commands for a package. * chore(aft): Add components and define version bump types * chore(aft): Clean up `deps` command Fix logging and merge `pub.dev` logic with `publish` * chore(aft): Add placeholders for version bump commit * chore(aft): Update logging settings * test(aft): Update e2e tests * More updates * chore(aft): More cleanup * chore(aft): Add propagation option * chore(aft): Remove `changelog` command * chore(aft): Clean up * chore(aft): Update wording in `aft.yaml` * chore(aft): Link packages before version bump * chore(aft): Follow Dart SemVer strategy Use build tag (`+`) for patch releases. * chore(aft): Fix analysis errors * fix(aft): Submodule `libgit2dart` Adds workaround for dart-lang/pub#3563 which requires using Flutter's `dart` command if a package lists a Flutter SDK constraint even if the package does not depend on Flutter. * fix(authenticator): ARB syntax Remove unncessary commas * chore(aft): Remove setup step * chore(aft): Copy libgit2 from Instead of trying to install it (since the latest version is not available in apt) * chore(aft): Reset after patch * chore(aft): Copy lib to /usr * fix(aft): `dev_dependency` conflicts When `dev_dependencies` contains versions of the published packages different than those on pub.dev (for example when using path deps or `any`), this causes issues during pre-publish verification. By simply keeping these constraints up-to-date as well, we lose nothing (since they are overridden in local development via linking), but gain stronger confidence in the pre-publish step. * chore(aft): Change workflow path for libgit2 * chore(aft): Fix tests in CI * chore(aft): Bump dependency Co-authored-by: Dillon Nys <dillon.andre.nys@gmail.com>
The requirement that Flutter be installed and used simply by virtue of the This negatively impacts the ability to run CI, compile dart for the server, use in Docker, etc. where the Flutter SDK is much less portable and unnecessary because the package may not even use Flutter. IMO, the presence of an environment specifier should be modified to mean if running with Flutter pub, then this requirement holds. The requirement for Flutter to be installed and used should only come from an explicit dependency on a Flutter SDK package. |
@dnys1, @dcharkes what would happen if we simply removed I suspect that Though in general it is a bit scary to let people make a top-level Just curious. |
Hey @jonasfj, that's correct. As you mention, attempting to publish the following pubspec is unsupported. name: hybrid_pkg
# ...
environment:
sdk: ^3.0.0
dependencies:
# Dart-only deps
flutter:
plugin:
platforms:
ios:
ffiPlugin: true In this case, pub requires the presence of This is true of the root package or if any transitive dependencies follow this format (which is required for publishing). It essentially colors the entire dependency tree to Flutter. Importantly, this is despite the fact that the Flutter SDK is not actually needed. There can be zero dependencies/dev dependencies on Flutter in the graph and this requirement still holds. The Basically, I don't believe that the presence of either |
Hmm, it's technically possible to publishing without This is obviously not intended :) And I don't know if Flutter will read the Also SDK detection in Pana (which affects pub.dev UI) might be off. Not sure. On topic: I think it's rather risky to change existing semantics for Or maybe we do need a mechanism to indicate that flutter is optional. Or simply allow omitting Or maybe we need to wait for the native assets work @dcharkes is working on. |
Good to know! Though I agree there should be a happy path for it.
It does 🙂
Yep 😅 dart-lang/pana#1351 Changing the semantics of It's true that there are few instances where you need this level of hybridization, but it would be very handy if there was first-class support for these kinds of packages. In the past, the only way was to have two separate packages, a Dart one with FFI, and a Flutter one which was a very thin wrapper (but which maybe used method channels and other SDK code). With native assets, there is no longer a need to use Flutter in the actual Dart code, only for the platform-specific configuration which lives outside |
Adding my vote here. Until native assets are fully supported by Dart and Flutter, the Even once it is, we would still need the following for federated plugins: flutter:
plugin:
implements: flutter_local_notifications While we may see more and more method channels being replaced by FFI, I don't think federation is going anywhere anytime soon. There is little value to a wrapper package, and it only adds bloat to pubspecs, monorepos, build + analyzer CI's, and Pub in terms of eating up more good names for packages. I think Flutter 1.9.0 is old enough at this point that it shouldn't be an issue. At the very least, Pub can check that EDIT @jonasfj If it's decided that this warning should be removed, I would gladly open a PR as this is a blocker on a few of my projects |
(Thinking out loud here) A package may want to work in different environments (dart sdk, flutter sdk - maybe 3rd party sdks in the future). The language has support - e.g. via conditional imports - that allows the package's code paths to behave differently in different environments. We'd want such a package to:
So it would seem natural that a environment:
sdk: ^a.b.c
flutter: ^x.y.z gets attached the following meaning: This package is usable in normal Dart SDK in version A SDK like the Flutter SDK is basically a wrapper around our lower-level tools (e.g. pub, dart2js, dart2wasm, vm, core libraries, ...). It provides it's own command line interface as well as API surface (e.g. => That's probably the key issue here: A (Thinking out loud further) Having a separate version resolution would also allow environment-specific dependencies, so the package when used in flutter may depend on One could encode such environment specific imports in environment:
sdk: ^a.b.c
flutter: ^x.y.z
dependencies:
flutter_icons:
- environment: flutter
- >= ...
standalone_icons:
- environment: sdk
- >= ... (without this, the package couldn't depend on flutter-only packages, but all transitive deps would need to support both environments - which may not make sense for them) (Thinking out loud further) Any tool that is depending on |
(just rambling off Martins thoughts) We should probably drop the name dart: 3.5.1 # <-- language version, nothing more.
sdks: # Supported SDKs
- dart: ^3.7.0 # <-- Dart is supported
- flutter: ^3.28.0 # <-- Flutter is supported I'm not sure we should want SDK-specific dependencies.
I wonder if there are ways to solve that problem. Ways to allow |
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:
This works locally with both the Flutter and Dart standalone SDK. (For example
dart pub get && dart test
andflutter pub get && flutter test
, wheredart
is not from the Flutter SDK.)However,
pub
does not support publishing this:Adding the flutter key makes
dart pub get
fail:As far as I can see, the only workaround is to publish two packages.
cc @mahesh-hegde @jonasfj
edit: duplicate of #2606
The text was updated successfully, but these errors were encountered: