flutter/packages/flutter_tools/templates
Daco Harkes 1f16d9121c
[native_assets] Add support for link hooks (#148474)
This PR adds support invoking `link.dart` hooks.

Link hooks can add new assets. Link hooks can transform assets sent to link hook from build hooks.

This PR does not yet add support for getting tree-shake information in the link hooks. This is pending on defining the `resources.json` format (https://github.com/dart-lang/sdk/issues/55494).

Issue:

* https://github.com/flutter/flutter/issues/146263

## Implementation considerations

The build hooks could be run before Dart compilation and the link hooks after Dart compilation. (This is how it's done in Dart standalone.) However, due to the way the `Target`s are set up, this would require two targets and serializing and deserializing the `BuildResult` in between these. This would lead to more code but no benefits. Currently there is nothing that mandates running build hooks before Dart compilation.

## Testing

* The unit tests verify that the native_assets_builder `link` and `linkDryRun` would be invoked with help of the existing fake.
* The native assets integration test now also invokes an FFI call of a package that adds the asset during the link hook instead of the build hook.
  * In order to keep coverage of the `flutter create --template=package_ffi`, `flutter create` is still run and the extra dependency is added and an extra ffi call is added. (Open to alternative suggestions.)
2024-05-22 16:02:00 +00:00
..
app bump cupertino_icons to 1.08 (#146806) 2024-05-10 21:55:52 +00:00
app_integration_test/integration_test Add an integration test to plugin template example (#117062) 2022-12-15 19:49:14 +00:00
app_shared Add kotlinOptions jvmTarget to templates (#147326) 2024-05-07 17:32:10 +00:00
app_test_widget/test [flutter_tools] Use proper project name in templates (#96373) 2022-02-02 06:50:14 -08:00
cocoapods Set template and migrate apps to iOS 12 minimum (#140823) 2024-01-03 00:47:40 +00:00
module bump cupertino_icons to 1.08 (#146806) 2024-05-10 21:55:52 +00:00
package Bump flutter_lints to 4.0 (#148020) 2024-05-09 18:07:51 +00:00
package_ffi [native_assets] Add support for link hooks (#148474) 2024-05-22 16:02:00 +00:00
plugin Add PrivacyInfo.xcprivacy to plugin template (#148485) 2024-05-16 19:58:11 +00:00
plugin_cocoapods Add PrivacyInfo.xcprivacy to plugin template (#148485) 2024-05-16 19:58:11 +00:00
plugin_ffi plugin_ffi template comment fix (#148378) 2024-05-16 06:19:13 +00:00
plugin_shared Bump flutter_lints to 4.0 (#148020) 2024-05-09 18:07:51 +00:00
plugin_swift_package_manager Add PrivacyInfo.xcprivacy to plugin template (#148485) 2024-05-16 19:58:11 +00:00
skeleton Bump flutter_lints to 4.0 (#148020) 2024-05-09 18:07:51 +00:00
xcode/ios/custom_application_bundle Migrate Xcode projects last version checks to Xcode 15.1 (#140256) 2024-01-03 23:05:46 +00:00
README.md FFI plugins (#96225) 2022-01-26 23:44:45 +01:00
template_manifest.json Add PrivacyInfo.xcprivacy to plugin template (#148485) 2024-05-16 19:58:11 +00:00

This directory contains templates for flutter create.

The *_shared subdirectories provide files for multiple templates.

  • app_shared for app and skeleton.
  • plugin_shared for (method channel) plugin and plugin_ffi.

For example, there are two app templates: app (the counter app) and skeleton (the more advanced list view/detail view app).

  ┌────────────┐
  │ app_shared │
  └──┬──────┬──┘
     │      │
     │      │
     ▼      ▼
┌─────┐    ┌──────────┐
│ app │    │ skeleton │
└─────┘    └──────────┘

Thanks to app_shared, the templates for app and skeleton can contain only the files that are specific to them alone, and the rest is automatically kept in sync.