System Requirements
- Operating system : macOS 10.15 or higher (64-bit)
- Disk space : 3GB (excluding disk space for IDE/Tools)
- Tools : Git, Xcode, Android Studio, Visual Studio Code
Get Flutter SDK
- Download the stable Flutter SDK
.zip
file from link given below https://flutter.dev/docs/get-started/install/macos - Unzip the file and move the folder named
flutter
from your Downloads folder to an ideal location to set it up permanently i.e., theHome
directory. - Go to
Home
by using the keyboard shortcutShift + CMD + H
and create a new folder namedDeveloper
and move theflutter
folder here. - Also, you can reach the
Home
directory from theFinder
window.Sidebar > Favourites > [folder_with_your_username]
. Refer below image for reference.
- Now that you have moved the flutter SDK folder to a permanent location, we can continue to define a path variable.
Adding a PATH Variable
To run flutter commands in any of your terminal sessions, a permanent path variable must be added into the rc
file of your shell.
- Open Terminal window
- Change to the directory where you placed the Flutter SDK folder (or) simply drag the flutter folder into the terminal window preceded with a
cd
command and run it.
- Now open or create a
rc
file to add in the path variable for Flutter SDK. Typingecho $SHELL
in your Terminal tells you which shell you’re using. If you’re using Bash, edit.bash_profile
or.bashrc
file. If you’re using Z shell, edit.zshrc
file. - In my case, i’m using a
zsh
shell. Open a new terminal session, runvim .zshrc
. If you are abash
shell user, runvim .bash_profile
orvim .bashrc
to enter inside a text editor where you will be adding the path variable.
- Hit
I
on keyboard to enter edit mode invim
editor. Add the following line and change[PATH_TO_FLUTTER_GIT_DIRECTORY]
to be the path where you hosted your Flutter SDK.
$ export PATH="$PATH:[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin"
- Now press
ESC
and type:wq!
to save yourrc
file and quit the terminal.
- Now open a new terminal session and run
$ flutter --version
command. This will check for the existing Flutter SDK folder and will download the Dart SDK.
- Now run
$ flutter doctor
command to to see if there are any dependencies you need to install to complete the setup. Any errors or warnings will be fixed in the process followed furthur.
Setting up Android Studio
- Download the latest Android Studio
.dmg
file from the link given below: https://developer.android.com/studio - Opening the .dmg file prompts a setup wizard that installs all Android SDK, Platform and Build Tools required. Proceed by clicking ‘yes’ without changing the default settings and wait for the installation to complete.
- Now run Android Studio and install the Flutter and Dart plugins as shown below:
- Select the
Configure
menu at bottom right and selectPlugins
. Search forFlutter
plugin and install. It will also display a prompt to installDart
plugin. Allow for the installation and restart the IDE for the changes to take effect. - Now we need to accept Android Licences in-order to proceed further. We do this by running the following command:
$ flutter doctor --android-licences
and by enteringy
to every Accept prompt in the terminal, we will be done with accepting all the android licences.
Creating and Deploying App to Android Simulator
- Follow below images with instructions to deploy a sample flutter app on to Android simulator.
The above sample app is a Counter
app which on cliking the +
button increments the count value and displays in on screen. It is provided as a started project by Flutter.
Setting up Xcode
- Download the latest version of Xcode from the Mac App Store and complete the installation process.
- It might ask you to agree with it terms and conditions. Simple agree all the prompts and you will be ready to start your development
- Open Xcode. On initial launch, you will be asked for installation of some additional components and command line tools basing on the system configuration. Allow installation.
- Now head to the menubar and click on
Xcode > Preferences > Accounts
or you can use theCMD + ,
keyboard shortcut to open the preference pane. - Add and sign-in with your apple account. This will be helpful when you want to run your Flutter app on to a real iPhone device.
Deploying App to iOS Devices
Source: flutter docs
To deploy your Flutter app to a physical iOS device you’ll need to set up physical device deployment in Xcode and an Apple Developer account. If your app is using Flutter plugins, you will also need the third-party CocoaPods dependency manager.
- You can skip this step if your apps do not depend on Flutter plugins with native iOS code. Install and set up CocoaPods by running the following command
$ sudo gem install cocoapods
- Open the default Xcode workspace in your project by running
open ios/Runner.xcworkspace
in a terminal window from your Flutter project directory. - Select the device you intend to deploy to in the device drop-down menu next to the run button.
- Select the
Runner
project in the left navigation panel. - In the
Runner
target settings page, make sure your Development Team is selected. The UI varies depending on your version of Xcode.
- For Xcode 10, look under General > Signing > Team.
- For Xcode 11 and newer, look under Signing & Capabilities > Team.
When you select a team, Xcode creates and downloads a Development Certificate, registers your device with your account, and creates and downloads a provisioning profile (if needed).
- To start your first iOS development project, you might need to sign into Xcode with your Apple ID.
- Development and testing is supported for any Apple ID. Enrolling in the Apple Developer Program is required to distribute your app to the App Store. For details about membership types, see Choosing a Membership.
- The first time you use an attached physical device for iOS development, you need to trust both your Mac and the Development Certificate on that device. Select
Trust
in the dialog prompt when first connecting the iOS device to your Mac.
- Then, go to the Settings app on the iOS device, select General > Device Management and trust your Certificate. For first time users, you may need to select General > Profiles > Device Management instead.
- If automatic signing fails in Xcode, verify that the project’s General > Identity > Bundle Identifier value is unique.
- Start your app by running
flutter run
or clicking the Run button in Xcode.
Create and Run a simple Flutter App
- Open Terminal and change to the directory you wish to keep your project files.
- Create a new Flutter app by running the following command.
$ flutter create [your_app_name]
- A directory with
[your_app_name]
is created, containing Flutter’s starter app. Enter this directory.$ cd [your_app_name]
- Open simulator using the following command.
$ open -a Simulator
- To run the app, use
$ flutter run
command.
Setting up Visual Studio Code Editor
- Download the VSCode IDE from the link given below:
https://code.visualstudio.com/download - Open VSCode and click on the
Extensions
tab on the sidebar to the left.
- Search for
Flutter
extension and click on install. It will also install the Dart extension which is bundled together.
Why use VSCode Editor ?
- It is efficient, convinient, lightweight editor that is equipped with all the tools related to code and run Flutter apps. It even has an integrated Command Line Interface (CLI) which helps running the same commands as in mac terminal.
- Xcode cannot be used to code Flutter apps as it can’t be equipped with any plugins in-order to recognise Flutter or Dart code unlike Android Studio or Visual Studio Code. It can only be used to process the flow which delivers the app to App Store.
- Android Studio can be used a default IDE, but it might put a heavy load on the CPU same as Xcode which will decrease efficiency and processing time (mentioning this with regard to low system configuration and storage). Instead it will be good to used Xcode or Android Studio whenever most necessary.
- You can simply create a new project as shown in
Create and Run a simple Flutter App
section above and build your app using VS Code. No hassle launching Android Studio or Xcode is required to create a new project. - If you prefer to choose VS Code, i would like to suggest
Material Icon Theme
extension which gives a materialised look to the icons all over your project files which makes it easy to distinguish.
You can open your previously created project files using Visual Studio Code and continue building your apps without any hassle.
Hope this was informative. Good Luck and Happy Coding…