@@ -226,26 +226,57 @@ good time to [report them as issues][dart-test-tracker].
226
226
227
227
### Editing API types
228
228
229
- We support Zulip Server 4.0 and later. For API features added in
230
- newer versions, use ` TODO(server-N) ` comments (like those you see
231
- in the existing code.)
229
+ #### Server compatibility
232
230
233
- When editing the files in ` lib/api/model/ ` , use the following command
234
- to keep the generated files up to date:
235
- ```
236
- $ dart run build_runner watch --delete-conflicting-outputs
237
- ```
231
+ We support Zulip Server 4.0 and later.
232
+
233
+ For API features added in newer versions, use ` TODO(server-N) `
234
+ comments (like those you see in the existing code.)
235
+
236
+
237
+ #### Require all parameters in API constructors
238
238
239
239
In our API types, constructors should generally avoid default values for
240
240
their parameters, even ` null ` . This means writing e.g. ` required this.foo `
241
241
rather than just ` this.foo ` , even when ` foo ` is nullable.
242
- This is because it's common in the Zulip API for a null or missing value
242
+
243
+ We do this because it's common in the Zulip API for a null or missing value
243
244
to be quite salient in meaning, and not a boring value appropriate for a
244
245
default, so that it's best to ensure callers make an explicit choice.
246
+
245
247
If passing explicit values in tests is cumbersome, a factory function
246
248
in ` test/example_data.dart ` is an appropriate way to share defaults.
247
249
248
250
251
+ #### Generated files
252
+
253
+ When editing any of the type definitions in our API, you'll need to
254
+ keep up to date the corresponding generated code
255
+ (which handles converting JSON to and from our types).
256
+
257
+ To do this, run the following command:
258
+ ```
259
+ $ dart run build_runner watch --delete-conflicting-outputs
260
+ ```
261
+
262
+ That ` build_runner watch ` command watches for changes
263
+ in relevant files and updates the generated code as needed.
264
+
265
+ When the ` build_runner watch ` command has finished its work and
266
+ is waiting for more changes, you may find it convenient to
267
+ suspend it by pressing Ctrl+Z before you edit the code further.
268
+ While suspended, the command will not run.
269
+ After editing the source files further, you can update the
270
+ generated files again by running the command ` fg ` in the
271
+ terminal where ` build_runner watch ` had been running.
272
+ The ` fg ` command causes the suspended command to resume running
273
+ (in the foreground, hence the name ` fg ` ), just like it was doing
274
+ before Ctrl+Z.
275
+
276
+ If a PR is missing required updates to these generated files,
277
+ CI will fail at the ` build_runner ` suite.
278
+
279
+
249
280
### Upgrading Flutter
250
281
251
282
We regularly increment our lower bounds on Flutter and Dart versions,
0 commit comments