flutter / flutter/flutter

[asset_transformers] Provide the current target platform in the asset transformer

Open
#159,323 4 comments 1 reaction 1 assignee Claimed by @navaronbracke View on GitHub
a: assets a: build c: new feature c: proposal P2 team-tool tool tool-still-valid triaged-tool
Dominant language
Dart
Stars
179k
Forks
31.1k
PR merge metrics
PR metrics pending

Description

### Use case

Developers wanting to transform assets, based on the current target platform (i.e. `flutter build web` -> web; `flutter build apk` -> android), currently cannot infer the target platform during the asset transformation.

### Proposal

I propose that the target platform of the `flutter build` invocation is provided as either an argument, or in `Platform.environment`. I initially tried checking what is inside `Platform.environment` and the `FLUTTER_BUILD_MODE` seems to be there already?

Then I think the easiest thing to do is to also add something like `FLUTTER_BUILD_TARGET_PLATFORM` to `Platform.environment` or the args that are passed to the asset transformer, whichever makes more sense / is cleaner from a tool perspective.

Context: I was initially exploring if I could work around the absence of https://github.com/flutter/flutter/issues/141371 using an asset transformer

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.