1

使用 VSCode 时,它​​会警告我TypeMatcher<T>已贬值。

IDE 警告

来自相关的Dart API 文档。. .

TypeMatcher([@Deprecated('Provide a type argument to TypeMatcher and omit the name. ' 'This argument will be removed in the next release.') String name])

我应该用什么代替TypeMatcher<T>

的输出Flutter --version

  Flutter 1.21.0-9.2.pre • channel beta • https://github.com/flutter/flutter.git
  Framework • revision 81a45ec2e5 (3 weeks ago) • 2020-08-27 14:14:33 -0700
  Engine • revision 20a9531835
  Tools • Dart 2.10.0 (build 2.10.0-7.3.beta)
4

1 回答 1

2

在阅读匹配器库的文档时,我注意到

isInstanceOf 不推荐使用 isA 代替。[...]

再次检查flutter_test的文档,我发现那里也存在相同的方法。

简答

老路

expect(someObject, TypeMathcher<T>);

新的方法

expect(someObject, isA<T>);
于 2020-09-15T02:18:42.677 回答