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
:
dart
import 'dart:async' as a;
a.Future? f(int a) {
a.Future? x;
return x;
}
Common fixes
#Rename either the prefix:
dart
import 'dart:async' as p;
p.Future? f(int a) {
p.Future? x;
return x;
}
Or rename the local variable:
dart
import 'dart:async' as a;
a.Future? f(int p) {
a.Future? x;
return x;
}
Was this page's content helpful?
Thank you for your feedback!
Provide details Thank you for your feedback! Please let us know what we can do to improve.
Provide details Unless stated otherwise, the documentation on this site reflects Dart 3.8.1. Page last updated on 2025-05-08. View source or report an issue.