'How to change the current Dart SDK version?
I ran the following commands in my foo project:
iDecode@iDecodes-Mac foo % pub get
Resolving dependencies...
The current Dart SDK version is 2.7.2.
Because foo requires SDK version >=2.12.0 <3.0.0, version solving failed.
iDecode@iDecodes-Mac foo % flutter --version
Flutter 2.6.0-11.0.pre • channel dev
Tools • Dart 2.15.0 (build 2.15.0-116.0.dev)
My pubspec.yaml file has:
environment:
sdk: '>=2.12.0 <3.0.0'
As you can see my current Dart SDK version is set to 2.7.2, my project is targeting a min of 2.12.0 and Dart SDK installed on my machine is 2.15.0. So, how do I change the current Dart SDK version?
This is my ~/.zshrc file
export PATH=/flutter/bin:$PATH
export PATH=$PATH:/$HOME/Library/Android/sdk/platform-tools/
export PATH="$PATH:/$HOME/flutter/bin"
export PATH="$PATH":"$HOME/.pub-cache/bin"
export JAVA_HOME=$(/usr/libexec/java_home)
Solution 1:[1]
You can also try this way: Just download that specific flutter version from here. and just set the flutter version in your editor and try to run it will run that specific flutter version but make sure you can't run that with terminal commands. So you need to handle all commands from the Tools option.
Solution 2:[2]
Upgrade by running flutter upgrade [check it out here] (update dart sdk for flutter)
Solution 3:[3]
Flutter comes with dart by default. Suggestion is to delete old flutter, delete .zshrc and download the latest stable version 2.5.3 for your mac and then give path for it in your .zshrc. Other method is switch to flutter stable by running flutter channel stable and then give flutter upgrade command so it will catch all the stuff from git in you local machine and you'll be good to go.
Solution 4:[4]
Simply go to the location where Dart SDK is kept and delete that and install a new Dart SDK version from the official website which is
https://dart.dev/get-dart
Solution 5:[5]
I had that same issue
Resolving dependencies... (5.3s)
The current Dart SDK version is 2.17.0.
Because talk_to_me depends on browser >=0.3.1+1 which requires SDK version
<2.0.0, version solving failed
I think we need to uninstall dart and install the correct version
To uninstall dart:
sudo apt purge dart
Solution 6:[6]
Your code is checking the command line for arguments, it is not reading standard input. To use xargs get move the input from the pipe to the command line is a good way of doing it.
echo -n "this is a test" | xargs cargo run -- -n11
The other option you have is to change your program so it reads from stdin if no user_string argument was given. Here is a good starting point to read stdin https://doc.rust-lang.org/std/io/struct.Stdin.html
You should also replace the unwrap() here:
let key: u8 = matches.value_of("num").unwrap()
with a check if the argument was given as it was not .required(true) for instance with a
if let Some(key) = matches.value_of("num")
or maybe with a unwrap_or("0")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Dave0116 |
| Solution 3 | Ahmad Hassan |
| Solution 4 | heyom |
| Solution 5 | Vladimir Dimitrov |
| Solution 6 |
