# Dart: The property 'length' can't be unconditionally accessed because the receiver can be 'null'

**Code:** `The property/method can't be unconditionally accessed because the receiver can be null` · **Category:** Flutter / Dart · **Seen on:** Flutter

With null safety you used `.` on a nullable value; Dart requires a null check first.

## Meaning

Use `?.` (safe access), `!` (only if you are certain), a null check `if (x != null)`, or `??` for a default. Prefer making the data non-nullable at the source. The analyzer message names the property and the nullable expression.

## Common causes

- Accessing members of a `T?` value
- Nullable API return (Map lookup, Future results)
- Optional widget parameters used directly
- JSON fields typed nullable
- Migrated code

## Quick fix

1. Use `x?.length ?? 0`
2. Add `if (x == null) return;` before use
3. Change the model to non-nullable where data is guaranteed

## Detailed fix by platform

### Dart

1. `final len = list?.length ?? 0;`

## How to diagnose

1. **Value** — Truly nullable?
2. **Fallback** — Default OK?
3. **Source** — Make non-null?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/flutter/receiver-can-be-null)
