xxxxxxxxxx
I had the same problem after importing a flutter project from git. These are
the steps to solve the problem.
1. Inside Android Studio File->Settings->Language & Framework->Flutter
2. Choose flutter SDK path: the first time we install flutter, we choose the
location where the flutter should be installed. Choose this location.
3. Click OK and the android studio will refresh. Carry on if the problem is
solved.
4. If you are still stuck with the error.
5. Goto this link and install Dart. (https://flutter.io/get-started/install/)
6. Goto the same place in settings, ..Language & Framework->Dart and chose the
SDK location. This solved the issues for me.
xxxxxxxxxx
import 'dart:io';
void main() {
String currentDirectory = Directory.current.path;
print('Current Directory: $currentDirectory');
}
xxxxxxxxxx
On macos: After installing dart using brew install dart, run brew info dart
At the bottom it prints:
Please note the path to the Dart SDK:
/usr/local/opt/dart/libexec
xxxxxxxxxx
Install using apt-get
Perform the following one-time setup:
sudo apt-get update
sudo apt-get install apt-transport-https
wget -qO- https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo gpg --dearmor -o /usr/share/keyrings/dart.gpg
echo 'deb [signed-by=/usr/share/keyrings/dart.gpg arch=amd64] https://storage.googleapis.com/download.dartlang.org/linux/debian stable main' | sudo tee /etc/apt/sources.list.d/dart_stable.list
Then install the Dart SDK:
sudo apt-get update
sudo apt-get install dart
Install a Debian package
Alternatively, download Dart SDK as a Debian package in the .deb package format.
Modify PATH for access to all Dart binaries
After installing the SDK, add its bin directory to your PATH. For example, use the following command to change PATH in your active terminal session:
export PATH="$PATH:/usr/lib/dart/bin"
To change the PATH for future terminal sessions, use a command like this:
echo 'export PATH="$PATH:/usr/lib/dart/bin"' >> ~/.profile