conditional_uri_does_not_exist
缺少条件导入。
详情
#不要在条件导入中引用不存在的文件。
如果条件评估结果需要导入缺失的文件,代码可能在运行时失败。
不良示例
dart
import 'file_that_does_exist.dart'
if (condition) 'file_that_does_not_exist.dart';
良好示例
dart
import 'file_that_does_exist.dart'
if (condition) 'file_that_also_does_exist.dart';
启用
#要启用 conditional_uri_does_not_exist
规则,请在你的 analysis_options.yaml
文件中的 linter > rules 下添加 conditional_uri_does_not_exist
analysis_options.yaml
yaml
linter:
rules:
- conditional_uri_does_not_exist
如果你改为使用 YAML 映射语法配置 linter 规则,请在 linter > rules 下添加 conditional_uri_does_not_exist: true
analysis_options.yaml
yaml
linter:
rules:
conditional_uri_does_not_exist: true
除非另有说明,否则本网站上的文档反映的是 Dart 3.7.1 版本。页面上次更新于 2025-03-07。 查看源代码 或 报告问题。