How to create flutter project using command line with different parameter?

I will show you three ways how to create a new Flutter project. You can do it with the IDEs Visual Studio Code or Android Studio or by using the command-line tool from the Flutter SDK. You need to have the Flutter SDK installed, otherwise non of these tips will work.

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.

create Flutter project by command line

flutter create --org com.yourdomain your_app_name

This command will create a Simple Counter App

If you want a more advanced template (with a ListView / DetailView / Settings / Theme switch) that follows community best practices run the command (only since the Flutter 2.5 version):

flutter create --org com.yourdomain -t skeleton your_app_name

Swift, Kotlin, and androidx dependencies are the default options

After just open the created project in Android Studio or in VSCode

Parameter

--org com.yourcompany

will form applicationId for Android:

com.yourcompany.yourappname

and iOS PRODUCT_BUNDLE_IDENTIFIER:

com.yourcompany.yourAppName

To explore all possible parameters type

flutter create --help

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 androidioswebwindowslinux, 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 appmodulepackage, 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
how to create project using command line

Just fork and try this github code ://

https://github.com/coderbaba0/example_of_skeletonapp_creation

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More