module_generator (GetX CLI Tool)

module_generator (GetX CLI Tool)

Sep 24, 2025

🔥 New Flutter Package: module_generator (GetX CLI Tool)

image

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.dart

    • getx/routes.dart

    • getx/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 ~/.bashrc or ~/.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 export

  • lib/getx/routes.dart → automatically updated with the new route

  • lib/getx/pages.dart → automatically updated with a new GetPage entry


📂 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
Gefällt dir dieser Beitrag?

Kaufe ABU KHOERUL IA einen Kaffee

Mehr von ABU KHOERUL IA

DatenschutzNutzungsbedingungenMelden