I'm having problems with VS Code not able to find packages after updating to dart 2.17. This worked fine while using dart 2.16.
With the following dart file:
import 'package:test/test.dart';
...
And the following pubspec.yaml
dev_dependencies:
test: ^1.17.4
VSCode is showing that there's a problem:
Target of URI doesn't exist: 'package:test/test.dart'.
Try creating the file referenced by the URI, or Try using a URI for a file that does exist.
The project can be run from CLI fine, just that VS Code IDE is showing issues to resolve.
This is using:
VSCode Version: 1.67.2
Dart extension in VSCode: v3.40.0
macOS 12.4
Dart SDK version: 2.17.1 (stable) (Tue May 17 17:58:21 2022 +0000) on "macos_arm64"
Note: This is a pure dart project, no flutter libraries are installed/used.
Related
I had Dart SDK with version 2.16 installed and worked fine on my machine.
I tried to install the Dart with version 3 which is currently in development (3.0.0-0.0.dev), so in order to try it, I replaced the path of the Dart sdk in the environment variables with the path of the new dart with version 3, Then I created a new project on VScode, and this showed up:
Here I am writing code with the Records feature ( Which exists only in that Dart 3 dev version), and this error shows up:
This requires the 'records' language feature to be enabled.
Try updating your pubspec.yaml to set the minimum SDK constraint to 3.0.0 or higher, and running 'pub get'.
But on my pubspec.yaml:
environment:
sdk: '>=3.0.0-0.0.dev <3.0.0'
but that error is thrown, and I have no idea what cause it and how I can fix it and run the code successfully.
Thank you.
I got Dart version 2.9.0. And my flutter is running with that version now.
However, I got this message:
Set literals weren't supported until version 2.2, but this code is required to be able to run on earlier versions
But I don't want it to be required to run on Dart versions earlier than 2.2.
How do I force it to run only on versions after 2.2 ?
You can edit the dart sdk constraints in your pubspec.yaml file to only use dart versions 2.2 and later.
environment:
sdk: '>=2.2.0 <3.0.0'
See this site for more information about the pubspec.yaml file.
I have this very simple code:
void main() async
{
print("Hello");
}
when I try to step into the function print I get the following message:
Could not load source 'dart:core/print.dart': <source not available>.
My Visual Studio Code version is:
1.32.3
a3db5be9b5c6ba46bb7555ec5d60178ecc2eaae4
x64
I added the following to my Visual Studio Code settings.json:
"dart.debugSdkLibraries": true,
"dart.debugExternalLibraries": true,
My Dart version:
Dart VM version: 2.2.0 (Tue Feb 26 15:04:32 2019 +0100) on "windows_x64"
This happened because the Dart VM for a while stopped serving up source code for built-in libraries. This has changed in SDK v2.2.1 so once that reaches stable releases, you won't see this anymore (or if you switch to a dev build, you'll see this sooner).
If you still have problems from v2.2.1, please open an issue and I'll take a look. Thanks!
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
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.
I upgraded Dart Editor today and now the Editor will not activate.
Instead I receive the following error in the "Tools Output" window:
"pub list-package-dirs failed: exit code 1"
None of the below actions has resolved this issue:
- Deleting and reinstalling Dart Editor and Dartium
- Running pub cache repair from command line,
- Manually deleting package cache directory and running pub get again.
I appreciate any advise on this.
My Dart Editor is version 1.8.3.release (STABLE)
Dart SDK version 1.8.3
Pubspec.yaml contents:
name: mpower
description: Sample app built with the polymer.dart package
environment:
sdk: '>=1.2.0 <2.0.0'
dependencies:
polymer: '>=0.15.1 <0.16.0'
dev_dependencies:
unittest: '>=0.10.0 <0.11.0'
transformers:
- polymer:
entry_points:
- web/index.html
Result of pub-list-package-dirs from Command Line:
{"packages":{"mpower":"C:\Users\jfontana\dart\mpower\lib","browser":"C:\Users\jfontana\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\browser-0.10.0+2\lib","matcher":"C:\Users\jfontana\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\matcher-0.10.1+1\lib","utf":"C:\Users\jfontana\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\utf-0.9.0+1\lib","source_span":"C:\Users\jfontana\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\source_span-1.0.0\lib","web_components":"C:\Users\jfontana\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\web_components-0.9.0\lib","string_scanner":"C:\Users\jfontana\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\string_scanner-0.1.2\lib","source_maps":"C:\Users\jfontana\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\source_maps-0.10.0\lib","mock":"C:\Users\jfontana\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\mock-0.10.0+1\lib","watcher":"C:\Users\jfontana\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\watcher-0.9.3\lib","args":"C:\Users\jfontana\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\args-0.12.1\lib","collection":"C:\Users\jfontana\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\collection-1.1.0\lib","barback":"C:\Users\jfontana\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\barback-0.15.0+1\lib","code_transformers":"C:\Users\jfontana\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\code_transformers-0.2.3+1\lib","csslib":"C:\Users\jfontana\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\csslib-0.11.0+2\lib","pool":"C:\Users\jfontana\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\pool-1.0.1\lib","polymer":"C:\Users\jfontana\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\polymer-0.15.1+3\lib","template_binding":"C:\Users\jfontana\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\template_binding-0.13.1\lib","smoke":"C:\Users\jfontana\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\smoke-0.2.1+1\lib","stack_trace":"C:\Users\jfontana\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\stack_trace-0.9.3+2\lib","html5lib":"C:\Users\jfontana\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\html5lib-0.12.0\lib","path":"C:\Users\jfontana\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\path-1.3.0\lib","observe":"C:\Users\jfontana\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\observe-0.12.1+1\lib","logging":"C:\Users\jfontana\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\logging-0.9.2\lib","yaml":"C:\Users\jfontana\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\yaml-2.0.1+1\lib","unittest":"C:\Users\jfontana\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\unittest-0.10.1+2\lib","analyzer":"C:\Users\jfontana\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\analyzer-0.22.4\lib","polymer_expressions":"C:\Users\jfontana\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\polymer_expressions-0.13.0\lib"},"input_files":["C:\Users\jfontana\dart\mpower\pubspec.lock","C:\Users\jfontana\dart\mpower\pubspec.yaml"]}
My OS is Windows 8.1
Java Version "1.8.0_25"
Java SE Runtime Environment (build 1.80_25-b18)
Java Hotspot 64-bit Server VM (build 25.25-b02, mixed mode)
Dart Editor version 1.8.3.release (STABLE)
Dart SDK version 1.8.3
I installed Dart by downloading darteditor-windows-x64.zip
and extracting contents into C:\Dart folder