Flutter is the cross-platform framework for iOS and Android development. It uses the Dart language. The installation process involves few steps to run flutter on macOS. If you want install only the Dart you can go to the Installing Dart language part.
Installing Flutter on macOS
Before installation make sure you have download Xcode or Android Studio. It depends what you want to use for the development. The official guide of installation macOS is here.
Here are several steps to install the Flutter:
1. Download the stable version of Flutter
2. Make the folder where binaries would be located. You can use development
folder
mkdir ~/development && cd ~/development
3. Unzip folder:
unzip ~/Downloads/flutter_macos_v1.2.1-stable.zip
4. Update the path to enable flutter
in the Terminal
export PATH="$PATH:pwd/flutter/bin"
To add this Flutter permanently to the path, go next:
4.1 For Bash
Open or create .bash_profile
:
vi .bash_profile
And change [PATH_TO_FLUTTER_GIT_DIRECTORY]to the path you've chosen, e.g. development folder:
export PATH="$PATH:[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin"
Example path:
export PATH="$PATH:/Users/yuri/development/flutter/bin"
Refresh bash profile:
source $HOME/.bash_profile
and finally, check it out with Terminal command flutter
5. Run flutter doctor
in the terminal to get the current installation status
It shows now the current situation with installation. You just need to follow the instructions.
The brew
is needed to install the tools for simulator. You can download it here.
The Visual Studio Code is the main IDE for Flutter along with the Dart extensionfor enabling all cool features such as hot reload.
After sorting out the iOS, Android, VS code setup you can check it again with:
flutter doctor
So far the installation process involves quite few steps. But the good thing that the setup can be easily checked and Flutter itself produces code for many platform. So it is worth its installation time.
Installing Dart language
Flutter itself contains Dart environment so this is a part where you want install only Dart. So let's install and play with it.
Installing the Dart language:
brew tap dart-lang/dart
brew install dart
Then you can start access the Dart SDK via command line.
Create a simple dart script using script.dart extension:
void main() {
for (int i = 0; i < 5; i++) {
print('hello, world ${i + 1}');
}
}
Though Dart is not classical scripting language as Python, it can be used via the command line.
For accessing the arguments a programmer would need a library so it is not that handy.
The better approach to play with the language is DartPad . Where you can REPL read-eval-print loop over the code. It is a similar to Playgrounds on Xcode.