late is a promise to Dart that you will assign the field before anyone reads it. Break that promise and you get a LateInitializationError. Here are the three correct ways out.
The Error
LateInitializationError: Field '_controller' has not been initialized.
Fix 1: Initialize in initState
late final AnimationController _controller;
@override
void initState() {
super.initState();
_controller = AnimationController(vsync: this); // assigned before use
}Fix 2: Make It Nullable Instead
If the value genuinely may not exist yet, drop late and use a nullable type with null handling:
User? _user; // null until loaded
// ... later
Text(_user?.name ?? "Loading...");Fix 3: Lazy Initialization
late final config = _buildConfig(); // computed on first readRule of Thumb
Use late only for values that are definitely set in initState. If there is any path where it isn't, make it nullable.
