Skip to content

☂️ Build hooks & Code assets #129757

@dcharkes

Description

@dcharkes

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

Use cases that should be supported

  • flutter run
    • debug
      • hot reload (1)
      • hot restart (1)
    • release/profile
  • flutter build debug/release/profile
  • flutter test / dart test
  • add-2-app (e.g. flutter build macos-framework for 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.dart protocol 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:

  1. This does not bundle new native libraries, but the already bundled native libraries should be accessible.

References:

cc @stuartmorgan @vashworth

Ongoing work related to native assets, build.dart and link.dart hooks:

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterdependency: dartDart team may need to help usr: fixedIssue is closed as already fixed in a newer versionteam-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.tool-still-validIssues that have been deemed still valid as part of the Flutter Tools issue cleanup initiative.triaged-toolTriaged by Flutter Tool team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions