Non-nullable instance field must be initialized Flutter / Dart Origin: On your device OSI layer 7 · Application Last updated 4 Nov 2026

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.

Exact message you may see 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
Seen on: Flutter

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 required keyword

⚡ Quick fix

  1. Add required this.name to the constructor
  2. Or set a default value
  3. Or mark late / make nullable if appropriate

Detailed fix by platform

Dart

  1. const User({required this.name, this.age = 0});

How to diagnose

  1. Field — Initialised anywhere?
  2. Constructor — required or default?
  3. 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:

Where this error sits

Origin: On your device. Errors that are often confused with or caused by this one (click to open):

Bad state: No element — Dart: Bad state: No element — .first, .last or .single on an empty list (Flutter / Dart)Bad state: No elementError: Couldn't resolve the package — Dart: Error: Couldn't resolve the package 'x' in 'package:x/x.dart' (Flutter / Dart)Error: Couldn't resol…LateInitializationError: Field has not been initialized — Dart: LateInitializationError: Field 'controller' has not been initialized (Flutter / Dart)LateInitializationErr…The argument type can't be assigned to the parameter type — Dart: The argument type 'String?' can't be assigned to the parameter type 'String' (Flutter / Dart)The argument type can…The named parameter is required, but there's no corresponding argument — Dart: The named parameter 'key' is required, but there's no corresponding argument (Flutter / Dart)The named parameter i…The property/method can't be unconditionally accessed because the receiver can be null — Dart: The property 'length' can't be unconditionally accessed because the receiver can be 'null' (Flutter / Dart)The property/method c…type 'Null' is not a subtype of type 'String' — Dart: type 'Null' is not a subtype of type 'String' in type cast (Flutter / Dart)type 'Null' is not a …Non-nulla…

Explore the map of this error Full error map →

🧠 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.