目录

conditional_uri_does_not_exist

Missing conditional import.

此规则自 Dart 2.16 版本起可用。

详情

#

DON'T reference files that do not exist in conditional imports.

Code may fail at runtime if the condition evaluates such that the missing file needs to be imported.

BAD:

dart
import 'file_that_does_exist.dart'
  if (condition) 'file_that_does_not_exist.dart';

GOOD:

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