How to change used Dart version in Android Studio? - flutter

So I am trying to run this command in terminal
flutter pub run intl_translation:extract_to_arb --output-dir=lib/i18n lib/i18n/app_localization.dart
and I get this error
Dart 2.15.1 is incompatible with your dependencies' SDK constraints. Please run "flutter pub get" again.
pub finished with exit code 65
And I noticed that the used Dart version is 2.15.1 and not version 2.10.5 which is specified in the Android Studio project settings
How would I change the actually used Dart version to be able to run the intl_translation command ?

You can download the version you want from this link. https://dart.dev/get-dart/archive

From SDK manager in android studio you can change the flutter SDK and dart SDK to the path of the versions you want to use.
And then restart IDE

Related

I have updated flutter sdk version to 2.10.0 but in terminal error coming saying : current version is 2.8.0

i have updated the sdk version of flutter to 2.10.0 but still old version (2.8.0) is showing in terminal due to which i am unable to use google fonts in my app as the google fonts require sdk version >=2.10.0. I Have used these two commands to upgrade - flutter upgrade and flutter pub get
Check for version file in flutter SDK. Open the flutter SDK folder and open the version file. It use to have a version specified, also check for the flutter version in VS Code at the bottom bar. If both are 2.10.0, then just flutter clean the project and rebuild. IF 2.8.0 is still there, download 2.10.0 zip file and unzip and replace the flutter SDK path.
You would check your flutter's SDK version through the below command
flutter doctor -v
Once you type above command, the system will show you about the current config

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)
It seems like you installed Flutter/Dart SDK somewhere using Homebrew. Use which flutter and which dart to see the actual Flutter/Dart command that is taking effect. Once you find where your Dart SDK is you can use
brew uninstall dart
After this when you run which dart it will now point to where your Flutter SDK was installed.
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.
set flutter version
Must Run commands from here
The dart version is related with flutter version, see which version is what you need here
https://docs.flutter.dev/development/tools/sdk/releases
Upgrade by running flutter upgrade [check it out here] (update dart sdk for flutter)
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.
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
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

Can't set Dart SDK in Android studio

Linux Mint 20.1
In my Flutter project.
I install Dart
https://dart.dev/get-dart
So the Dart location is here on my machine:
whereis dart
dart: /usr/bin/dart /usr/lib/dart
Nice.
Now I want to set this path in Android Studio.
As you can see I get error that Dart SDK not exist
Dart SDK with Flutter provided in flutter/bin directory. In your case, if you provide a valid Flutter SDK path to Flutter plugin, Android Studio automatically detects Dart SDK. If you want to set Dart SDK directly, use it from flutter/bin.

Android Studio Dart And Flutter Plugin is not installed

Here is the flutter doctor result:
[√] Flutter (Channel stable, 1.22.1, on Microsoft Windows [Version 10.0.18362.30], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[!] Android Studio
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
[!] Connected device
! No devices available
! Doctor found issues in 2 categories.
I have already installed the flutter plugin. But the problem still exists. How can I fix this?
Just run this on your terminal (Mac users)
ln -s ~/Library/Application\ Support/Google/AndroidStudio4.1/plugins ~/Library/Application\ Support/AndroidStudio4.1
Well hello all
I would suggest you all to follow the steps what flutter documentation sites tells you to do
For windows-->There are some people who got detected flutter and dart plugins by the flutter doctor and few are not
I got this issue when I tried to install ...
I did everything like installed flutter and dart plugin still my flutter doctor haven't detected the plugins ...
following steps worked for me
flutter channel dev
flutter upgrade
flutter config --android-studio-dir="C:\Program Files\Android\Android Studio"
flutter doctor -v
note :--- flutter config --android-studio-dir="C:\Program Files\Android\Android Studio" should be example flutter config "C:\Program Files\Android\Android Studio"
above steps worked for me i hope it will helps you too :)
change channel master to dev.
then upgrade.
flutter channel dev
flutter channel upgrade
try again
flutter doctor
Note: I think it's Android Studio 4.1 issue...
Since you say you have flutter plugin installed in Android Studio, and if Android Studio correctly shows your installed plugin, there is no reason to believe any third-party tool reporting otherwise.
Also, this will not affect your flutter development and your IDE plugins will work as expected inside the IDE and flutter tool's commands work independent of the IDE in use.
Android Studio 4.1 apparently changed its default plugin install path.
Related github issue: [flutter_tools] IDE plugin validators should be deprecated #61246
Flutter does not directly use the IDE plugins, so doctor failing to detect them does not affect any behavior (it's just annoying).
open terminal:
run> flutter channel dev
run> flutter channel updrade
open terminal:
Mac User:
flutter config --android-studio-dir=/Applications/Android\ Studio.app
Reinstall Flutter Plugin from Android Studio
Are you using Android Studio V 4.1?
With Android Studio V4.1 there is a problem.
Try to reinstall Android Studio but Version 4.0.1 and try it again, chances are this will fix your problem.
Open Android studio
Follow the Path Configure > Plugins > marketplace > search Flutter & Dart > Install
Restart IDE(Android studio)
Open Terminal and Export Flutter Path
and run flutter doctor -v
If you are upgrading for an existing project:
Run
git clone https://github.com/flutter/flutter.git
in your terminal.
The be sure to delete the Flutter folder in your App's root directory. Otherwise you will get over 50k errors popping up
Check your flutter PATH
which flutter
if you get /path-to-flutter-sdk/bin//flutter or similar you may have added an extra / in your $HOME/.rc_file. Remove the last '/', restart terminal and try again
this worked for me
flutter channel dev
flutter doctor

I am getting an error in flutter setup in android studio in windows, i already updated and having latest version of flutter and android studio

After completing all steps like SDK download, path setup in windows getting this error in flutter setup.
This error is occuring before creating flutter project.
The current Dart SDK version is 2.9.2. Because flutter_tools depends on test >=1.16.0-nullsafety which requires SDK version >=2.10.0-0 2.11.0, version solving failed. pub get failed (1; Because flutter_tools depends on test >=1.16.0-nullsafety which requires SDK version >=2.10.0-0 2.11.0, version solving failed.)
Please show your pubspec file. If you have tried all possible solutions and can't figure out the issue, I would say to try and reinstall it.