# FlutterError: ScrollController not attached to any scroll views

- **ID:** `flutter/scrollcontroller-not-attached`
- **Domain:** flutter
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 88%

## Root Cause

ScrollController is used (e.g., .position, .offset, .animateTo) after it has been detached from all Scrollable widgets, typically due to a disposed state or incorrect lifecycle management.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Flutter 3.10 | active | — | — |
| Flutter 3.13 | active | — | — |
| Flutter 3.16 | active | — | — |

## Workarounds

1. **Ensure ScrollController is created in initState and disposed in dispose, and only access its properties after the scroll view has built (e.g., using WidgetsBinding.instance.addPostFrameCallback).** (85% success)
   ```
   Ensure ScrollController is created in initState and disposed in dispose, and only access its properties after the scroll view has built (e.g., using WidgetsBinding.instance.addPostFrameCallback).
   ```
2. **Check hasClients before accessing controller properties to avoid the error condition.** (92% success)
   ```
   Check hasClients before accessing controller properties to avoid the error condition.
   ```

## Dead Ends

- **** — Creates a new controller each rebuild, losing scroll position and causing memory leaks; the error persists if the old controller is still referenced. (75% fail)
- **** — Does not address the root cause; the controller remains detached and further calls will still throw, leading to silent failures and broken UX. (90% fail)
- **** — Global state causes conflicts when multiple scroll views share the same controller; detaching from one page breaks others. (60% fail)
