Important Flutter Commands

Dineth Prabashwara Benthotage
4 min readMar 27, 2020

You have already set up your flutter development environment in Android studio or VS code or any other relevant IDE.In this article I am trying to show you the command line aspect of flutter.We can use commands of flutter sdk for that.Still valuable to know flutter command line tools because It is important to continuous Integration.OK Let’s Start.

$ flutter create flutter_app

This command creates various files in the specified directory as the skeleton code of the new app.You can use any name for flutter_app as your app name.

$ flutter run

To run the app You can use this command.Before run this command make sure you have connected devices to run the app. Before hit flutter run command you must have connected devices.

$ flutter doctor

After Flutter SDK is installed, it needs to be configured with other supporting tools. The command flutter doctor is the primary tool to provide necessary help.It will show a path to you how to fix those things.Then all you need is apply those things and run that command again.Then It will show you those things are fixed or not fixed.

You can ignore some errors if they are not affect to your activity.

$ flutter upgrade

This will update your flutter sdk to the latest stable version.

Different run types of flutter run command

You can use flutter run command with following types.By default, flutter run builds a debug version of the app. Debug version is good for development and testing with hot reload support.

flutter run — debug is for the running of the debug version.

flutter run — profile is for a version specialized for performance profiling. this option does not currently support emulator targets.

flutter run — release is for the running release version for the app store.

flutter run — flavor a custom app flavor defined by platform-specific build setup. this requires using product flavors in android Gradle scripts and custom X code schemes.There are many arguments are available for this command.

Building flutter app

To deploy flutter apps into devices,app stores(both android and ios) we need to create binary files.Those binary files can be build using flutter build command.

$flutter build apk

As above flutter build apk command has so many options.Let’s see important arguments that we can use with flutter build apk command . - -debug build a debug version apk.- -profile build a version specialized for performance profiling.- -release build a release version ready for publish to app store.- -flavor build a custom app flavor defined by platform-specific build set up.There are many arguments are available for this command.

Install flutter apps

$flutter install

Go to the project location and hitting this command Install your app into devices and emulators.But before this command you have to create app bundle or apk,or binary files using flutter build command.

Install packages

$flutter packages get 
$flutter packages upgrade

In Dart pub is the tool for managing dart packages.The command flutter packages get downloads dependent packages in a Flutter project. The command flutter packages upgrade upgrades packages in a Flutter project.

Testing in Flutter

$flutter test testExample.dart

For maintainable software projects tests are major parts.In flutter we can use flutter test command to run test files of our application.

Analyzing code in flutter

Your project is passed all test cases.Your code has no errors.But you need to analyze further your code you can use following command.

$ flutter analyze

You can check bad code practices and other issues in your code.

Check connected devices

This command display all devices that are connected for the flutter development process.

$flutter devices

Flutter SDK uses the term “device” to reference Android emulators, iOS simulators, and real devices. The command flutter devices lists all devices that can be used by Flutter SDK.

Cleaning build files

The command flutter clean deletes files in the build directory. The disk size of the build directory can be large even for small apps. For example, after building the Flutter sample app, the size of the build directory is about 200M. When learning Flutter, you may create many small apps for testing. It’s a good idea to run flutter clean for those apps when you think you have done with them. You’ll find out that you can reclaim a large amount of disk space.

$flutter clean

Above commands are optional knowledge because All can be done through the IDE.But somehow These are very useful.Many of them have different arguments.Hope you got the idea.

Thanks for reading this article. Be sure to clap/recommend as much as you can and also share with your friends. It means a lot to me.

Also, Let’s become friends on LinkedIn and Github.

--

--