The property/method can't be unconditionally accessed because the receiver can be null Flutter / Dart Origin: On your device OSI layer 7 · Application Last updated 4 Nov 2026

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

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

Exact message you may see The property can't be unconditionally accessed because the receiver can be 'null'The method can't be unconditionally invoked because the receiver can be 'null'The operator '[]' can't be unconditionally invoked because the receiver can be 'null'Try making the call conditional (using '?.') or adding a null check (as '!')
Seen on: Flutter

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?

🔧 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 elementLateInitializationError: Field has not been initialized — Dart: LateInitializationError: Field 'controller' has not been initialized (Flutter / Dart)LateInitializationErr…Non-nullable instance field must be initialized — 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' (Flutter / Dart)Non-nullable instance…Null check operator used on a null value — Dart/Flutter: Null check operator used on a null value (Flutter / Dart)Null check operator u…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…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 …version solving failed (pub get) — Dart pub: Because app depends on intl ^0.19.0 and flutter_localizations from sdk depends on intl 0.18.1, version solving failed (Flutter / Dart)version solving faile…The prope…

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.