Changing the project name

To change project name , you need to change it for all platforms .

You can use rename package to make it easy .
Run this command inside your flutter project root

pub global run rename --appname "Application Name"

You can also specify the platform you want to apply the change

pub global run rename --appname yourappname -t macOS  // support also ios and android

or

Edit AndroidManifest.xml for Android and info.plist for iOS

Do a flutter clean and restart your application if you have a problem.


You can let flutter do this for you:

Using Terminal:

cd /path/to/existing/flutter_project
flutter create --project-name newprojname --org com.yourorgdomain .

Next change the name on line 1 of pubspec.yaml

Trash all generated folders to remove all references of the old project name.

NB - Some import statements will need to have their package references updated manually to the new name. Review the project structure (in your IDE) for any references to the old project name inside of IDE generated files.

Recreate the trashed generated files by using flutter create . (including the space and period at the end) from within the project folder.

Now run flutter clean then debug as normal

Gotchas

You should expect that the project name still resides in all the generated folders for the various environments and in comments/strings. You can use a tool to search all files in the project or folder structure (e.g Cmd + Shift + F in Android Studio or ag {the_silver_searcher in Homebrew}) to find the old name and trash any generated folders including ios, windows, linux. After trashing the generated folders remember to re-create them by running flutter create .


That depends on what you are trying to achieve. If you want to change the name of the app which is displayed in the mobile phones menu 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).

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 to use search and replace in the project. If you do this, you have to choose a name without spaces or special characters. A 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'
  ...);

To add to Rainer's answer, you may also have to change the com.example.myprojectname file under android/app/build.gradle

Also for the com.example.myprojectname, do not use underscores (ie: com.example.my_project_name)

You may also have to find and replace the com.example.myproject name in the files project.pbxproj and MainActivity.java.

Tags:

Flutter