The imported library defines a top-level function named 'loadLibrary' that is hidden by deferring this libraryDRT-W1389
The analyzer produces this diagnostic when a library that declares a
function named loadLibrary
is imported using a deferred import. A
deferred import introduces an implicit function named loadLibrary
. This
function is used to load the contents of the deferred library, and the
implicit function hides the explicit declaration in the deferred library.
For more information, check out Lazily loading a library.
Example
Given a file a.dart
that defines a function named loadLibrary
:
void loadLibrary(Library library) {}
class Library {}
The following code produces this diagnostic because the implicit
declaration of a.loadLibrary
is hiding the explicit declaration of
loadLibrary
in a.dart
:
import 'a.dart' deferred as a;
void f() {
a.Library();
}
Common fixes
If the imported library isn't required to be deferred, then remove the
keyword deferred
:
import 'a.dart' as a;
void f() {
a.Library();
}
If the imported library is required to be deferred and you need to reference the imported function, then rename the function in the imported library:
void populateLibrary(Library library) {}
class Library {}
If the imported library is required to be deferred and you don't need to
reference the imported function, then add a hide
clause:
import 'a.dart' deferred as a hide loadLibrary;
void f() {
a.Library();
}