Skip to content

Commit 2afadc2

Browse files
Add flutter/package code generation instructions (#158326)
Adds general instructions for updating generated code in flutter/packages, covering the common cases of Pigeon and Mockito generation. Fixes flutter/flutter#158321
1 parent 0059575 commit 2afadc2

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

docs/ecosystem/contributing/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,24 @@ On some platforms, there are multiple native languages that can be used to write
200200

201201
For all platforms, use of Dart for platform-specific features is both allowed and encouraged. While there are no specific rules about this in most plugins, in general we are moving toward having more logic written in Dart rather than a host language, as having more code in the project's primary language eases maintenance.
202202

203+
## Generated code
204+
205+
### Pigeon
206+
207+
Most plugins in flutter/packages use [`pigeon`](https://pub.dev/packages/pigeon) for communication between Dart and host-language code. Unless a package lists specific instructions in its CONTRIBUTING.md file, after changing a Pigeon interface definition file in the `pigeons/` directory run:
208+
```sh
209+
$ dart run pigeon --input pigeons/[changed file]
210+
```
211+
212+
If the package's tests have mocks, they likely include mocks of Pigeon-generated classes; see below for instructions to update the mocks to reflect the changes in the Pigeon-generated code.
213+
214+
### Mockito
215+
216+
Many packages use [`mockito`](https://pub.dev/packages/mockito) for unit tests. To regenerate mocks run:
217+
```sh
218+
$ dart run build_runner build --delete-conflicting-outputs
219+
```
220+
203221
## Changing federated plugins
204222

205223
Most of the plugins in flutter/packages are [federated](https://flutter.dev/docs/development/packages-and-plugins/developing-packages#federated-plugins). Because a logical plugin consists of multiple packages, and our CI tests using published package dependencies—in order to ensure that every PR can be published without breaking the ecosystem—changes that span multiple packages will need to be done in multiple PRs. This is common when adding new features.

0 commit comments

Comments
 (0)