comments_remover 1.0.0
comments_remover: ^1.0.0 copied to clipboard
A command-line tool to remove comments from Dart files in a Flutter project.
Comments Remover #
A powerful command-line tool for removing comments from Dart files in your Flutter projects. Whether you need a cleaner codebase for production, code reviews, or learning purposes, Comments Remover helps you strip out single-line (//) and multi-line (/* */) comments effortlessly.
Why Use Comments Remover? #
Comments are invaluable during development for documentation and debugging, but there are cases where removing them is useful:
- Minification: Reduce file size for production builds, improving performance and readability.
- Code Review: Focus on logic and structure without distractions from comments.
- Learning: Clean up example projects (e.g., Flutter templates) to study core functionality without extra explanations.
- Obfuscation: Remove sensitive or unnecessary annotations before sharing code or submitting assignments.
Installation #
Prerequisites #
Ensure you have Dart installed. You can check by running:
dart --version
If Dart is not installed, follow the official installation guide.
Installing the Package #
- Clone this repository or download the source code:
git clone https://github.com/benouarAbdou/comments_remover_flutter_package cd comments_remover_flutter_package - Install dependencies:
dart pub get - Activate the package locally:
dart pub global activate --source path .
Usage #
Basic Usage #
Remove all comments from all Dart files in the lib directory:
dart run comments_remover
Command Options #
| Option | Description |
|---|---|
--path |
Specify a target file or directory to process. Defaults to lib/. |
--single-line |
Remove only single-line comments (//). |
--multi-line |
Remove only multi-line comments (/* */). |
Example Commands
-
Remove all comments from a specific file:
dart run comments_remover --path lib/main.dart -
Remove only single-line comments from all Dart files in
lib:dart run comments_remover --single-line -
Remove only multi-line comments from a specific directory:
dart run comments_remover --path lib/src --multi-line
Example Output #
Input File (Before): #
// This is a single-line comment
void main() {
/* This is a multi-line
comment */
print("Hello"); // Inline comment
}
Output File (After): #
void main() {
print("Hello");
}
Contributing #
We welcome contributions! Here’s how you can help:
- Fork the repository.
- Create a new branch for your feature or fix.
- Commit your changes with clear commit messages.
- Push to your fork and submit a Pull Request.
Feel free to open issues for bug reports, feature requests, or suggestions.
License #
This project is licensed under the MIT License. See the LICENSE file for more details.