Commit 202ce36
authored
fix: compile errors on Dart 3.13 from stricter flow analysis (#1146)
## What
Dart 3.13 (shipping with Flutter 3.47, currently in beta) no longer
keeps null promotion of captured variables across `await`. The video
`negotiate()` closure in `LocalParticipant` dereferences the captured
nullable `publishOptions` after an `await`, which now fails to compile:
```
lib/src/participant/local.dart:384: Error: Property 'videoCodec' cannot be accessed on 'VideoPublishOptions?' because it is potentially null.
Info: Variable 'publishOptions' could not be promoted due to an 'await' or 'yield'.
```
This breaks every app that depends on `livekit_client` once users update
to Flutter 3.47, including the agent starter example.
## Fix
Pass the publish options into the `negotiate()` closure as a
non-nullable parameter instead of capturing the nullable variable. At
both call sites `publishOptions` is already promoted non-null in the
enclosing function body, so this needs no null assertions at all. The
audio closure gets the same treatment for consistency, which removes the
pre-existing `publishOptions!` there too.
## Verification
- `flutter analyze` on 3.47 beta goes from 5 errors to 0, and stays
clean on stable 3.44
- All unit tests pass
- The agent starter example builds on 3.47 beta with this patch applied
to the resolved package1 parent d3c53f2 commit 202ce36
2 files changed
Lines changed: 12 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
199 | | - | |
200 | | - | |
| 199 | + | |
| 200 | + | |
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
207 | | - | |
| 207 | + | |
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
| |||
378 | 378 | | |
379 | 379 | | |
380 | 380 | | |
381 | | - | |
382 | | - | |
| 381 | + | |
| 382 | + | |
383 | 383 | | |
384 | | - | |
| 384 | + | |
385 | 385 | | |
386 | 386 | | |
387 | 387 | | |
388 | 388 | | |
389 | | - | |
| 389 | + | |
390 | 390 | | |
391 | 391 | | |
392 | 392 | | |
393 | 393 | | |
394 | | - | |
| 394 | + | |
395 | 395 | | |
396 | 396 | | |
397 | 397 | | |
398 | 398 | | |
399 | 399 | | |
400 | | - | |
| 400 | + | |
401 | 401 | | |
402 | 402 | | |
403 | 403 | | |
404 | 404 | | |
405 | | - | |
| 405 | + | |
406 | 406 | | |
407 | 407 | | |
408 | 408 | | |
| |||
438 | 438 | | |
439 | 439 | | |
440 | 440 | | |
441 | | - | |
| 441 | + | |
442 | 442 | | |
443 | 443 | | |
444 | 444 | | |
| |||
0 commit comments