Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Flutter – Renaming a App

  • Last Updated : 16 Dec, 2021

Flutter is a UI kit by Google. Flutter is a widely growing open-source framework, with many libraries getting published daily making android/iOS, web development easy. In this article, we will see the use of the library – “rename“. Although there are other packages also, but this one is the most popular and holds null safety.

While creating a project, you didn’t give it an appropriate name. Now, you want to change its name. There are two options to do it, create a new project, copy all the files inside the new project – it’s a terrible idea, or rename it using a package with just one command- nice idea.

Prerequisite:

  • You have an existing Flutter project to rename.

Implementation:

Follow the below steps to rename your flutter app:

Step 1: Installation of Dependencies

  • In pubspec.yaml, add the dependency of the package as shown in the below image:

Dependencies

  • After adding it, run either of the following commands:
pub get
  • You can also add packages directly from the terminal, simply run either of the following commands:
pub add rename

This command will add dependency in pubspec.yaml file, resolving all the dependencies as shown below:

Installing dependencies

Step 2: Import the package

  • When renaming the app name there is no use in importing this package anywhere. All we have to do is, run a command from the terminal and we are done. From the terminal go to the app location, then type the below command to change the app name. You can give the name inside brackets in place of “New App Name”. We have named the app while creating it as “random_app”, and now renamed it to “Quote-Generator”.
pub global run rename --appname "New App Name"
  • Or run the below command using flutter if the pub is not recognized as an internal command, replace “Quote-Generator” with the new name you want to give to your application: 
flutter pub global run rename --app "Quote-Generator"

After you run this command in a terminal, you should see something like the below:

Renaming Applications

  • If you want to change the name for a specific platform for example, only for android, use this command:
pub global run rename --appname yourappname --target android
  • Or use flutter to run this command(shown below).  Here “–target” specifies the platform which you are targeting. Similarly, you can do this for the web, macOS, iOS, just replace “android” with another platform. For example:

Similarly, for an ios platform,

Change the bundleId:

If you want to change the bundleId, by default it is like “com.example.appname”. Run the below command:

pub global run rename --bundleId com.companyname.newappname

After this, something like the below should be seen on the terminal, it means you have successfully changed the name of bundleId as shown below:

Congratulations!, you just learned a new way to rename the Flutter app and bundleId of your project.

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!