module_generator
module_generator is a simple CLI tool to generate GetX modules (Controller, Page, Binding, Routes, and Pages) automatically.
With just one command, you get a clean folder structure and boilerplate code ✅.
✨ Features
- Generate a complete GetX module (Controller, Page, Binding, Index).
- Automatically updates:
import_all.dartgetx/routes.dartgetx/pages.dart
- Keeps your project structure clean and consistent.
- Usable directly from the terminal.
📦 Installation
Global activation
Activate the package globally:
dart pub global activate module_generator
Make sure the pub cache bin directory is in your PATH:
-
Linux / macOS
Add this line to your~/.bashrcor~/.zshrc:export PATH="$PATH":"$HOME/.pub-cache/bin" -
Windows (PowerShell)
Add this line to your$PROFILE:$env:Path += ";$env:APPDATA\Pub\Cache\bin"
Verify the installation:
module_generator --help
🚀 Usage
Generate a new module
module_generator <moduleName> <ROUTE_NAME> </routePath>
Example:
module_generator home HOME /home
This will create:
lib/
└─ modules/
└─ home/
├─ home_controller.dart
├─ home_page.dart
├─ home_binding.dart
└─ home.dart
Additionally:
lib/import_all.dart→ automatically updated with module exportlib/getx/routes.dart→ automatically updated with the new routelib/getx/pages.dart→ automatically updated with a newGetPageentry
📂 Example Output
home_controller.dart
import 'package:android/import_all.dart';
class HomeController extends GetxController {
// TODO: Implement HomeController
}
home_page.dart
import 'package:android/import_all.dart';
class HomePage extends GetView<HomeController> {
const HomePage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Home')),
body: const Center(child: Text('Home View')),
);
}
}
🛠️ Development
Clone this repository:
git clone https://github.com/abhu66/module_generator.git
cd module_generator
Activate locally:
dart pub global activate --source path .
Test:
module_generator test TEST /test
Support the Project
If you find this plugin helpful, consider supporting its development:
Your support is greatly appreciated!
📄 License
MIT License. See the LICENSE file for details.