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:
dart
class A {}
The following code produces this diagnostic because the import contains a
path that includes lib
:
dart
import '../lib/a.dart';
Common fixes
#Rewrite the import to not include lib
in the URI:
dart
import 'a.dart';
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。