Skip to main content

Step-by-Step Guide to create a new flutter project and run flutter project using Terminal

This is a beginner's guide to terminal and flutter. In this guide we will create a new flutter project from the flutter starter app template and run the project using terminal commands. You will also learn to run the android emulator using the terminal command.


flutter create terminal

  • Validate your flutter setup using "flutter doctor command".

Once flutter sdk and your terminal is up and running, To Create a new flutter project from the flutter starter app template follow the below steps

step 1 : Navigate to your project location using "cd" command in your terminal window

CD Project Folder
CD Project Folder

step 2 : To create a new flutter project in your project location, use "flutter create" command

Syntax : flutter create <app name>
flutter create command
flutter create command
Wait for a couple of seconds and let flutter create the required files and folders in your project location.
Flutter App Created
Flutter App Created
Your flutter project is ready ! Edit your flutter code using your favorite code editor.
  • To run your flutter app - navigate to your project directory using "cd" command
CD Flutter App Directory
CD Flutter App Directory
  • Use command "flutter run" to run your app.
flutter run command - no device
flutter run command - no device
If you get an output : No supported devices connected.
  • To check the list of connected devices run command : flutter devices
flutter devices command - no device
flutter devices command - no device
Note:
To run the flutter app or project you must have either a physical device or emulator connected.
Now, let us understand how to run the emulator device using terminal.

step 3 : Run Android Emulator using Terminal Command

Run command : flutter emulators - to get the list of emulators
flutter emulators command
flutter emulators command
Note your emulator id - In this demo, our emulator id is "Pixel API 28 "

step 4 : Launch your emulator using Terminal Command

Run command : flutter emulators --launch <emulator id>
flutter emulator launch command
flutter emulator launch command
Once the Emulator device is up and running,
Once again, Run command : flutter devices
flutter devices command
flutter devices command
It should show you number of connected devices

step 5 : Run Flutter Project using Terminal Command

Once you have one or more connected devices, we can now run the flutter app or project on the connected devices.
Run command : flutter run - to run your project
flutter run command
flutter run command
Note : if you have more than one device use command - flutter run -d <device id>
Your flutter app is now running successfully on your connected devices.
Flutter Demo App
Flutter Demo App

To learn more about flutter - Flutter Developer Guide

Bonus Tip : Hot Reload and Hot Restart

Flutter Hot Reload : Type r in the terminal windows once you have edited your code to update your app UI instantly.
Flutter Hot Reload
Flutter Hot Reload
Flutter Hot Restart : Type R (shift + r) in the terminal window to restart your app.
Flutter Hot Restart
Flutter Hot Restart
Unauthorized use and/or duplication of this material without express and written permission from this site’s author and/or owner is strictly prohibited.The materials(images, logos, content) contained in this web site are protected by applicable copyright and trade mark law.

Flutter, Pixel, Android and the Android logo are registered trademarks of Google LLC.

Popular posts from this blog

Step-by-Step Guide to create a new flutter project using Visual Studio Code [VS Code]

This is a beginner's guide to visual studio code and flutter. VS Code is a light weight editor with flutter app development, execution and debug support. Visual Studio Code is a source-code editor developed by Microsoft. Install latest stable version of VS Code Install the Flutter and Dart plugins In VS Code "Extensions" Tab, search field type flutter, select "Flutter" in the list and click "Install". Flutter plugin also installs the required Dart plugin. Validate your flutter setup using "flutter doctor command". Once Flutter SDK and your VS Code Editor is up and running, Flutter Visual Studio Code To Create a new flutter project from the flutter starter app template follow the below steps step 1 : Open Command Palette Use Shortcut key - Ctrl+Shift+P or Cmd+Shift+P on macOS OR Go to View Menu, select "Command Palette" VS Code Command Palette step 2 : Create Flutter New Project Sele

Step-by-Step Guide for Flutter Android APK Signing and Release

In this guide we will learn how to sign the release version of apk or aab(android app bundle) to publish our flutter app to android play store. flutter release apk How to sign the apk or app bundle created using flutter ? To publish your app on Play Store, you need to give your app a digital signature. step 1 : Create a new keystore file ; if you have an existing keystore , skip this step Run command in your terminal for linux/mac keytool -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key On Windows, use the following command: keytool -genkey -v -keystore c:/Users/USER_NAME/key.jks -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 -alias key Fill in the required info inside the terminal Enter keystore password: test@12345 Re-enter new password: test@12345 What is your first and last name? [test]: test What is the name of your organizational unit? [test]: test

Step-by-Step Guide to take a App Screenshot with the Device Frame using Android Studio

This guide will help you to take a screenshot with the device frame using android studio. If we capture screenshot using the default android emulator "Capture Screenshot" option, then screenshot will not have the device frame. Android Emulator - Screen Capture By using android studio we can capture screenshot with different devices frame. How to take a App Screenshot with the Device Frame using Android Studio step 1 : Load your project in android studio and run the app Open Android Studio Load your android app project in android studio.  Build and Run your app using android emulator or a connected physical device.  If you are using a physical device make sure that you have enabled USB DEBUGGING option. Android Studio - Load Project step 2 : Open Logcat in Android Studio Check out bottom left corner in android studio to find Logcat option and click to open Logcat If it is not visible then select "View Menu" and search for