Users can create a flutter project using the command flutter create a name so what if a user wants to change the project once the new project is already been created. So in this article, we will take a look at how to change the project name in flutter.
How to Change the Project Name In Flutter ??
That depends on what you are trying to achieve.
If you want to change the name of the app which is displayed in the menu of the mobile phone together with the app icon, you have to change the android:label in the android/app/src/main/AndroidManifest.xml (Code Sample 1) and the CFBundleName in the ios/Runner/Info.plist (Code Sample 2).
The last time I did this it took me ages to find out, why the name of the app was not changed in the list of currently running apps on Android.
For that, you also need to change the title of your MaterialApp (Code Sample 3).
For renaming it everywhere I would suggest using search and replace in the project.
If you do this, you have to choose a name without spaces or special characters.
So project name ‘new project’ in the pubspec.yaml for example will break the build.
Code Sample 1:
<application android:name="io.flutter.app.FlutterApplication" android:label="New Name" android:icon="@mipmap/ic_launcher">
Code Sample 2:
<key>CFBundleName</key> <string>New Name</string>
Code Sample 3:
return new MaterialApp( title: 'New Name' ...);
So if you want to change the project name, simply change it in all these files.
- build.gradle (app)
Rebuild your app and you should be good to go.
If you are using Android Studio, follow these steps:
- Right-click your project in the Project window (Alt+1 to show).
- Click Refactor > Rename.
- Enter a new name.
So This will rename the project’s name on all required places except in the test directory.
Steps to rename your project:
- Use VSCode’s any other editor’s search and replace across the entire project feature. But always turn on the match cases for vscode: located on the right side.
- You have to do this two times as for the first you have to replace com.orgname.currentname with com.orgname.newname then
- currentname with newname
- Rename the folders inside /android/app/src/main/kotlin/com/orgname/currentname to new /android/app/src/main/kotlin/com/orgname/newname.
- If you’re using only Java with flutter then just replace the kotlin with java
- Rename the currentname.iml of your root project folder to newname.iml
Thanks for reading!! Hope you have learned better!!
So in this article, we have been through how to change the project name in flutter.
Do not forget to drop your valuable suggestions/feedback. We would love to assist you.
FlutterAgency.com is our portal Platform dedicated to Flutter Technology and Flutter Developers. The portal is full of cool resources from Flutter like Flutter Widget Guide, Flutter Projects, Code libs and etc.
FlutterAgency.com is one of the most popular online portals dedicated to Flutter Technology and daily thousands of unique visitors come to this portal to enhance their knowledge of Flutter.