Dart: LateInitializationError: Field 'controller' has not been initialized
A late variable was read before it was assigned.
LateInitializationError: Field has not been initializedLateInitializationError: Local 'x' has not been initializedLateInitializationError: Field '_controller' has not been initializedLateInitializationError: Field 'x' has already been initialized Meaning
late promises you will initialise a field before first use. Reading it earlier throws. Initialise it in initState, make it late final x = … with an initialiser (lazy), or make it nullable. Also happens when initState assigns after build already used it, or on hot reload of a field added later.
Common causes
- late field read in build before initState assigns it
- Assignment inside a branch that did not run
- Async initialisation not finished
- Hot reload added a late field to an existing State
- Reading in a constructor initialiser
⚡ Quick fix
- Assign in
initStatebefore use - Use a lazy initialiser:
late final c = TextEditingController(); - Make the field nullable and handle null
Detailed fix by platform
Dart
late final controller = TextEditingController();withdispose()callingcontroller.dispose()
How to diagnose
- Assign — Where is it set?
- Order — Before first read?
- Hot reload — Restart app?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- Bad state: No element Dart: Bad state: No element — .first, .last or .single on an empty list
- Non-nullable instance field must be initialized Dart: Non-nullable instance field 'name' must be initialized. Try adding an initializer expression, or a generative constructor that initializes it, or mark it 'late'
- Null check operator used on a null value Dart/Flutter: Null check operator used on a null value
Most viewed in Flutter / Dart
- A RenderFlex overflowed Flutter: A RenderFlex overflowed by x pixels on the right/bottom
- SocketException: Failed host lookup Flutter: Unhandled Exception: SocketException: Failed host lookup: 'api.example.com' (OS Error: No address associated with hostname, errno = 7)
- Unsupported class file major version (Gradle / Java) Android Gradle: Execution failed — Unsupported class file major version 65 / Android Gradle plugin requires Java 17 to run
Other ways to find it
Where this error sits
Origin: On your device. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 4 Nov 2026