avoid_ relative_ lib_ imports
Can't use a relative path to import a library in 'lib'.
Description
#
The analyzer produces this diagnostic when the URI in an
import
directive has
lib
in the path.
Example
#Assuming that there is a file named a.dart
in the lib
directory:
class A {}
The following code produces this diagnostic because the import contains a
path that includes
lib
:
import '../lib/a.dart';
Common fixes
#Rewrite the import to not include lib
in the URI:
import 'a.dart';
Unless stated otherwise, the documentation on this site reflects Dart 3.9.2. Page last updated on 2025-9-1. View source or report an issue.