Skip to content

Commit

Permalink
Add note about widgets. (#244)
Browse files Browse the repository at this point in the history
  • Loading branch information
polina-c authored Aug 28, 2024
1 parent ade624f commit d92073c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions doc/leak_tracking/TROUBLESHOOT.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ Follow the rules to avoid/fix notGCed and notDisposed leaks:
4. **Weak referencing**. Non-owners should either link the object with WeakReference, or make sure to
release the references before the owner disposed the object.

A test specific rule:
**Flutter specific rules:**
1. If a widget creates disposables (like controller), it should be stateful, to be able to dispose the disposables.

**Test specific rules:**
1. If your test creates a disposable object, it should dispose it in `tearDown`, so that test failure does not result in a leak:

```dart
final FocusNode focusNode = FocusNode();
addTearDown(focusNode.dispose());
```
```dart
final FocusNode focusNode = FocusNode();
addTearDown(focusNode.dispose());
```

## Known simple cases

Expand Down

0 comments on commit d92073c

Please sign in to comment.