Dart-code: 'extension-methods'

Created on 9 Feb 2020  Â·  6Comments  Â·  Source: Dart-Code/Dart-Code

This requires the 'extension-methods' experiment to be enabled.
Try enabling this experiment by adding it to the command line when compiling and running.

awaiting info

Most helpful comment

Extension methods require Dart 2.6, so you need to update the SDK constraint in your pubspec.yaml to use them.

I'm not sure why you get this message - I got it too, but after changing my pubspec constraint and then changing it back, I get a better message:

Screenshot 2020-02-10 at 12 55 01

And there's a quick-fix for it:

Screenshot 2020-02-10 at 12 55 24

I've noted this at https://github.com/dart-lang/sdk/issues/37913#issuecomment-576787713, but in the meantime you can just manually update your pubspec.yaml to include this:

environment:
  sdk: ">=2.6.0 <3.0.0"

Let me know if you still have issues after changing that!

All 6 comments

Extension methods require Dart 2.6, so you need to update the SDK constraint in your pubspec.yaml to use them.

I'm not sure why you get this message - I got it too, but after changing my pubspec constraint and then changing it back, I get a better message:

Screenshot 2020-02-10 at 12 55 01

And there's a quick-fix for it:

Screenshot 2020-02-10 at 12 55 24

I've noted this at https://github.com/dart-lang/sdk/issues/37913#issuecomment-576787713, but in the meantime you can just manually update your pubspec.yaml to include this:

environment:
  sdk: ">=2.6.0 <3.0.0"

Let me know if you still have issues after changing that!

I'm having the same issue in some projects, in pubspec.yaml I see the constraints:

environment:
  sdk: ">=2.6.0 <3.0.0"

Flutter doctor:

[✓] Flutter (Channel beta, v1.14.6, on Mac OS X 10.15.3 19D76, locale en-US)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
[✓] Chrome - develop for the web
[!] Android Studio (version 3.5)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] VS Code (version 1.42.1)
[✓] Connected device (4 available)

Dart version: 2.7.0

@diegoveloper do you still see this after restarting VS Code? What's the exact message you see when hovering over the error in the editor?

Yes, it's still happening after restarting VS-Code, closing the project, etc. (I didn't try restarting my laptop yet).

Screen Shot 2020-02-24 at 10 55 34 AM

The app works fine, after I press the run app, VSCode show me this message.

Screen Shot 2020-02-24 at 10 57 36 AM

But the app still works.

@diegoveloper that doesn't look like the same issue.. This issue is about extension methods not working, but your screenshot shows error importing specific packages.

If you've added those packages to your pubspec.yaml and pub get/flutter packages get ran and completed without error but you still see these, please open a separate issue with details.

@ximendougen I'll close this since I haven't heard back, but if the solution described at https://github.com/Dart-Code/Dart-Code/issues/2253#issuecomment-584109179 doesn't solve the issue for you, please let me know!

Extension methods require Dart 2.6, so you need to update the SDK constraint in your pubspec.yaml to use them.

I'm not sure why you get this message - I got it too, but after changing my pubspec constraint and then changing it back, I get a better message:

Screenshot 2020-02-10 at 12 55 01

And there's a quick-fix for it:

Screenshot 2020-02-10 at 12 55 24

I've noted this at dart-lang/sdk#37913 (comment), but in the meantime you can just manually update your pubspec.yaml to include this:

environment:
  sdk: ">=2.6.0 <3.0.0"

Let me know if you still have issues after changing that!

This works for me 💯
I just update the dart version and restart the vs-code.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ifredom picture ifredom  Â·  3Comments

jascodes picture jascodes  Â·  4Comments

mayorbyrne picture mayorbyrne  Â·  5Comments

shamrin picture shamrin  Â·  5Comments

rgb1380 picture rgb1380  Â·  3Comments