# Dart: LateInitializationError: Field 'controller' has not been initialized

**Code:** `LateInitializationError: Field has not been initialized` · **Category:** Flutter / Dart · **Seen on:** Flutter

A `late` variable was read before it was assigned.

## 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

1. Assign in `initState` before use
2. Use a lazy initialiser: `late final c = TextEditingController();`
3. Make the field nullable and handle null

## Detailed fix by platform

### Dart

1. `late final controller = TextEditingController();` with `dispose()` calling `controller.dispose()`

## How to diagnose

1. **Assign** — Where is it set?
2. **Order** — Before first read?
3. **Hot reload** — Restart app?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/flutter/late-initialization-error)
