Skip to content

Commit

Permalink
Add note about widgets.
Browse files Browse the repository at this point in the history
  • Loading branch information
polina-c committed Aug 27, 2024
1 parent ade624f commit d65316b
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, it should be stateful, to be able to dispose them.

**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 d65316b

Please sign in to comment.