Bram  Vanbilsen
Bram Vanbilsen

Reputation: 6505

Can't run Dart 2 command line programs

I am trying to write a simple command line program with Dart 2. I have used Dart 2 before with Flutter without any problems, but when trying to run my command line application, I can't get it to work.
I am getting the following error:

NoSuchMethodError: Attempted to use type '_Testtt' as a function. Since types do not define a method 'call', this is not possible. Did you intend to call the _Testtt constructor and forget the 'new' operator?
Receiver: _Testtt

I am confident that nothing is wrong with my class. Also, in VS Code, it recognizes that it is in fact a constructor.
I am using the Dart version that ships with Flutter.

Does any one have an idea?

Dart Version:

Dart VM version: 2.0.0-dev.59.0.flutter-ff815d05a5 (Tue May 29 20:01:09 2018 +0000) on "windows_x64"

pubspec:

environment:
  sdk: '>=2.0.0-dev.55.0 <2.0.0'

dependencies:
  http: "^0.11.3+16"

dev_dependencies:
  test: ^0.12.30

Upvotes: 0

Views: 467

Answers (1)

Richard Heap
Richard Heap

Reputation: 51750

Don't use the modified flutter SDK for normal Dart programs. Download the regular SDK (albeit the dev channel - currently 2.0.0-dev.60.0) and install it somewhere away from your flutter installation. Use this SDK for non-Flutter Dart programs.

There's a command line argument that you need to turn on to get the regular Dart SDK to support the new 2.0 features like optional new. When running from the command line specify --preview-dart-2.

Upvotes: 1

Related Questions