How to change package name in flutter?

Installing flutter pub rename

Follow the instruction to install https://pub.dev/packages/rename

Read the usage from –help

You may rename the AppName or BundleId

juzhax@Juz-MacBook-Pro flutter_first_app % flutter pub global run rename --help
A CLI tool that helps for renaming in Flutter projects.

Usage: rename <command> [arguments]

Global options:
-h, --help       Print this usage information.
-v, --version

Available commands:
  getAppName    Get app names for the targeted platforms
  getBundleId   Get bundleId identifiers for the targeted platforms
  setAppName    Set app name for the targeted platforms
  setBundleId   Set bundleId identifier for the targeted platforms

Run "rename help <command>" for more information about a command.

Result from flutter pub global

This is the example result logs from the console

juzhax@Juz-MacBook-Pro flutter_first_app % flutter pub global run rename setBundleId -v com.juzhax.flutter_first_app
[   +3 ms] executing: sw_vers -productName
[   +7 ms] Exit code 0 from: sw_vers -productName
[        ] macOS
[        ] executing: sw_vers -productVersion
[   +5 ms] Exit code 0 from: sw_vers -productVersion
[        ] 14.2.1
[        ] executing: sw_vers -buildVersion
[   +5 ms] Exit code 0 from: sw_vers -buildVersion
[        ] 23C71
[        ] executing: uname -m
[   +1 ms] Exit code 0 from: uname -m
[        ] arm64
[   +1 ms] executing: sysctl hw.optional.arm64
[   +1 ms] Exit code 0 from: sysctl hw.optional.arm64
[        ] hw.optional.arm64: 1
[  +24 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[        ] Artifact Instance of 'LegacyCanvasKitRemover' is not required, skipping update.
[        ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[  +15 ms] Artifact Instance of 'MaterialFonts' is not required, skipping update.
[        ] Artifact Instance of 'GradleWrapper' is not required, skipping update.
[        ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[        ] Artifact Instance of 'LegacyCanvasKitRemover' is not required, skipping update.
[        ] Artifact Instance of 'FlutterSdk' is not required, skipping update.
[        ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FontSubsetArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'PubDependencies' is not required, skipping update.
[  +37 ms] executing: [/Users/juzhax/flutter-app/flutter_first_app/] /Users/juzhax/flutter/bin/cache/dart-sdk/bin/dart pub --suppress-analytics global run rename setBundleId -v
com.juzhax.flutter_first_app
FINE: Pub 3.2.4
FINE: Package Config up to date.
FINE: Package Config up to date.
Targets: [ios, android]
Value: com.juzhax.flutter_first_app
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ #0   Rename._handleCommand (package:rename/rename.dart:156:16)
│ #1   <asynchronous suspension>
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ 💡 rename has successfuly changed bundleId for IOS
│ 💡 com.example.flutterFirstApp; -> com.juzhax.flutter_first_app
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ #0   Rename._handleCommand (package:rename/rename.dart:156:16)
│ #1   <asynchronous suspension>
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ 💡 rename has successfuly changed bundleId for ANDROID
│ 💡 com.example.flutter_first_app -> com.juzhax.flutter_first_app
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
IO  : Writing 6462 characters to text file /Users/juzhax/.pub-cache/log/pub_log.txt.
MSG : Logs written to /Users/juzhax/.pub-cache/log/pub_log.txt.
[ +189 ms] "flutter global" took 247ms.
[ +115 ms] ensureAnalyticsSent: 114ms
[        ] Running 0 shutdown hooks
[        ] Shutdown hooks complete
[        ] exiting with code 0

Tags:

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.