Installing Flutter and Configuring Your IDE
Installing Flutter and Configuring Your IDE
Do not worry if this sounds daunting. This chapter will guide you through the process and try to answer any questions which may arise along the way. By the end of this chapter, you will have a development environment set up to write your very first app. As a bonus, you will even compile the default sample app, which ships with Flutter!
Chapter overview
Structure
- Getting started on Windows
- Getting started on macOS
- Installing and configuring Visual Studio Code
- Building and running your first Flutter application
- Briefly exploring the default Flutter application
Objectives
Tools
- Git
- Windows PowerShell (Windows only)
- Terminal (macOS only)
- Visual Studio Code
- Visual Studio (Windows only)
- Xcode (macOS only)
- Android Studio
Getting started on Windows
To develop Flutter applications on Windows, we are going to need to install several tools and utilities. We will tackle this one by one, and when we are done you should have everything you need to get started writing apps. The tools we will be installing are PowerShell, Git, Visual Studio, Android Studio, and Flutter.
Enable Windows Developer Mode
Windows Developer Mode needs to be enabled before we can begin developing applications. To do this, you will first need to go to your system settings. Whether you are using Windows 10 or Windows 11, the fastest way is to open the Start menu and type settings. This will open the Windows settings application.
From there, you can either search for developer mode or navigate to Update & Security (on Windows 10) or Privacy & security (on Windows 11). On Windows 10, you will need to go to the For developers tab, and then on both versions of Windows, you will need to toggle the switch for Developer Mode to on.
Windows will likely ask you to confirm this change by presenting you with a security control dialog. Confirming the change will enable developer mode, and then you can close the Settings application.
Install PowerShell
PowerShell is a command line that we will be using throughout this book. Windows 10 and 11 ships with older versions of PowerShell, which we will need to upgrade to the latest version.
To get started, head over to https://aka.ms/powershell-release?tag=stable and scroll down to the assets section. Look for PowerShell-x.y.z-win-x64.msi, where x.y.z is the latest version available. Download the file and run through the installation process. The default install options are sufficient for us, and the installation is very straightforward.
To verify that PowerShell is installed, click your Start menu and type PowerShell. There may be several versions installed, such as Windows PowerShell, Windows PowerShell ISE, and PowerShell v (x64) where v is the major version of PowerShell matching the file you just installed. At the time of writing, the latest major version of PowerShell is version 7. If your search looks like the following screenshot(s) (figure 3.1), you have successfully installed PowerShell.

Figure 3.1: PowerShell in the Windows 10 (left) and Windows 11 (right) Start Menu
Install Git
Git is a source control manager used to manage source code. It helps us to maintain a history of changes that we can refer to in case things go awry or we need more information about what changes were made, by whom, and for what reason. Furthermore, it is a crucial utility for working on a software development team, as it enables multiple developers to collaborate on a single codebase.
To get started with Git, head over to https://git-scm.com/download/win and click the link at the top of the page that says, Click here to download. Once downloaded, run through the installer.
main and click next. The remaining options can all be left as their defaults.Once you are finished installing Git, you can test to ensure it is installed properly by running PowerShell and typing:
git --version
If there are no errors, it will print the version of Git that you just installed and exit. If successful, it should look something like the following (figure 3.2):

Figure 3.2: Successfully verifying that Git has been installed on Windows 10
Install Visual Studio
Microsoft Visual Studio is an integrated development environment (IDE) used by many developers to create all sorts of different types of software. While we will not be using it to develop our Flutter applications, we will be installing it to gain access to the tools it provides to us, including its compiler. A compiler is a piece of software that converts our source code into machine code.
To start, head over to https://visualstudio.microsoft.com/ and look for the Download Visual Studio button. As you hover over it, a dropdown will appear. Select the Community edition. Once downloaded, run the installer which will install and launch the Visual Studio Installer.
The Visual Studio Installer will prompt you for a workload to install alongside the IDE itself. The workload you will need to select is the Desktop development with C++ workload (figure 3.3):

Figure 3.3: Selecting the correct workload during the Visual Studio install
There is an option to start after installation while Visual Studio is installed. Since we will not be using Visual Studio itself, there is no need to run it. Feel free to uncheck this box.
Install Android Studio
Android Studio is another IDE that is used to write Android applications. We will not be using it as our development environment, but we do want some of the tools that it provides, including the Android SDK, command line tools, and the Android Virtual Device (AVD).
First, head over to https://developer.android.com/studio and download the latest version of Android Studio. By default, the installer will have the option to install the Android Virtual Device (AVD) selected. Since we will be using the AVD extensively as we develop and test our applications, ensure that the option to install the Android Virtual Device remains selected.
Once Android Studio is finished installing, be sure to launch it. The first prompt we are presented with will ask us if we want to import settings. Since we do not have any to import, we will select Do not import settings and click OK. Next, we are greeted with the welcome screen. There will probably be an update to install, which a notification at the bottom of the window will inform you of. Install the update, and when prompted, restart Android Studio to apply the changes.
Once Android Studio is finished updating and has been restarted, you will be back at the welcome screen. Click Next to move to the install type screen. Choose the standard option and click Next. You will be offered the option to choose between a light and dark theme, so choose one according to your preferences. The next screen will ask you to verify your settings, which should all be fine. Click Finish. At this point, several components will be downloaded to complete the process.
Once all the components have been downloaded, you will be at a new welcome screen. You will need to create a new project to get to the main application window where we will install and configure the rest of the tools we need. The project you create does not matter, so do not stress too much over it. Just choose New and click through the default options.
Android Studio will create and open the new project, then download several components in the background. There will be a status bar at the bottom of the window which will update you on its progress, as well as a notice at the top that says Gradle project sync in progress. Wait for a while as this process finishes. Once everything has finished, you should see a window that looks like the following (figure 3.4):

Figure 3.4: The Android Studio main window
Install the Android SDK tools
Next, look for the SDK Manager icon (
) in the upper right-hand corner. Clicking this will open the settings window to the Android SDK section. On the SDK Platforms tab, the latest version of Android's SDK will already be installed. This is entirely sufficient for our purposes; however, if you wish to target an older or newer version of Android, this is where you would come to download the SDK.
Now, move over to the SDK Tools tab (figure 3.5). Here, we want to make sure that the check boxes are checked for:
- Android SDK Build-Tools
- NDK (side by side)
- Android SDK command-line tools
- CMake
- Android Emulator
- Android SDK Platform-Tools
If you have an Intel processor, you will also want to install the Intel x86 Emulator Accelerator (HAXM Installer), as this will improve the speed and performance of your Android Emulator. Likewise, if you have an AMD processor, you will want to install the Android Emulator Hypervisor Driver for AMD Processors. If your processor does not have support for virtualization, expect this to fail. Click OK, read and accept the license agreements, and allow the process to complete.

Figure 3.5: Choosing the necessary components to install in Android Studio
Add the platform tools to the Path
Next, we need to configure Windows so that it knows where to find the tools we just installed. Open your Start menu and type Edit the system environment variables then hit Enter. This will open the System Properties window where you will find a button near the bottom that says, Environment Variables…. Tapping this button will open the Environment Variables window (figure 3.6):

Figure 3.6: The Environment Variables window
In the Environment Variables window, look at the upper half where the user variables are. Click on the Path variable (highlighted in the preceding screenshot), and then press the Edit… button. A new window will appear with a list of filesystem locations in it. We need to add the Android SDK platform tools to this list, so click New.
The path we need to add can be found back in Android Studio in the SDK Manager. At the top of the SDK Manager window, you will find Android SDK Location with a filesystem path next to it. Copy this path and paste it into the environment variables window. At the end of the path, add \platform-tools. The full path should resemble the following:
C:\Users\<user>\AppData\Local\Android\Sdk\platform-tools
If you have done this correctly, you should see the path in the list of environment variables, such as in the following screenshot (figure 3.7):

Figure 3.7: The Android SDK platform tools have been added to the Path environment variable
If everything looks good, click OK to close the edit environment variables window, then click OK again to close the environment variables window. Finally, click OK to close the System Properties window.
Create an Android Virtual Device
Back in Android Studio, we are going to create an Android Virtual Device (AVD), which we will be using to test and debug our code. Look for the AVD Manager icon (
) next to where you found the SDK Manager icon (
), in the upper right-hand corner. At this point, you will be presented with a window that has a Create Virtual Device button on it. Click the button to begin.
The first thing we need to do is choose what device to emulate. Select Pixel 4 from the list of devices then click Next. Next, you will be prompted to choose which version of Android you want to run on this device. Click the Download link next to the release name in the list of releases for the latest stable release at the top of the list. When the download is complete, click the Finish button, then click Next.
On the next screen, click the Show advanced settings button and scroll down to find the Internal Storage setting.
64. Finally, click Finish.We are now done setting up and configuring Android Studio and our Android Virtual Device. You will then be returned to the AVD device list, where your new Pixel 4 will be listed. We are done with Android Studio at this point, so close this window and exit Android Studio.
Install Flutter
Now that we have all our tools installed, it is time to move on to installing Flutter itself. To install Flutter, we will be using PowerShell. If you still have PowerShell open, you will need to close and re-open it so that our updated Path variables are populated.
In PowerShell, we will create a directory where we will install Flutter to. Run the following command to create this directory:
cd; mkdir bin; cd bin
This will create a directory, bin, in your home folder, then navigate to that directory.
Next, we are going to use Git to download the latest version of Flutter. While still in the bin directory in PowerShell, issue the following command:
git clone https://github.com/flutter/flutter.git -b stable
If you have done this correctly, you should see output resembling the following (figure 3.8):

Figure 3.8: Successfully cloning the Flutter repository using PowerShell
Cloning the Flutter repository into the bin directory will pull down the latest versions of both Flutter and Dart for us. However, before we can use it, we will need to add it to our Path. So, just like before, head back to the Environment Variables, edit the Path, and add the following location to the list:
C:\Users\<user>\bin\flutter\bin
Be sure to replace <user> with your actual username. The easiest way to find this is by referring to the PowerShell prompt. If you have done this correctly, you will see something resembling the following (figure 3.9):

Figure 3.9: Adding Flutter to the Path environment variable
Once you have added Flutter to your Path variable, you will need to restart PowerShell to read in the new variables. At this point, you should now be able to run the Flutter command line tools!
Run flutter doctor
The first command we will issue to Flutter is:
flutter doctor
This will download and install any missing components, then run through a series of checks to verify that Flutter and all the necessary components required to build and deploy applications are installed correctly. The first time you run flutter doctor will take a while, but any subsequent times you run it will go much faster.
Once flutter doctor has finished, a summary will be reported with any issues (and often their solutions) highlighted, similar to the following screenshot, but running a much newer version of Flutter (figure 3.10):

Figure 3.10: Flutter doctor has finished running for the first time
The first issue we see is a message about the licenses for the Android toolchain not having been accepted. Thankfully, it gives us the command to run to fix this:
flutter doctor --android-licenses
Be sure to read the licenses carefully and agree to each of them. Once completed, running flutter doctor again should show a green checkmark next to each of the different categories.
X next to the Chrome category; however, this will not impact our ability to test our code on the AVD.If all has gone well, you now have a fully functioning Flutter installation with all the necessary tools to build and run applications! Later in this chapter, we will install Visual Studio Code, which is the IDE we will be using to write our Flutter code.
Getting started on macOS
To write Flutter applications on macOS, we are going to need a couple of tools, which we will look at one-by-one. The tools we are going to install include Xcode and Android Studio, in addition to Flutter itself.
Install Xcode
Xcode is Apple's all-in-one utility for developing applications that run on its line of products, from the iPhone and Apple Watch to applications running on macOS and the iPad. Conveniently, it also includes the command line utilities we will need to build Flutter applications.
To install Xcode, you can either download it directly from Apple's developer website (https://developer.apple.com/xcode/) or from the App Store by searching for Xcode or by using the following link: https://apps.apple.com/us/app/xcode/id497799835. The download will take a while, depending on the speed of your internet connection, as Xcode is quite large.
Once Xcode is installed, you will need to launch Terminal.app. Use Spotlight (⌘-Space) to search for terminal or find it in /Applications/Utilities. Once the terminal has loaded, you will need to run the following commands one at a time:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -runFirstLaunch
sudo xcodebuild -license
This will configure your system to use Xcode and allow you to read and agree to the license agreement, all without the need to load Xcode itself. At this point, we are done with Xcode for now, so let us move on.
Install Android Studio
Android Studio is Google's integrated development environment (IDE) used to create Android applications. We will not be using Android Studio to build our Flutter applications (although, that is certainly a possibility) and instead will be using it to install the tools, which will enable us to write, build, and test our applications using whatever IDE we want.
To install Android Studio, you will first need to navigate to https://developer.android.com/studio and download the latest version. After agreeing to the licensing agreement, you will be prompted to choose which version of Android Studio is right for you, depending on your Mac's processor.
Continue to download the version of Android Studio that is appropriate for your system. Once the download is complete, mount the disk image, drag the application to the Applications folder, and launch Android Studio.
You will likely be prompted by the initial screen to update the plugins via a message at the bottom of the window. Go ahead and do that, allowing Android Studio to update its components and restart itself to complete the process. If you are prompted to import settings from a previous install, choose not to import anything. Eventually, you will find yourself at a Welcome to Android Studio window.
Install the Android SDK tools
On the welcome window, look for the More Actions link and from the dropdown which appears, choose SDK Manager. Here, we will need to first make a note of the Android SDK Location at the top of the window. Momentarily, we will be using this to configure our system.
For now, however, choose the SDK Tools tab. Check the boxes for:
- NDK (Side by side)
- Android SDK Command-line Tools (latest)
- CMake
- if you are using a Mac with an Intel processor, also the Intel x86 Emulator Accelerator (HAXM installer)
Click Apply, accept the license agreements, and allow these components to download.
Add the platform tools to the PATH
Meanwhile, head back into the terminal. We are going to take that Android SDK Location path that you took note of earlier and tell our system to use it to find the tools, which Flutter will need to work. So, in the terminal, type the following:
nano ~/.zshrc
This will open a file within a command-line-based text editor (figure 3.11). If the file is empty, simply add the following line using the Android SDK Location as your guide:
export PATH="/Users/<user>/Library/Android/sdk/platform-tools:$PATH"

Figure 3.11: Adding the Android SDK platform-tools to the PATH variable
<user> with your username so that it matches the Android SDK Location and that you are addingplatform-tools to the end of the path. Also, note that this is case-sensitive.If there is already something in this file, find the line which starts with export PATH= and add the Android SDK Location (including the /platform-tools part) to the end of the line, just before the :$PATH. Each directory in this PATH variable will be separated by a colon (:), so double-check that you have done it correctly.
Once you have edited the file and updated the PATH variable, press ⌃O (Control-O) to write the file to the disk, pressing Return when it prompts for the filename. Press ⌃X (Control-X) to exit the editor. Quit and restart your terminal to read in the new variables.
You can verify that the changes have taken effect by typing the following, which should return the path to the adb utility:
which adb
If there is an error, chances are your terminal is not configured to use the zsh shell. To fix this, type the following and restart the terminal:
chsh -s /bin/zsh
Create an Android Virtual Device
Back in Android Studio, close the SDK Manager window to return to the welcome screen. Under the More Actions menu, locate the AVD Manager (figure 3.12). This will pop-up a window that will allow us to create an Android Virtual Device (AVD). Click the button to create a device.

Figure 3.12: The AVD Manager
The device we are going to emulate is Google's Pixel 4 phone. Select it from the list and click Next. We will then be prompted to choose a system image. Click the Download link next to release with the highest API level. This will download an Android system image with the latest version of Android for us to use on our AVD. When it is done downloading, click the Finish button, then click Next.
16. That will give us 16 GB of internal storage to work with, which should be more than sufficient (figure 3.13).
Figure 3.13: Adjusting the internal storage size of your new AVD
Click on Finish to create your AVD, then close the AVD Manager window and exit Android Studio.
Install Flutter
It is time to install Flutter. We will do this in the terminal, too. First, we need a place to install Flutter to, so we are going to create a directory where we will keep it. Run the following command to do that:
cd && mkdir bin && cd bin
Next, we will pull down the latest version of Flutter using Git with the following command:
git clone https://github.com/flutter/flutter.git -b stable
This will install the latest version of Flutter to /Users/<user>/bin/flutter (figure 3.14):

Figure 3.14: Installing Flutter via the command line
We are going to need to edit our PATH variable again so that we can use it, though. Just like before, open up .zshrc in nano:
nano ~/.zshrc
This time, you are going to add /Users/<user>/bin/flutter/bin to the PATH, replacing <user> with your username. If you are uncertain what your username is, you can run the whoami command. Make sure that you insert a colon (:) between the different paths in the PATH variable. Save the file and quit nano when you are finished. Your PATH should look something like the following in your .zshrc file (figure 3.15):
export PATH="[…]/platform-tools:/Users/<user>/bin/flutter/bin:$PATH"

Figure 3.15: Adding Flutter to the PATH variable
Like before, you will need to restart your terminal for these changes to take effect. You can test to make sure that Flutter is found in your PATH by running the following command. If it returns the path to Flutter, you are good to go.
which flutter
Run flutter doctor
The next step is to run the flutter doctor command. This will download and install the necessary components for Flutter. It will also alert you to any issues which could prevent Flutter from working properly. At this point, you are likely to see a couple of different issues.
First, you should be prompted to accept the Android licenses. To do this, run the following command:
flutter doctor --android-licenses
Next, it is likely that you will run into an issue with Xcode in that CocoaPods is not installed. We can fix this by running the following command:
sudo gem install cocoapods
If all goes well, running flutter doctor should not recommend any additional steps (figure 3.16). However, if you are using a Mac with Apple Silicon (M1, M2, and so on), you will need to perform a few additional steps.

Figure 3.16: Flutter doctor completes without errors
Additional information for devices with Apple Silicon (M1, M2, and so on)
ffi.First, you will need to install Rosetta 2 using the following command:
sudo softwareupdate --install-rosetta --agree-to-license
Next, you will need to remove the existing CocoaPods and ffi, and replace them with their x86 counterparts using the following commands:
sudo gem uninstall ffi
sudo gem uninstall cocoapods
sudo arch -x86_64 gem install cocoapods
sudo arch -x86_64 gem install ffi
Any time you need to use CocoaPods and you find that something is not working quite right, try prepending the command with arch -x86_64 and running it again, such as with the following example:
arch -x86_64 flutter run
softwareupdate command), but it no longer mentions x86 CocoaPods, x86 ffi or arch -x86_64. For CocoaPods crashes related to ffi, it suggests reinstalling the gem with the --enable-libffi-alloc flag: sudo gem uninstall ffi && sudo gem install ffi -- --enable-libffi-alloc (Flutter, n.d.).Installing and configuring Visual Studio Code
We are going to be using Visual Studio Code to develop our Flutter applications for the duration of this book. Whether you are on macOS or Windows, you can find the latest version on their website: https://code.visualstudio.com/. Download and install the latest version.
Once you have it installed, run the program. Visual Studio Code does not, by default, have any idea what Flutter or Dart is, which certainly makes developing applications difficult. Luckily, Visual Studio Code is highly extensible, with a thriving extensions marketplace. Extensions to support Flutter and Dart have been created for Visual Studio Code, and we will need to install them.
To accomplish this, look for the Extensions icon on the left-hand side of the window, or press Ctrl + Shift + x on Windows or ⌘ + Shift + x on macOS (figure 3.17):

Figure 3.17: The extensions view in Visual Studio Code
Search the extensions marketplace for Flutter (the author is Dart Code) and press the blue Install button. This will install both the Flutter and Dart extensions, which you can verify by searching for @installed.
Congratulations! You now have a development environment set up for Flutter development! Now, let us create a new Flutter project and get it running in our AVD.
Building and running your first Flutter application
Create the project
Visual Studio Code has a built-in command line that we can use to create our Flutter project. To invoke it, press Ctrl + ` or find the Terminal option in the View menu. First, we will want to create a directory in which we will keep all our projects. Run the following to create a development directory and navigate into it:
cd; mkdir development; cd development
Next, we will create our Flutter application. Run the following and let Flutter do its magic:
flutter create my_application
At this point, we are finished with the terminal. Feel free to close it by clicking the X button on the top-right corner of the terminal.
Open the project in Visual Studio Code
Now, we need to open our project in Visual Studio Code. On the left-hand side of the Visual Studio Code window, locate the top-most icon to navigate to the Explorer view. You will be prompted with two options: Open Folder and Clone Repository. Click the Open Folder button, navigate to your home folder, double-click the development folder, double-click again on the my_application folder, then press the Select Folder button.
A small dialog will appear at the bottom of the window, asking us if we want to use the recommended settings for Dart, which we do. Click the button to accept the changes to your configuration. Your workspace should now look like the following (figure 3.18):

Figure 3.18: Visual Studio Code with a Flutter project open
Explore the project structure
Let us talk about some of the key files and directories in this list view, to understand what we will be working with:
flutter test command.Select the device
To run our code, we will need to open the AVD we created earlier. There are a couple of ways to do this:
- press Ctrl + Shift + p (on Windows) or ⌘ + Shift + p (on macOS) to invoke the command palette and search for Flutter: Select Device, or
- look at the bottom-left of the window, to the right of the Flutter version number. Depending on your system, you may see something which says, No device, or perhaps you will see something like Edge (web-javascript) as highlighted in the following screenshot (figure 3.19):

Figure 3.19: The device selection option in Visual Studio Code
Either option will open a selector at the top-middle of the window. The option we are looking for is Start Pixel 4 API x, where x is the version of the API used with your chosen version of Android that is installed on the device. Selecting this option will launch the AVD and automatically connect to it.
Configure and run
Wait for your AVD to finish booting into Android and allow it to complete any initial setup. Once it is ready, navigate back to Visual Studio Code and find the Run and Debug icon on the left-hand side of the window, which looks like a play button with a little bug on it. On this screen, below the Run and Debug button, click the link to Create a launch.json file, choosing Dart & Flutter when prompted. This will automatically configure Visual Studio Code with the necessary settings to run our application and will automatically open the configuration file in our editor.
The final step is to press the green Play button to compile and run our application. The first time you compile your application will take the longest, as Flutter will need to download any necessary components and compile your entire application. When this process is complete, Flutter will automatically install the application on your AVD, launch it, and connect to it via the debugger. If all goes well, you have just run your first Flutter application (figure 3.20)!

Figure 3.20: The Flutter demo running on an Android Virtual Device
Conclusion
There is a fair amount of setup work involved in getting Flutter running. Luckily, we only need to do it once. The feeling of watching your first Flutter application come to life in front of you can be magical, too.
In the upcoming chapter, we are going to look at the code for the demo application to get an idea of what is going on. We are also going to talk about widgets, more generally speaking. (Like, what even is a widget, anyway?) Plus, we are going to make some widgets of our own. You are going to love this, so turn the page and get started!
Further reading
PowerShell Documentation
References
- Android Developers. (n.d.-a). Configure hardware acceleration for the Android Emulator. Retrieved from Android Developers: https://developer.android.com/studio/run/emulator-acceleration (added, not in the book)
- Android Developers. (n.d.-b). Create and manage virtual devices. Retrieved from Android Developers: https://developer.android.com/studio/run/managing-avds (added, not in the book)
- Flutter. (n.d.). Developing with Flutter on Apple Silicon. Retrieved from GitHub: https://github.com/flutter/flutter/blob/master/docs/platforms/desktop/macos/Developing-with-Flutter-on-Apple-Silicon.md (added, not in the book)
- Intel. (2023, January 28). Intel Hardware Accelerated Execution Manager (HAXM). Retrieved from GitHub: https://github.com/intel/haxm (added, not in the book)
Market Opportunities for Flutter Developers
How Flutter's popularity grew against Swift, Kotlin and React Native, and how Alibaba, BMW, ByteDance, eBay, Toyota and Google use it.
Introduction to Widgets
How Flutter turns widgets into pixels, the difference between stateless, stateful and inherited widgets, and what BuildContext is.