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

**Code:** `Non-nullable instance field must be initialized` · **Category:** Flutter / Dart · **Seen on:** Flutter

With null safety every non-nullable field needs a value by the end of construction.

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

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/flutter/non-nullable-field-must-be-initialized)
