Skip to main content

undefined_prefixed_name_read

Details about the 'undefined_prefixed_name_read' diagnostic produced by the Dart analyzer.

The name '{0}' is declared in '{1}', but private names are visible only in their own library.

The name '{0}' isn't defined in the libraries imported with the prefix '{1}'.

There's a setter '{0}' in the libraries imported with the prefix '{1}', but no getter.

Description

#

The analyzer produces this diagnostic when a name is read, invoked, or torn off through an import prefix, but none of the libraries imported with that prefix has a getter, function, variable, or type with that name that can be read.

Examples

#

The following code produces this diagnostic because dart:core doesn't define anything named a:

dart
import 'dart:core' as p;
​
void f() {
  p.a;
}

Given a file a.dart that contains:

dart
set x(int _) {}

The following code produces this diagnostic because a.dart has only a setter named x, which can't be read:

dart
import 'a.dart' as p;
​
int f() => p.x;

Common fixes

#

If the library in which the name is declared isn't imported yet, then import it with the prefix.

If the name is wrong, then change it to one of the names that's declared in the imported libraries.

If the library has only a setter, then add a getter with the same name to that library.