-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
Build hooks and code assets support in Flutter is available in stable since 3.38 and Dart 3.10: flutter create --template=package_ffi [package name].
Ongoing work for tree-shaking and other features related to hooks can be tracked in: Native Assets
A high level tracking issue for supporting native assets.
Native assets enables packages to specify a top-level build.dart that is invoked by launchers (dartdev and flutter_tools) to build/download native libraries and communicate back which native libraries need to be bundled and under which "asset id".
From a Flutter context, the native assets feature will enable testing native code with flutter test, which the FFI plugins do not support. From a Dart+Flutter context packages will be compatible with both Dart and Flutter, removing the need for publishing two versions on pub (one for Dart and one for Flutter).
More details can be found in:
Current ongoing work can be tracked in: Native Assets
Dart standalone support has landed behind an experimental flag (dart --enable-experiment=native-assets).
This issue tracks implementing native assets in flutter tools
- MacOS
- iOS
- Linux
- Android
- Flutter app
- Add2app
- Windows
Use cases that should be supported
flutter run- debug
- hot reload (1)
- hot restart (1)
- release/profile
- debug
flutter builddebug/release/profileflutter test/dart test- add-2-app (e.g.
flutter build macos-frameworkfor MacOS) flutter run -dflutter-tester
Test coverage will be through end-to-end integration tests that exercise the dynamic libraries provided by packages.
Landing plan is to land this behind an experimental flag on the main branch only. This has the following benefits:
- Support for the various OSes can be in separate CLs, simplifying code review.
- We defer settling on the actual
build.dartprotocol until before we get it out of experimental. Users should not publish packages on pub.dev while this feature is in experimental phase. - Making this available in experimental enables users to give this feature a spin without having to build their own version of Dart or Flutter. Getting their feedback is important to us to get this feature right.
Please feel free to note additional use cases that we have missed or ask questions on this issue.
Foot notes:
- This does not bundle new native libraries, but the already bundled native libraries should be accessible.
References:
- Example package with native assets: https://github.com/dart-lang/native/tree/main/pkgs/hooks/example/build
- Dart tracking issue: ☂️ [vm/ffi] Build hooks & Code assets dart-lang/sdk#50565
Ongoing work related to native assets, build.dart and link.dart hooks:
- Native assets should be able to specify a privacy manifest #140966
-
hook/link.dartsupport in flutter_tools #146263 -
hook/build.dartData assets support #146264 -
hook/link.dartconsume data assets from pubspec.yaml #146265 - [native_assets] Use kernel concatenation instead of passing in asset-mapping into kernel compilation #146270
- [native assets] Inconsistent logging on error. #147544
- Native assets: visionOS support #142933
- [native_assets] There's two errors thrown by Xcode 15.3 when submitting Flutter apps built with
native_assetsto the App Store. #148044 - [macOS] Code-signing native assets #148051
- [native_assets]
flutter cleanshould delete all native assets #151890 - [native_assets] Stop doing dry run in
flutter run#154425 - [native_assets]
package_ffitemplate language options #151646 - [native assets] Support
flutter test integration_test#168961