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'
With null safety every non-nullable field needs a value by the end of construction.
Non-nullable instance field must be initializedNon-nullable instance field 'name' must be initializedTry adding an initializer expression, or a generative constructor that initializes it, or mark it 'late'Field 'x' should be initialized because its type 'String' doesn't allow null Meaning
Fix by giving the field a default, making it a required constructor parameter, marking it late (when you will assign before use), or making it nullable. For StatefulWidget fields use final plus constructor parameters.
Common causes
- Field declared without initialiser or constructor parameter
- Constructor parameter not marked
this.name - Optional named parameter for non-nullable field with no default
- Class migrated from pre-null-safety code
- Forgot
requiredkeyword
⚡ Quick fix
- Add
required this.nameto the constructor - Or set a default value
- Or mark
late/ make nullable if appropriate
Detailed fix by platform
Dart
const User({required this.name, this.age = 0});
How to diagnose
- Field — Initialised anywhere?
- Constructor — required or default?
- late — Appropriate?
🔧 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
- Error: Couldn't resolve the package Dart: Error: Couldn't resolve the package 'x' in 'package:x/x.dart'
- LateInitializationError: Field has not been initialized Dart: LateInitializationError: Field 'controller' has not been initialized
Most viewed in Flutter / Dart
- setState() called after dispose() Flutter: setState() called after dispose(): _MyState#1a2b3 (lifecycle state: defunct, not mounted)
- A RenderFlex overflowed Flutter: A RenderFlex overflowed by x pixels on the right/bottom
- Null check operator used on a null value Dart/Flutter: Null check operator used on a null value
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