Favourite List
Nothing Added.

Flutter Create New Project with Package Name

The default Flutter project created by an IDE includes the company domain, in reverse order, followed by the project name. The package name is the unique identifier of your app and it is used to determine where an app is installed on a device. Therefore, it is important to have a meaningful package name for your flutter application.

By default, the package name for your flutter project will be com.example.projectName. We will use our own custom package name while creating a new flutter app/project.

Easy way of creating Flutter Project:

We already know how to create a project with normal way. If you don't know how to create flutter project I'm going to show you how to do it.

  1. Open your terminal and go to your desktop folder or any where you want to locate your new project.
  2. Type following command flutter create my_app
  3. cd my_app
  4. flutter run 
  5. Or, to open on VS Code type "code my_app"

Create Professional Flutter Project:

As I mentioned before this is the normal way of creating a project in flutter. In this article, we are going to create a project with our own package name. There are a few steps to create project with custom package name. Now, let's create a project with custom package name using terminal. Open your terminal and run this command.

flutter create --org com.yourdomain.projectname my_new_project

If you are running this command first time it will take some time to setup flutter and their dependencies.

Once the process is finished go inside the folder and check 

android --> app --> build.gradle file.

It should have the correct package name inside it. Run the project with " flutter run -d all " or emulator id or device id if connected.

How to manually change Flutter Package Name: 

The main reason of why you are getting an error in your project is because you have not changed the package name. Sometimes, we had to manually change our own package name. To change the package name follow below steps. Right Click on your Project and Select: 

Refactor -> Rename

And give the new package name and then press Enter key. Now you will see that the entire project is renamed with a new package name.

Next Post Previous Post
Feels like
No Comment
Add Comment
comment url