What is CLI commands in Flutter?

· 4 min read
What is CLI commands in Flutter?
What is CLI commands in Flutter?

Flutter Command-Line (CLI) tool enables a user to interact with flutter SDK. So, in this article, we will see what is CLI commands in Flutter.

What is CLI commands in Flutter?

Flutter is a mobile development UI kit by Google. It is powered by dart language. Dart is used for the Flutter framework to make applications for mobile, web, and desktop with a single codebase. So, let’s see a few Flutter command-line tools that flutter uses. We will see the most important commands which are used in almost all flutter projects.

Create an App:

This command creates a new flutter app project, in the current directory. If you want to create the project in a specific folder then move to that directory first using the command cd FILE  ADDRESS. The syntax is shown below:

flutter create APP_NAME

Test Flutter App:

This command performs a test on the flutter project or a specific dart file. It checks if the application or code is flawed or not. This is very useful if our application is big and test it manually is not possible.

flutter test [<DIRECTORY|DART_FILE>]

Run a Dart file:

This command will run the dart file if mentioned or otherwise it will run the whole project in the device which the user chooses.

flutter run <DART_FILE>

Analyze the Dart Code:

This command performs a static analysis of the project’s Dart source code. Basically what it does is search for any missing code or errors. It can be performed for a specific file or the whole flutter project.

flutter analyze -d <DEVICE_ID>

Check Channels:

This command will list all the flutter channels available right now. You can see which one you are using or switch to another to access new features. Generally stable is the one most people use.

flutter channel <CHANNEL_NAME>

Check Project Health:

This Flutter doctor command will check the current status of the flutter information. If some software is missing or not working then it will show a warning.

flutter doctor

Download Dependencies/Packages:

This command downloads all the packages or dependencies which are listed in the pubspeck.yaml file of the current or active project file.

flutter pub get

Build the Project:

This command is to build the flutter application in the directory we want. If we don’t assign a directory then it will build inside the build folder. Also, we can build a web app with a flutter build web command, an android app with flutter build apk or flutter build app bundle (more preferred), and an iOS app with a flutter build ios command.

flutter build <DIRECTORY>

List Connected Devices:

This is the command to list all the connected devices on which we can run our flutter application. Then we can connect to the device of our choice to run the flutter application.

 flutter devices -d <DEVICE_ID>

Upgrade Flutter Version:

This command should be run globally in the system. Moreover, it upgrades the copy of flutter SDK along with dart SKD in our machine. It is usually a good idea to run this command after every new release.

flutter upgrade

Conclusion:

Thanks for being with us on a Flutter Journey!

So, in this article, we have seen What is CLI commands in Flutter. Also, feel free to comment and provide any other suggestions regarding Flutter tips & tricks.

Flutter Agency is our portal Platform dedicated to Flutter Technology and Flutter Developers. The portal is full of cool resources from Flutter like Flutter Widget GuideFlutter ProjectsCode libs and etc.

Flutter Agency is one of the most popular online portals dedicated to Flutter Technology. Daily thousands of unique visitors come to this portal to enhance their knowledge of Flutter.

Leave a Reply