Creating Your First Flutter Application Using flutter create Command

3 min readMay 19, 2024

In this tutorial, we will look into how we can create a Flutter application using the Flutter command flutter create and also explore all the available options that can be used in different scenarios.

We can use the create command to generate the code for a Flutter project and then execute the code using the run command as below:

flutter create my_app
cd my_app
flutter run lib/main.dart

With this create command, a Flutter project will be created including a specific folder for all the supported platforms that can be executed in those platforms. Another important point to note is that the package name would be auto-generated as com.example.project_name . In our case, the app name is my_app so the package name would be com.example.my_app. In most cases, this package name is not applicable for releasing the application in the App Store, Play Store, etc. So we must do some extra work to change the package name later. Also, as I mentioned earlier, the project consists of the code for all the default supported platforms even though we do not need them. Instead, we can use some options while creating the application to specify the package name, platform to include the code for, etc.

We can use --org it to specify the organization and --project-name to specify the project name as:

flutter create --org com.test --project-name gaming my_app

Here the package name of the app will be com.test.gaming while the project will be created inside the my_app directory.

If you do not include --project-name option then my_app will be the project name and the package name will be com.test.my_app .

Similarly, we can specify the platforms to generate the code for using --platforms option as:

flutter create --platforms=android,ios my_app

We can specify any supported platforms by separating them with a comma(,). Supported platforms as of the creation of today's date are android, ios, linux, macos and windows.

If you do not specify this option, then the code for all the default platforms will be generated which may not be necessary in most cases.

We can add code for any platforms in the existing projects later as per need by using the same command as flutter create --platforms=web . assuming you are in the project root.

We can remove the platforms by simply deleting their directory. Eg. rm -rf ios

We can combine all the available options into one create command as:

flutter create --org com.test --project-name gaming --platforms=ios my_app

Besides these options, other options can be used with the create command. To list all the available options, you can use the help command as flutter create --help .

We can use all the above options while creating a Flutter project using the command flutter create and also combine them wherever applicable.

For example, the following command will generate the Flutter package ie. a shareable Flutter project containing modular Dart code.

flutter create --template=package my_package

This is the end of the article and please do leave suggestions or questions if any in the comment section below. In the next tutorial, we’ll look into how we can change the package name and app icon in an existing Flutter package. Also, feel free to clap 👏 as much as you can and share with others to show support. Thank you!

#flutter #flutter_create #creating_flutter_application_from_command_line #flutter_create_options #flutter_project

--

--

No responses yet