prefix_shadowed_by_local_declaration
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.7.3. Page last updated on 2025-05-08. View source or report an issue.