Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 16 additions & 30 deletions sites/docs/src/content/tools/pubspec.md
Original file line number Diff line number Diff line change
Expand Up @@ -621,33 +621,25 @@ To learn more about plugins, see

### shaders field {: #shaders }

GLSL Shaders with the `.frag` extension must be declared in
the shaders section of your project's `pubspec.yaml` file.
GLSL shaders with the `.frag` extension must be declared in
the `shaders` section of your project's `pubspec.yaml` file.
The Flutter command-line tool compiles the shader to its
appropriate backend format and generates its necessary
runtime metadata. The compiled shader is then included in
the application just like an asset.

The `shaders` field has the following structure:
The `shaders` field accepts a list of individual file paths;
directory paths aren't supported.
The field has the following structure:

```yaml title="pubspec.yaml"
flutter:
shaders:
- { path_to_file | path_to_directory }
- [path_to_file]
[...]
```

```yaml
# path_to_file structure
- assets/shaders/file
```

```yaml
# path_to_directory structure
- assets/shaders/
```

Add specific shaders:
For example, to add specific shaders to your project:

```yaml title="pubspec.yaml"
flutter:
Expand All @@ -656,24 +648,18 @@ flutter:
- assets/shaders/shader_b.frag
```

Add a directory of shaders:
Don't list shader files under the `assets` field,
either directly or through a directory that contains them.
The Flutter tool reports an error if a shader is declared
in both places.

```yaml title="pubspec.yaml"
flutter:
shaders:
- assets/shaders/
```

Alternatively, you can add your shader directory to the
`assets` field:
Like other assets, shaders also support `flavors`, `platforms`,
and `transformers`.
Comment thread
jesskuras marked this conversation as resolved.

```yaml title="pubspec.yaml"
flutter:
assets:
- assets/shaders/my_shader.frag
```
To learn more about using shaders in Flutter, check out
[Writing and using fragment shaders][].

Like other assets, shaders also support `flavors` and `transformers`.
[Writing and using fragment shaders]: /ui/design/graphics/fragment-shaders

### uses-material-design field {: #uses-material-design }

Expand Down
Loading