You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improve WatchingStatefulWidget example with better local state pattern
- Replaced SearchableList with NotificationToggle
- Shows true local UI state (_isAnimating) for immediate feedback
- Demonstrates updating manager (toggleNotifications) from local interaction
- Better illustrates when StatefulWidget is actually needed
- Local state for UI, reactive state for business logic from manager
- You need local UI state (search queries, form input, expansion state)
32
+
- You need local UI state (form input state, animation flags, expansion state)
33
33
- You need animation controllers
34
34
- Mix `setState` with reactive updates
35
+
- Local state triggers manager updates (like this switch example)
35
36
36
37
**Note:** Your State class automatically gets all watch functions - no mixin needed!
37
38
39
+
**Pattern:** Local state (`_isAnimating`) provides immediate UI feedback, while reactive state (`notificationsEnabled`) ensures the widget reflects manager changes from anywhere in the app.
40
+
38
41
## Alternative: Using Mixins
39
42
40
43
If you have **existing widgets** you don't want to change, use mixins instead:
0 commit comments