always_use_package_imports
Use 'package:' 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 relative path to import another library inside the lib
directory of the same package.
Example
#Given that a file named a.dart
and the code below are both inside the lib
directory of the same package, the following code produces this diagnostic because a relative URI is used to import a.dart
:
dart
import 'a.dart';
Common fixes
#Use a package import:
dart
import 'package:p/a.dart';
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.