no_leading_underscores_for_library_prefixes
避免库前缀使用前导下划线。
详情
#不要为库前缀使用前导下划线。库前缀没有“私有”的概念。当其中一个名称以划线开头时,会向读者发出令人困惑的信号。为了避免这种情况,请不要在这些名称中使用前导下划线。
错误示例
dart
import 'dart:core' as _core;
正确示例
dart
import 'dart:core' as core;
启用
#要启用 no_leading_underscores_for_library_prefixes
规则,请在你的 analysis_options.yaml
文件中的 linter > rules 下添加 no_leading_underscores_for_library_prefixes
analysis_options.yaml
yaml
linter:
rules:
- no_leading_underscores_for_library_prefixes
如果你改为使用 YAML 映射语法来配置 linter 规则,请在 linter > rules 下添加 no_leading_underscores_for_library_prefixes: true
analysis_options.yaml
yaml
linter:
rules:
no_leading_underscores_for_library_prefixes: true
除非另有说明,否则本网站上的文档反映的是 Dart 3.7.1 版本。页面上次更新于 2025-03-07。 查看源代码 或 报告问题。