尽管使用 Dart 2.0,但不能省略 'new' 关键字
Cannot omit 'new' keyword despite using Dart 2.0
当我 运行 测试我的应用程序时,我得到这个异常:
NoSuchMethodError: Attempted to use type 'SimplePipe' as a function. Since types do not define a method 'call', this is not possible. Did you intend to call the SimplePipe constructor and forget the 'new' operator?
我从这个错误消息中得出结论,我的项目实际上没有使用 Dart 2.0,而是 Dart 1.0。
不过,SDK 在 pubspec.yaml
中设置为 >=2.0.0-dev.53.0 <2.0.0
。
我的一个朋友在他的 PC 上 运行 在相同条件下进行相同测试时收到此错误消息。他已经尝试 运行ning pub get
.
Dart 2.0.0-dev.54.0.flutter-46ab040e58 is incompatible with your dependencies' SDK constraints. Please run "pub get" again
pubspec.yaml
:
name: timecoder_common
description: A Dart Libary containin all the shared logic
version: 0.0.1
environment:
sdk: '>=2.0.0-dev.53.0 <2.0.0'
dependencies:
uuid: "^0.5.3"
json_annotation: "^0.2.3"
http: "^0.11.3"
rxdart: "^0.16.6"
test: "^0.12.34"
dev_dependencies:
build_runner: "^0.8.0"
json_serializable: "^0.5.0"
Dart 2.0 SDK 默认不启用此功能(目前)。
对于 Flutter,您将 need to be on the latest SDK:
In this blog post, we’ll take a deeper look at the specific improvements we’ve made in Beta 3 itself.
对于命令行 VM,如评论中所述,您必须选择加入:
dart --preview-dart-2 bin/main.dart
当我 运行 测试我的应用程序时,我得到这个异常:
NoSuchMethodError: Attempted to use type 'SimplePipe' as a function. Since types do not define a method 'call', this is not possible. Did you intend to call the SimplePipe constructor and forget the 'new' operator?
我从这个错误消息中得出结论,我的项目实际上没有使用 Dart 2.0,而是 Dart 1.0。
不过,SDK 在 pubspec.yaml
中设置为 >=2.0.0-dev.53.0 <2.0.0
。
我的一个朋友在他的 PC 上 运行 在相同条件下进行相同测试时收到此错误消息。他已经尝试 运行ning pub get
.
Dart 2.0.0-dev.54.0.flutter-46ab040e58 is incompatible with your dependencies' SDK constraints. Please run "pub get" again
pubspec.yaml
:
name: timecoder_common
description: A Dart Libary containin all the shared logic
version: 0.0.1
environment:
sdk: '>=2.0.0-dev.53.0 <2.0.0'
dependencies:
uuid: "^0.5.3"
json_annotation: "^0.2.3"
http: "^0.11.3"
rxdart: "^0.16.6"
test: "^0.12.34"
dev_dependencies:
build_runner: "^0.8.0"
json_serializable: "^0.5.0"
Dart 2.0 SDK 默认不启用此功能(目前)。
对于 Flutter,您将 need to be on the latest SDK:
In this blog post, we’ll take a deeper look at the specific improvements we’ve made in Beta 3 itself.
对于命令行 VM,如评论中所述,您必须选择加入:
dart --preview-dart-2 bin/main.dart