Problem Statement
What are common mistakes developers make when using Provider? How do you avoid them?
Explanation
Using context.watch in initState or other lifecycle methods causes errors because context.watch must be called in build methods. Use context.read in lifecycle methods to access provider without listening, or move the logic to didChangeDependencies if you need to respond to provider changes. Similarly, never use context.watch in event handlers - use context.read instead to avoid unnecessary dependency registration.
Forgetting to provide a provider before consuming it causes runtime errors. Always ensure ProviderNotFoundException errors are resolved by checking provider hierarchy - the consumer must be a descendant of the provider. Common mistake is placing the provider too deep in the tree, not covering all consumers. Use MultiProvider at app root for app-wide providers to ensure availability everywhere.
Using Provider.of with listen: true in widgets that shouldn't rebuild when state changes wastes performance. Always use listen: false (or context.read) in event handlers, constructors, or anywhere that doesn't need rebuilds. Conversely, forgetting to listen (using listen: false when you should listen) means widgets won't update when state changes, leading to stale UI.
Calling notifyListeners() synchronously during build causes errors because it triggers rebuilds during builds. Move state modifications to event handlers or post-frame callbacks. Not disposing ChangeNotifier causes memory leaks, though Provider handles disposal automatically. Creating providers inside build methods instead of above causes providers to be recreated on every build, losing state and causing performance issues - providers should be created once in widget tree, not recreated in build.

