Skip to content

Touy2004/How-to-install-flutter-step-by-step

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 

Repository files navigation

How to Install & Set Up Flutter: A Step-by-Step Guide

This guide will walk you through installing the Flutter SDK, configuring your system, and running your first virtual device for mobile app development.


Step 1: Download the Flutter SDK

First, you need to get the Flutter SDK (Software Development Kit).

  1. Go to the official Flutter installation page: flutter.dev/docs/get-started/install
  2. Select your operating system: Windows, macOS, or Linux.
  3. Download the latest stable release ZIP file.
  4. Create a folder where you want to store the SDK. For example:
    • Windows: C:\src\flutter
    • macOS/Linux: ~/development/flutter
  5. Extract the downloaded ZIP file into the folder you just created. Do not place it in a directory that requires elevated privileges, like C:\Program Files\.

Step 2: Update Your System Path for Flutter

To run Flutter commands from any terminal, you need to add the Flutter bin directory to your system's PATH environment variable.

Windows

  1. In the Start search bar, type env and select Edit the system environment variables.
  2. Click the Environment Variables... button.
  3. Under "User variables," select the Path variable and click Edit....
  4. Click New and add the full path to your Flutter bin directory (e.g., C:\src\flutter\bin).
  5. Click OK to close all windows.

macOS & Linux

  1. Open your terminal.
  2. Determine which shell you are using by running echo $SHELL. It's usually bash or zsh.
  3. Open your shell's configuration file (.bash_profile, .zshrc, etc.) in a text editor. For example:
    nano ~/.zshrc
  4. Add the following line to the end of the file, replacing [PATH_TO_FLUTTER_DIRECTORY] with the actual path to your Flutter folder:
    export PATH="$PATH:[PATH_TO_FLUTTER_DIRECTORY]/flutter/bin"
  5. Save the file and restart your terminal for the changes to take effect.

Step 3: Install Android Studio

To build apps for Android, you need the Android SDK and tools.

  1. Install Android Studio: Download it from the official Android developer website.
  2. Run Android Studio Setup: Follow the installation wizard. This will install the Android SDK, Android SDK Platform-Tools, and Android SDK Build-Tools.
  3. Find the Android SDK Location:
    • Open Android Studio.
    • Go to Settings/Preferences > Appearance & Behavior > System Settings > Android SDK.
    • At the top of the window, you will see the "Android SDK Location". Copy this path. The default path is usually:
      • Windows: C:\Users\[Your_Username]\AppData\Local\Android\Sdk
      • macOS/Linux: ~/Library/Android/sdk

Step 4: Add Android SDK to Environment Variables

This allows system tools to find and use the Android SDK, which is necessary for adb and other commands.

Windows

  1. Open the Environment Variables window again.
  2. Under "User variables," click New....
  3. For Variable name, enter ANDROID_HOME.
  4. For Variable value, paste the Android SDK location you copied.
  5. Select the Path variable again and click Edit....
  6. Click New and add the following two paths:
    • %ANDROID_HOME%\platform-tools
    • %ANDROID_HOME%\tools
  7. Click OK on all windows to save.

macOS & Linux

  1. Open your shell configuration file (.zshrc, .bash_profile, etc.) again.
  2. Add the following lines, replacing [PATH_TO_ANDROID_SDK] with the SDK location you copied:
    export ANDROID_HOME="[PATH_TO_ANDROID_SDK]"
    export PATH="$PATH:$ANDROID_HOME/platform-tools"
    export PATH="$PATH:$ANDROID_HOME/tools"
  3. Save the file and restart your terminal.

Step 5: Run Flutter Doctor & Accept Licenses

Now, check your full setup and accept the necessary licenses.

  1. Open a new terminal or Command Prompt to ensure the new environment variables are loaded.
  2. Run flutter doctor. It will check your environment and produce a report.
  3. If flutter doctor warns that some Android licenses are not accepted, run the following command:
    flutter doctor --android-licenses
    You will be prompted to review and accept several licenses. Press y followed by Enter for each one.

Step 6: Configure IDE and Final Check

For Android Studio

  1. Install Plugins:
    • In Android Studio, go to Settings/Preferences > Plugins.
    • Search for Flutter in the Marketplace and click Install. Accept the prompt to install the Dart plugin as well.
    • Restart Android Studio when prompted.

For iOS (macOS only)

  1. Install Xcode: Get Xcode from the Mac App Store.
  2. Configure Tools: After installing, run these commands in your terminal:
    sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
    sudo xcodebuild -license
  3. Install CocoaPods:
    sudo gem install cocoapods

Final Check

Run flutter doctor one last time. If all sections have a checkmark [✓], you're ready to start building Flutter apps!


Step 7: How to Run the Android Emulator

Once your setup is complete, here's how to start a virtual device to test your apps.

1. Open the Device Manager

First, you need to open the tool that manages your virtual devices.

  1. Open your Android Studio application.
  2. In the welcome window or with a project open, look for the Device Manager icon in the toolbar on the right side of the window. Alternatively, go to Tools > Device Manager from the top menu.

2. Create a New Virtual Device

If you don't have an emulator set up yet, you'll need to create one.

  1. In the Device Manager panel, click the Create device button.
  2. Select Hardware: Choose a phone model from the list (e.g., Pixel 7 Pro) and click Next.
  3. Select a System Image: Choose the version of the Android OS you want to run. If you don't have one downloaded, click the download icon next to a recommended version (like "UpsideDownCake" or "Tiramisu"). Wait for the download to complete.
  4. Select the downloaded system image and click Next.
  5. Verify Configuration: You can give your emulator a custom name if you wish. Click Finish.

Your new virtual device will now appear in the Device Manager list.

3. Launch the Emulator

Now you can run the virtual device you just created.

  1. In the Device Manager list, find the virtual device you want to use.
  2. Click the Launch icon (a green play button) next to its name.

The Android emulator will start up in a new window. You can now run your Flutter or Android apps directly on this virtual device. 🎉

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published