-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Use hooks in addition to asset transformers #9935
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@@ -0,0 +1,9 @@ | |||
# example | |||
|
|||
A Flutter showcase for how to replce asset transformers with hooks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: s/replce/replace/
@@ -0,0 +1,9 @@ | |||
# example |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Maybe something more descriptive, like Vector Graphics Compiler - Build Hooks Example
To run execute: | ||
```bash | ||
flutter config --enable-dart-data-assets | ||
flutter run -d linux |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there technical reasons for only supporting this on Linux? Ideally we'd at least support the desktop platforms so that the majority of our users can run this.
); | ||
} | ||
|
||
for (final MapEntry<String, Pair> entry in pairs.entries) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: consider using patterns here
for (final MapEntry(key: name, value: Pair(:outputPath)) in pairs.entries) {
output.assets.data.add(
DataAsset(
package: input.packageName,
name: name,
file: Uri.file(outputPath),
),
);
}
Requires
flutter config --enable-dart-data-assets
.This is an example of how replacing asset transformers with build/link hooks could look like. The basic idea is that package
vector_graphics_compiler
exposes a helper method, herecompileSvg
, which is then called in the package's build hook. Options can be set there as well.For now, asset transformers and build hooks can simply co-exist - in the future, when hooks are stable enough, we will want to deprecate asset transformers and move towards this mechanism.