dart api 划掉变量

dart api crossed out variables

在大多数 Dart 文档页面中,一些变量和函数被划掉了。就像 https://api.dartlang.org/1.14.2/dart-js/dart-js-library.html

这是什么意思?

表示class、函数、属性等是deprecated

在 Dart 中,注释用于将某些内容标记为已弃用。请注意 this class.

上记录的注释

在 Dart 中 metadata 可以添加到 类、字段、库声明、参数...作为注释。

@Deprecated('some reason')
class SomeClass {
  String someField;
  int otherField;

  SomeClass({
      this.someField, 
      @Deprecated('don\'t use this anymore") this.otherField});
}

就是这样的注释,Dart 分析器和 dartdoc 等一些工具使用此信息来生成警告(分析器)或其他一些 API 仍然存在但应该避免的视觉提示,因为它是计划最终删除。