change_project_name 1.1.0 copy "change_project_name: ^1.1.0" to clipboard
change_project_name: ^1.1.0 copied to clipboard

A CLI tool to rename Flutter/Dart projects and update all package references automatically. Simple, fast, and made for devs who hate tedious refactors.

Change Project Name #

pub package

A powerful CLI tool to rename Flutter/Dart projects and automatically update all package references, and imports.

Features #

  • πŸ”„ Automatic Renaming: Updates project name in pubspec.yaml
  • πŸ“¦ Import Updates: Finds and updates all package imports in Dart files
  • βœ… Validation: Ensures new names follow Dart package naming conventions
  • πŸ” Dry Run: Preview changes before applying them
  • 🎯 Flexible Input: Multiple ways to specify the new project name
  • πŸ“± Smart Detection: Automatically excludes build directories and tool files

Installation #

Install globally using pub:

dart pub global activate change_project_name

Usage #

Basic Usage #

# Simple rename
change-project-name my_new_project

# Using --value flag
change-project-name --value my_new_project

# Interactive mode
change-project-name --interactive

Advanced Options #

# Preview changes without applying them
change-project-name --dry-run my_new_project

# Verbose output
change-project-name --verbose my_new_project

# Show help
change-project-name --help

Programmatic Usage #

You can also use the core logic in your own Dart scripts:

import 'dart:io';
import 'package:change_project_name/change_project_name.dart';

void main() async {
  final renamer = ProjectRenamer(
    projectDir: Directory.current,
    isDryRun: false, // Set to true to preview changes
    isVerbose: true,
  );

  try {
    await renamer.rename('old_name', 'new_name');
  } catch (e) {
    print('Error: $e');
  }
}

Command Line Options #

Option Short Description
--value -v Specify the new project name
--interactive -i Run in interactive mode
--dry-run -d Preview changes without applying
--verbose Show detailed output
--help -h Show help message

What Gets Updated #

  • βœ… pubspec.yaml - Project name
  • βœ… All .dart files - Package import statements
  • βœ… .dart_tool/package_config.json - Package configuration

Example #

$ cd my_flutter_project
$ change-project-name awesome_app

πŸ“¦ Current project name: old_project_name
πŸ”„ Starting project rename from "old_project_name" to "awesome_app"...

πŸ”„ Updating pubspec.yaml...
βœ… Updated: pubspec.yaml

πŸ”„ Updating Dart imports...
βœ… Updated: ./lib/main.dart
βœ… Updated: ./lib/src/app.dart
βœ… Updated: ./.dart_tool/package_config.json

πŸŽ‰ Done! Project successfully renamed to "awesome_app".
πŸ“Œ 2 Dart file(s) updated.

Package Name Validation #

The tool validates that new project names follow Dart package naming conventions:

  • Must be lowercase
  • Can contain underscores and numbers
  • Must start with a letter or underscore
  • Cannot start with numbers

βœ… Valid: my_app, myapp, my_app_v2
❌ Invalid: MyApp, my-app, 2myapp

Requirements #

  • Dart SDK 2.17.0 or higher
  • Must be run from a Flutter/Dart project root (directory containing pubspec.yaml)

Contributing #

Contributions are welcome! Please feel free to submit a Pull Request.

License #

This project is licensed under the MIT License - see the LICENSE file for details.

4
likes
150
points
276
downloads

Publisher

verified publisheritsyourboiputra.is-a.dev

Weekly Downloads

A CLI tool to rename Flutter/Dart projects and update all package references automatically. Simple, fast, and made for devs who hate tedious refactors.

Homepage
Repository (GitHub)
View/report issues

Topics

#cli #flutter #dart #rename #refactor

Documentation

Documentation
API reference

License

MIT (license)

Dependencies

args, path, yaml

More

Packages that depend on change_project_name