prefer_ relative_ imports
Details about the 'prefer_relative_imports' diagnostic produced by the Dart analyzer.
Use relative imports for files in the 'lib' directory.
Description
#
The analyzer produces this diagnostic when an import in a library inside
the lib directory uses a package: URI to refer to another library in
the same package.
Example
#
The following code produces this diagnostic because it uses a package:
URI when a relative URI could have been used:
import 'package:my_package/bar.dart';
Common fixes
#Use a relative URI to import the library:
import 'bar.dart';
Unless stated otherwise, the documentation on this site reflects Dart 3.10.3. Report an issue.