Setup
The following instructions assume a Windows environment.
Prerequisites
-
Download and install Git. This is used to download the Flutter SDK.
-
Go to:
https://gitforwindows.org. -
Download.
-
Install.
-
-
Download and install Android Studio. We will not be using Android Studio, but we need its SDK and emulator.
-
Download.
-
Install.
-
Run, follow the wizards: accept conditions, download tools, etc.
-
Open Android Studio and create a (dummy) new project.
-
Wait for it to finish synching.
-
On the right pane, click on “Running Devices".
-
Click on the plus to add a virtual device. Choose an architecture that your desktop/laptop can handle. If in doubt, choose a small phone with an old Android version such as Android 10.
Flutter
-
Install and set upVisual Studio Code. This is the IDE that we shall use.
-
Go to:
https://code.visualstudio.com/docs?dv=win -
Install.
-
-
Install Flutter extension in VS Code.
-
Install the Flutter SDK.
-
Open the Command Palette by pressing
Ctrl+Shift+Por by going to the burger menu and choosingView -> Command Palette. -
Type “flutter", and choose:
Flutter: New Project. -
You will get an error popup message at the bottom right corner asking you to download the Flutter SDK. Click on "Download SDK".
-
You will be prompted to enter folder for the Flutter SDK. Don’t install Flutter to a directory or path that meets one or both of the following conditions: (i) the path contains special characters or spaces, and (ii) the path requires elevated privileges. For example,
C: Program Filesfails both conditions. -
Click “Add SDK to Path".
-
-
Accept Android licenses.
-
From an elevated command prompt, run:
flutter doctor –android-licenses. -
You will be prompted to accept licenses:
Review licenses that have not been accepted (y/N)? -
Choose “y", and accept the licenses one by one.
-
-
Run
fultter doctorto learn about issues-
In an elevated prompt run:
flutter doctor.
-
Common Pitfalls
-
Flutter SDK not in the path, add it. Go to Windows Settings, and search for Environment Variables, and add Flutter SDK to the user path
-
Android command-line tools not installed, add them:
Android Studio -> Menu -> Tools -> Languages and Frameworks -> Android SDK -> SDK Tools (on right) -> Android SDK Command line tools -> Apply.
First App
-
Run Visual Studio Code.
-
Open command palette (Ctrl+shift+P) and type flutter, and choose
Flutter : New Project -> Application. -
Choose folder for the app files.
-
A project will be created and you will see the
main.dartfile. -
To run the code, click on the “triangle" on right. The first time you run, you will asked to choose the target platform.
-
If you choose Chrome, you will see your app in Chrome.
-
If you choose an AVD (and Android Virtual Device that you have already set up in Android Studio), you will see your app on the AVD.
-
You can also plug in your own phone, and choose it as target.
-
Your device must first be recognizable by Windows.
-
Plug in your device, and make sure that USB debugging and file transfer are enabled.
-
If your computer is just an old disguised calculator, you should perhaps use your device instead of the emulator.
-
-