Flutter - Creating New Project

This tutorial shows you how to create a new Flutter project using command line (terminal) and Android Studio.

Are you new to Flutter or haven't created any Flutter project before? This tutorial explains how to create a new Flutter project using command line (terminal) and Android Studio, including the available options when creating a project.

Using Command Line

If you have installed Flutter and set the PATH variable correctly, you should be able to use flutter commands from your terminal. For creating a new project, you can use the create command followed by the output directory. For example, if you want to create a project named project_one, you can use the following command.

  flutter create project_one

There are some optional arguments that you can pass to customize how the project should be created.

Set Language for Android

For Android-specific code, you can choose to use Java or Kotlin by passing --android-language argument (short: -a). The allowed values are java and kotlin (default). Example:

  flutter create --android-language=java project_one

Set Language for iOS

For iOS-specific code, you can choose to use ObjectiveC or Swift by passing --ios-language argument (short: -i). The allowed values are objc and swift (default).Example:

  flutter create --ios-language=objc project_one

Set Target Platforms

Flutter supports various platforms which include Android, iOS, Web, Windows, Linux, and macOS. By default, when creating a new project, Flutter will provide the basic setup for all platforms, so that you can run the project on any platform later. For desktop platforms, Flutter will only setup the platform-specific code and config if you already have done the setup for the platform, which can be read on Flutter Desktop Support page.

If you are sure that the application will only run on certain platforms only, you can pass the --platforms argument. The possible values are android, ios, web, windows, linux, and macos — all of them are defaults. It accepts multiple values separated by commas. For example, below is the command if you only want to run the platform on Android and web.

  flutter create --platforms=android,web project_one

This argument only works if the --template argument value is app (default) or plugin.

Set Project Type/Template

A Flutter project can be an application, a module, a package, or a plugin and it would be better if the generated template depends on the project type that you're going to develop. You can specify the project type by passing --template argument (short: -t). The valid values are app, module, package, and plugin. Example:

  flutter create --template=package project_one

Specify Code Sample

By default, Flutter generates a sample file as main.dart which can be helpful for developers, especially for those who are new to Flutter. It's possible to specify the code to be used as the sample file by passing the --sample argument (short: -s). The value passed to the argument is the sample ID. The below command specifies that the sample with ID widgets.SingleChildScrollView.1 is used as the sample.

  flutter create --sample=widgets.SingleChildScrollView.1 project_one

To get the list of available samples, you can use the --list-samples argument.

  flutter create --list-samples=list_samples.json

Using Android Studio

Android Studio is a very popular IDE for Flutter developers. If you are going to use Android Studio, creating a new project can be done easier with the help of GUI. First of all, you have to install the Flutter plugin. You need to open the plugin settings from File > Settings > Plugins menu on Linux/Windows or Preferences > Plugins menu on macOS. If your Android Studio currently doesn't open any project, just select the Configure > Plugins menu from the welcome popup. Then, search for the Flutter plugin from marketplace and install it.

Flutter - Android Studio Plugin

After the Flutter plugin has been installed, you should find the File > New > New Flutter Project menu.


Flutter - Create Project - Android Studio

If your Android Studio currently doesn't open any project, there should be Create New Flutter Project option on the welcome popup. Click on it and it will open a new popup.

Flutter - Create Project - Android Studio Welcome Popup

In the first step, you need to select the project type and specify the SDK path.

Flutter - Create Project - Android Studio

In the next step, you can configure the name, directory, description, and organization of the project. You can also configure the languages for Android and iOS as well as configure the supported platforms. Finally, just click on the Finish button and wait until the project is successfully created.

Flutter - Create Project - Android Studio


That's how to create a new Flutter project. You can use command line or any supported IDE. Flutter allows you to specify the used language for Android and iOS, specify the target platforms, set the project type, and specify the code sample.