From 51c7146399af7add2bb747bb0bf10140d553ce97 Mon Sep 17 00:00:00 2001 From: "Shams Zakhour (ignore Sfshaza)" Date: Wed, 21 Jan 2026 09:53:01 -0800 Subject: [PATCH 1/5] Docs: Add platform-specific assets documentation (#12966) --- src/content/tools/pubspec.md | 47 ++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/src/content/tools/pubspec.md b/src/content/tools/pubspec.md index e30ec87f86..8e08c94e91 100644 --- a/src/content/tools/pubspec.md +++ b/src/content/tools/pubspec.md @@ -146,7 +146,7 @@ The `asset` field has this structure: flutter: assets: - [ path_to_file | path_to_directory ] - [ flavor_path_field ] + [ flavor_path_field | platform_path_field ] [...] ``` @@ -167,19 +167,31 @@ flutter: - flavor_name ``` +```yaml +# platform_path_field structure +- path: path/to/file + platforms: + - platform_name +``` + Subfields of `assets`: * `path_to_file`: A string that represents the path to a file. -* `path_to_directory`: A string that represents the path to - a directory. -* `flavor_path_field`: A path field and its flavor - subfields. -* `path`: The path to a directory. -* `flavors`: A list of flutter flavors to use with assets - at a specific path. To learn more about - flavors, see [Set up flavors for iOS and macOS] and - [Set up flavors for Android]. +* `path_to_directory`: A string that represents the path to + a directory. +* `flavor_path_field`: A path field and its flavor + subfields. +* `platform_path_field`: A path field and its platform + subfields. +* `path`: The path to a directory. +* `flavors`: A list of flutter flavors to use with assets + at a specific path. To learn more about + flavors, see [Set up flavors for iOS and macOS] and + [Set up flavors for Android]. +* `platforms`: A list of platforms to use with assets at a + specific path. Valid values are `android`, `ios`, `web`, `linux`, + `macos`, and `windows`. You can pass in a path to a file: @@ -214,6 +226,21 @@ flutter: - flavor_c ``` +You can pass in a path to a file for specific platforms: + +```yaml title="pubspec.yaml" +flutter: + assets: + - path: assets/web_worker.js + platforms: + - web + - path: assets/desktop_icon.png + platforms: + - windows + - linux + - macos +``` + [Set up flavors for iOS and macOS]: /deployment/flavors-ios [Set up flavors for Android]: /deployment/flavors [Assets and images]: /ui/assets/assets-and-images From 534c534f404da4d760fe014238b3e13cd2f7e18f Mon Sep 17 00:00:00 2001 From: Shams Zakhour <44418985+sfshaza2@users.noreply.github.com> Date: Wed, 21 Jan 2026 09:56:38 -0800 Subject: [PATCH 2/5] Update src/content/tools/pubspec.md Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- src/content/tools/pubspec.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/content/tools/pubspec.md b/src/content/tools/pubspec.md index 8e08c94e91..6a88428e7f 100644 --- a/src/content/tools/pubspec.md +++ b/src/content/tools/pubspec.md @@ -178,20 +178,20 @@ Subfields of `assets`: * `path_to_file`: A string that represents the path to a file. -* `path_to_directory`: A string that represents the path to - a directory. -* `flavor_path_field`: A path field and its flavor - subfields. -* `platform_path_field`: A path field and its platform - subfields. -* `path`: The path to a directory. -* `flavors`: A list of flutter flavors to use with assets - at a specific path. To learn more about - flavors, see [Set up flavors for iOS and macOS] and - [Set up flavors for Android]. -* `platforms`: A list of platforms to use with assets at a - specific path. Valid values are `android`, `ios`, `web`, `linux`, - `macos`, and `windows`. +* `path_to_directory`: A string that represents the path to + a directory. +* `flavor_path_field`: A path field and its flavor + subfields. +* `platform_path_field`: A path field and its platform + subfields. +* `path`: The path to an asset file or directory. +* `flavors`: A list of flutter flavors to use with assets + at a specific path. To learn more about + flavors, see [Set up flavors for iOS and macOS] and + [Set up flavors for Android]. +* `platforms`: A list of platforms to use with assets at a + specific path. Valid values are `android`, `ios`, `web`, `linux`, + `macos`, and `windows`. You can pass in a path to a file: From 3f0f956d52a302daf38f7c0d3254b9c26cff9a56 Mon Sep 17 00:00:00 2001 From: Shams Zakhour <44418985+sfshaza2@users.noreply.github.com> Date: Wed, 4 Feb 2026 10:27:04 -0800 Subject: [PATCH 3/5] Update src/content/tools/pubspec.md Co-authored-by: Parker Lougheed --- src/content/tools/pubspec.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/tools/pubspec.md b/src/content/tools/pubspec.md index 6a88428e7f..be38679de9 100644 --- a/src/content/tools/pubspec.md +++ b/src/content/tools/pubspec.md @@ -171,7 +171,7 @@ flutter: # platform_path_field structure - path: path/to/file platforms: - - platform_name + - platform_name ``` Subfields of `assets`: From c0f48b5690860ded5cfdd85697536c7a6a8eaa8b Mon Sep 17 00:00:00 2001 From: Shams Zakhour <44418985+sfshaza2@users.noreply.github.com> Date: Wed, 4 Feb 2026 10:27:17 -0800 Subject: [PATCH 4/5] Update src/content/tools/pubspec.md Co-authored-by: Parker Lougheed --- src/content/tools/pubspec.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/tools/pubspec.md b/src/content/tools/pubspec.md index be38679de9..000279cb76 100644 --- a/src/content/tools/pubspec.md +++ b/src/content/tools/pubspec.md @@ -233,7 +233,7 @@ flutter: assets: - path: assets/web_worker.js platforms: - - web + - web - path: assets/desktop_icon.png platforms: - windows From 03a7a97beeceea0fbaedfd1253dbfe9347f0fede Mon Sep 17 00:00:00 2001 From: Shams Zakhour <44418985+sfshaza2@users.noreply.github.com> Date: Wed, 4 Feb 2026 10:27:31 -0800 Subject: [PATCH 5/5] Update src/content/tools/pubspec.md Co-authored-by: Parker Lougheed --- src/content/tools/pubspec.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/content/tools/pubspec.md b/src/content/tools/pubspec.md index 000279cb76..30fe2ab3bc 100644 --- a/src/content/tools/pubspec.md +++ b/src/content/tools/pubspec.md @@ -236,9 +236,9 @@ flutter: - web - path: assets/desktop_icon.png platforms: - - windows - - linux - - macos + - windows + - linux + - macos ``` [Set up flavors for iOS and macOS]: /deployment/flavors-ios