i created a simple stand alone application using the dart sdk provided in the flutter sdk
and if i run this code
main() {
MyClass myObj=MyClass();
}
class MyClass{
}
NoSuchMethodError: Attempted to use type 'MyClass' as a function. Since types do not define a method 'call', this is not possible. Did you intend to call the MyClass constructor and forget the 'new' operator?
flutter --version
so what i am doing wrong here ? i want to get the optional new and const
flutter version doesn't matter if you have a Dart standalone app. dart --version prints the relevant information.
You need to run with --preview-dart-2 until Dart 2 semantics becomes default. In Flutter this is already the default.
dart --preview-dart-2 bin/main.dart
In IntelliJ you can pass this option in "Run/Debug Configurations" > "VM options".
This will become the default soon in standalone Dart as well.

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With