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
Ti piace questo post?

Offri un caffè a ABU KHOERUL IA

Altro da ABU KHOERUL IA

PrivacyTerminiRapporto