prefix_ shadowed_ by_ local_ declaration
Details about the 'prefix_shadowed_by_local_declaration' diagnostic produced by the Dart analyzer.
The prefix '{0}' can't be used here because it's shadowed by a local declaration.
Description
#The analyzer produces this diagnostic when an import prefix is used in a context where it isn't visible because it was shadowed by a local declaration.
Example
#
The following code produces this diagnostic because the prefix a is
being used to access the class Future, but isn't visible because it's
shadowed by the parameter a:
import 'dart:async' as a;
a.Future? f(int a) {
a.Future? x;
return x;
}
Common fixes
#Rename either the prefix:
import 'dart:async' as p;
p.Future? f(int a) {
p.Future? x;
return x;
}
Or rename the local variable:
import 'dart:async' as a;
a.Future? f(int p) {
a.Future? x;
return x;
}
Unless stated otherwise, the documentation on this site reflects Dart 3.10.3. Report an issue.