Newby Coder header banner

Flutter Setup

Install in Linux/Ubuntu

Download and extract Flutter SDK

Download the following installation bundle to get a recent stable release of the Flutter SDK:

flutter_linux_1.17.4-stable.tar.xz

Alternatively, check older and beta versions

Extract the file in a desired location, for example:

$ cd ~/Programs
$ tar xf ~/Downloads/flutter_linux_1.17.4-stable.tar.xz  

Add to system PATH

Add the path to flutter binary to shell configuration file where

echo 'export PATH="$PATH:<path_to_flutter_dir>/flutter/bin"'|tee -a <rc_file> 

For example, if flutter is extracted to /home/izaku/Programs and rc file is ~/.bashrc:

echo 'export PATH="$PATH:/home/izaku/Programs/flutter/bin"'|tee -a ~/.bashrc 

Type source ~/.bashrc (or appropriate shell-specific config file) to load the config into current shell

Verify that the flutter command is available by running:

which flutter

Run flutter doctor

Run the following command to see if there are any dependencies required to install (for verbose output, add -v flag):

$ flutter doctor  

This command checks environment and displays a report to the terminal window

For example:

[-] Android toolchain - develop for Android devices
    • Android SDK at /Users/obiwan/Library/Android/sdk
    ✗ Android SDK is missing command line tools; download from https://goo.gl/XxQghQ
    • Try re-installing or updating your Android SDK,
      visit https://flutter.dev/setup/#android-setup for detailed instructions 

Once any missing dependencies is installed, run the flutter doctor command again to verify that things are set up correctly

The flutter tool uses Google Analytics to anonymously report feature usage statistics and basic crash reports

To disable reporting, type flutter config --no-analytics

To display the current setting, type flutter config

Upgrading Flutter SDK

To update Flutter SDK use the flutter upgrade command:

flutter upgrade

This command gets the recent version of the Flutter SDK that’s available on your current Flutter channel

Install Android Studio

Download Android Studio from https://developer.android.com/studio

Extract to a folder, copy-paste android-studio folder to a desired directory

Here its pasted to ~/android-studio (which is also /home/izaku/android-studio)

Start android studio like

~/android-studio/bin/studio.sh

Choose a "Custom" setup when prompted to select an installation type

Make sure the boxes next to following are checked (in case unable to, these can be installed later) :

Install the components

Install Android SDK

Building a React Native app with native code requires the Android 9 (Pie) SDK in particular, which can be installed through the SDK Manager in Android Studio

The SDK Manager can be accessed from one of following

In SDK Manager

Click Finish

Permission

For systems which supports hardware virtualization, the user should have permission to /dev/kvm

Check if /dev/kvm exists, and its permissions with ls -lah

If required, then make current user as owner of /dev/kvm

sudo chown izaku /dev/kvm

where izaku is username

Environment variables

Configure the ANDROID_HOME environment variable

Add the following lines to your $HOME/.bashrc or $HOME/.bash_profile or $HOME/.zshrc or $HOME/.zsh_profile config file (or appropriate shell-specific config file) :

export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools

Type source $HOME/.bashrc to load the config into current shell

Verify that ANDROID_HOME has been added to path by using echo $PATH

Check the actual location of the SDK in Android Studio Preferences β†’ Appearance & Behavior β†’ System Settings β†’ Android SDK

Running an App


Installing in MacOS

Download Flutter SDK

Download the following installation bundle to get a recent stable release of the Flutter SDK:

flutter_macos_1.17.4-stable.zip

For other release channels, and older builds, see the SDK archive page.

Extract the file in a desired location, for example:

cd ~/Programs
unzip ~/Downloads/flutter_macos_1.17.4-stable.zip 

Add to system PATH

Add the path to flutter binary to shell configuration file where

echo 'export PATH="$PATH:<path_to_flutter_dir>/flutter/bin"'|tee -a <rc_file> 

For example, if flutter is extracted to /Users/nc/Programs and rc file is ~/.bashrc:

echo 'export PATH="$PATH:/Users/nc/Programs/flutter/bin"'|tee -a ~/.bashrc 

Type source ~/.bashrc (or appropriate shell-specific config file) to load the config into current shell

Verify that the flutter command is available by running:

which flutter

Run flutter doctor

Run the following command to see if there are any dependencies required to install (for verbose output, add -v flag):

$ flutter doctor  

This command checks environment and displays a report to the terminal window

For example:

[-] Android toolchain - develop for Android devices
    • Android SDK at /Users/obiwan/Library/Android/sdk
    ✗ Android SDK is missing command line tools; download from https://goo.gl/XxQghQ
    • Try re-installing or updating your Android SDK,
      visit https://flutter.dev/setup/#android-setup for detailed instructions 

Once any missing dependencies is installed, run the flutter doctor command again to verify that things are set up correctly

The flutter tool uses Google Analytics to anonymously report feature usage statistics and basic crash reports

To disable reporting, type flutter config --no-analytics

To display the current setting, type flutter config

Upgrading Flutter SDK

To update Flutter SDK use the flutter upgrade command:

flutter upgrade

This command gets the recent version of the Flutter SDK that’s available on your current Flutter channel

iOS setup

Install Xcode

To develop Flutter apps for iOS, a Mac is required with Xcode installed

  1. Install recent stable version of Xcode (using web download or the Mac App Store)
  2. Configure the Xcode command-line tools to use the newly-installed version of Xcode by running the following from the command line:

    sudo xcodebuild -runFirstLaunch
  3. Make sure the Xcode license agreement is signed by either opening Xcode once and confirming or running sudo xcodebuild -license from the command line

Install CocoaPods

CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects, required to run iOS application

Install and set up CocoaPods by running the following commands:

sudo gem install cocoapods
pod setup

Set up the iOS simulator

To prepare to run and test Flutter app on the iOS simulator, follow these steps:

Running an App