Rename Flutter App Name and Bundle
How often have you been asked to rename the app or bundle ID of your Flutter projects? It's a tedious task to enter the concerning files for Android and iOS and carefully renaming the values of the relevant variables. What's worse is that a typo/mismatch anywhere will lead to the project breaking, only for you to tear your hair for hours to debug the cause of the issue.
To help you out from such situations, here's a plugin that helps you seamlessly update your package and bundle IDs from the command line.
Step 1: Add as a dev dependency
To get started, add this package to your pubspec.yaml as a dev dependency.
Step 2: Activate the package
Next, you need to activate the package from the terminal. Go the the root directory of your project and run the following command:
flutter pub global activate rename
Step 3: Rename your app name or bundle ID
Once the plugin is activate you can update your app name or bundle ID with the following commands:
flutter pub global run rename --bundleId com.<DOMAIN-NAME>.<APP-NAME>
flutter pub global run rename --appname "<YOUR-APP-NAME>"
Sometimes you may want to give a different name to your app for different platforms. Or more relevantly, you may want to use _naming convention for your Android bundle name, but resort to the camel case convention for iOS. In such situations you can run the commands using the target flags -t or --target. For example,
flutter pub global run rename --appname MyIOSApp --target ios
flutter pub global run rename --appname MyAndroidApp --target android
flutter pub global run rename --appname MyWebApp --target web
flutter pub global run rename --appname MyMacOSApp --target macOS
flutter pub global run rename --appname MyWindowsApp --target windows
and,
flutter pub global run rename --bundleId com.example.my_app --target android
flutter pub global run rename --bundleId com.example.myApp --target ios