Site icon AndroidRide

7 Flutter Commands & Command Line Options You Must Know : Create New Project, Run & More Commands Using CLI

flutter create new project command line options cli create flutter app
In this post, you will learn about flutter terminal commands and command-line options. Using Flutter command-line interface (CLI), you can perform lots of operations in your project.

Before that make sure you have downloaded Flutter SDK and updated path variable if you are using Windows.

If you haven’t, you can use Flutter Android Studio post to do that.

You could run below commands in flutter console too.

flutter console terminal

This is Flutter console. You can find it in Flutter SDK.

Let’s start…
7 Flutter Commands You Must Know - Create Flutter App, Run & More.

7. Flutter clean – Reduces Project Size by deleting build and .dart_tool directories.

When I created a simple flutter app, it’s size only below 200 kb but after a run in an emulator, Its size largely increases and takes more than 300 MB.

So if you have a low-configuration PC and you are learning flutter by making different apps. That might takes lots of memory in your device.

So just use below command in the root folder of the project.

flutter clean
flutter clean
flutter clean command

6.Flutter build – List Build Commands

For publishing your flutter app, you need to make binaries for Android and Ios. The build command by default makes a release flavor of the app.

flutter build

flutter build
flutter build appbundle - build an appbundle
flutter build apk 
flutter build apk --split-per-abi 
flutter build ios 

5. Flutter channel – List Different Flutter Source Code Branches

Flutter channel means a git branch where we get Flutter source code. It could be used to change different branches such as master, dev, beta, and stable.

Just run “flutter channel” to find out.

flu
flutter channel

Let’s change the channel…

flutter channel [channel_name] – this is syntax, let’s change stable to master.

flutter channel master
how to change flutter channel
change flutter channel to master

4. Flutter run – Run Flutter Project

If you have created your flutter project, then you can run it on any devices or emulators using the run command. While using the run command, it must be called from the root directory of the project. you can use cd command for that purpose.

cd flutter_app
flutter run

flutter run & fluttter run -d
flutter run & fluttter run -d
flutter run -d emulator-5554
flutter run --release

3.flutter create – Create new flutter project Using Command Line

This command is used to create flutter projects, such as Flutter application, package, plugin, and module.

flutter create [output_directory_name or project_name]
flutter create flutter_app
create flutter app flutter create new project command line
flutter create new project command line
flutter creates project again
flutter recreates project

Let’s create a project with our own package name and description, use below code

flutter create --org com.androidride --description "simple example" my_flutter_app

Let’s check how to create a package using flutter commands.

flutter create -t package flutter_package
flutter create package
flutter create package

Let’s create a plugin project with flutter create command.

flutter create -t plugin flutter_plugin

we can change that by using the below command.

flutter create -t plugin -i objc -a java my_flutter_plugin

2.Flutter doctor – Diagnoses Flutter system environment.

This command diagnoses our system and tells us is everything fine or any issues need to treat just like a doctor.

If there are no issues, you are good to go. You don’t need to worry about all issues. For example, you are making a flutter app in VS Code, So you can avoid problems associated with Android Studio.

For example, Flutter plugin not installed in Android Studio like error.

flutter doctor

flutter doctor

Okay… Let’s know more details by running

flutter doctor -v

flutter doctor -v

1. flutter help

Just like the name it helps developers to find other commands and tells us how to use them just like a senior developer who is sitting nearby you. So I think, you don’t need to remember all commands I told above, Just remember this one.

flutter help
flutter help command
flutter help
flutter help -v
flutter help [command]
flutter help create
flutter help create
flutter help create

Flutter Other Commands

Now I will show you some other commands with fewer details that helped me while I create flutter apps.

That’s all for now. Thank you. If you like this post, please share it with your friends and family.

Exit mobile version