How to Set Up Your Physical Device to Run Your Flutter Project in VSCode

Fatuma Yattani
3 min readFeb 22, 2024

--

image from unsplash.com

Are you eager to see your Flutter project in action on your physical Android device? Setting up your phone to run your Flutter project in Visual Studio Code (VSCode) is easier than you might think. Follow these step-by-step instructions to get started:

1. Enable Developer Options

First things first, you need to enable Developer Options on your Android device. To do this:

  • Go to Settings on your phone.
  • Scroll down and tap on “About Phone”.
  • Find the “Build Number” entry and tap on it multiple times (usually around 7 times) until you see a message confirming that you are now a developer.

2. Enable USB Debugging

With Developer Options now accessible, you can enable USB debugging:

  • Still, in the Settings menu, locate and tap on “Developer Options”.
  • Toggle on the “USB debugging” option.

3. Connect your Device to your Computer

Now, take your USB cable and connect your Android device to your computer.

4. Check Device Connection

Open a terminal or command prompt on your computer and run the command flutter devices. This command will display a list of all connected devices. Make sure your device is recognized and listed.

5. Allow USB Debugging Access

When you connect your device to your computer for the first time, you may see a prompt on your phone asking for permission to allow USB debugging. Grant the permission to proceed.

6. Set Target Device in VSCode

Switch to VSCode and open your Flutter project. Then, follow these steps:

  • Press Ctrl+Shift+P to open the command palette.
  • Type “Flutter: Select Device” and hit Enter.
  • Choose your connected device from the list that appears.

7. Run your Flutter Project

With your device selected as the target, it’s time to run your Flutter project:

  • Press F5 or select "Debug > Start Debugging" from the VSCode menu.

Watch as your Flutter project is built and deployed directly onto your physical device. You’ll be able to see the output and interact with your app right on your device’s screen.

Additional Tips:

  • Hot reload: If you make code changes while the app is running, hot reload will automatically update the app without restarting. This speeds up development significantly. Press r in the terminal window: This will trigger hot reload and update your running app with the changes.
  • Build modes: You can build your app in different modes (debug, profile, release) using the flutter run --mode command or the "Run and Debug" panel in VS Code for more control and optimization.
  • Troubleshooting: If you encounter issues, consult the Flutter documentation or seek help online in forums or communities.

Key Points:

  • Device compatibility: Ensure your physical device meets Flutter’s requirements.
  • USB debugging: Make sure USB debugging is enabled on your device.
  • VS Code extensions: Install the necessary VS Code extensions for Flutter and Dart support.
  • Build modes: Choose the appropriate build mode for your needs.
  • Hot reload: Leverage hot reload for faster development iterations.

--

--