How to change package name in flutter?

To change the package name of a Flutter app, you can follow these general steps:

  1. Update the Android package name: The package name of a Flutter app is typically defined in the AndroidManifest.xml file located in the android/app/src/main directory of your Flutter project. Update the package attribute in the <manifest> tag to your new package name.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.example.newpackagename">

2. Update the iOS bundle identifier: The bundle identifier of a Flutter app is typically defined in the Info.plist file located in the ios/Runner directory of your Flutter project. Update the CFBundleIdentifier key to your new bundle identifier.

<key>CFBundleIdentifier</key>
<string>com.example.newpackagename</string>

3. Rename the package folder: Rename the folder of your Flutter app’s package to match the new package name. This folder is typically located in the lib directory of your Flutter project.

4. Update import statements: Update any import statements in your Dart files to reflect the new package name.

import 'package:newpackagename/my_widget.dart';

5. Update Gradle settings: Open the android/build.gradle file and update the applicationId of the defaultConfig section to your new package name.

defaultConfig {
  // ...
  applicationId "com.example.newpackagename"
  // ...
}

6. Clean and rebuild the project: After making these changes, clean and rebuild your Flutter project to ensure that the changes are applied correctly.

flutter clean
flutter run

It’s important to note that changing the package name of a Flutter app can have implications for the app’s functionality, including potential data loss, so it’s important to back up your app data before making any changes. Additionally, changing the package name can also affect app store listings and updates, so be sure to update any relevant information accordingly.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More