dartgenx
A powerful and flexible Command Line Interface (CLI) tool for generating common Flutter/Dart boilerplate code directly into your project. Stop writing the same utility files over and over—let dartgenx handle the heavy lifting!
✨ Features
dartgenx offers both direct command execution and an interactive mode to quickly scaffold necessary services and utilities.
- ApiClient Service: Creates an
api_client.dartfile with dio api calling setup. - Assets Utility Generation: Creates an
assets_utils.dartfile with static paths for all resources in yourassetsfolder. - FCM Service Scaffold: Generates a standard
fcm_service.dartfor handling Firebase Cloud Messaging setup. - Refresh Token Service: Scaffolds a dedicated service for managing token refresh logic.
- Local Storage Service: Creates either
shared_preferences_service.dartorget_storage_service.dartto store data locally. - Sqflite Service: Creates an
sqflite_service.dartto store data locally. - Pagination Utilities: Creates both a
pagination_controller.dartand a reusablepaging_list_view.dartwidget. - Bloc Classes: Creates a basic bloc folder structure with
bloc.dart,state.dartandevent.dartfiles with boilerplate prewritten code. - Getx Classes: Creates a basic getx folder structure with
controller.dart,bindings.dartandscreens.dartfiles with boilerplate prewritten code. - Theme Classes: Creates a basic theme class with
app_colors.dart,app_theme.dartandapp_text_styles.dartfiles with boilerplate prewritten code. - Interactive Mode: Use the
dartgenx runcommand for a friendly menu-driven generation experience.
🚀 Installation
1. Activate the Package
Activate dartgenx globally using the Dart package manager. This makes the dartgenx command available anywhere on your system.
dart pub global activate dartgenx
2. Verify Installation
Run the help command to confirm dartgenx is installed and working correctly.
dartgenx --help
👨💻 Usage
There are two primary ways to use dartgenx: Direct Commands and the Interactive Run mode.
1. Interactive Mode (dartgenx run)
For generating multiple files at once or for a guided experience, use the run command.
dartgenx run
This will launch an interactive multi-select menu, allowing you to choose which services you want to generate.
? Select what you have to generate:
Generate ApiClient
Generate AssetsUtils
Generate FcmService
Generate RefreshToken service
Generate Local Storage service
Generate SqfliteService
Generate Pagination Service
Generate BLoC Service
Generate Getx Service
Generate App icons
Generate Theme class
2. Direct Commands
Use these commands for quick, single-purpose generation.
| Command | Description | Output File(s) |
|---|---|---|
dartgenx api_client |
Generates a boilerplate service for handling API calls. | lib/api_client.dart |
dartgenx assets |
Scans the assets folder and generates the assets utility file. | lib/assets_utils.dart |
dartgenx fcm |
Generates a boilerplate service for handling FCM. | lib/fcm_service.dart |
dartgenx refresh |
Generates the service for managing refresh token logic. | lib/refresh_token_service.dart |
dartgenx local_storage |
Generates shared_preferences or get_storage service. | lib/shared_preferences_service.dart & lib/get_storage_service.dart |
dartgenx sqflite |
Generates a sqflite singleton service. | lib/sqflite_service.dart |
dartgenx pagination |
Generates a controller and a reusable widget for paginated lists. | lib/pagination_controller.dart & lib/paging_list_view.dart |
dartgenx bloc |
Generate bloc directory which contains bloc.dart, state.dart, and event.dart in lib folder. | From where you run this command or the path you set |
dartgenx getx |
Generate getx directory which contains controllers, bindings, and views in a folder | From where you run this command or the path you set |
dartgenx app-icon |
Generate app icon of different sizes in platform specific folder. | The files are generated at platform specific folders. |
dartgenx theme |
Generate theme class in platform specific folder. | The files are generated at the path provided by you. |
General Help
To see the list of all available commands:
dartgenx --help
OR
dartgenx -h
General Version
To see current installed version on your device:
dartgenx --version
OR
dartgenx -v
Libraries
- dartgenx
- generators/api_client_generator
- generators/app_icon_generator
- generators/app_storage_generator
- generators/assets_generator
- generators/bloc_generator
- generators/fcm_generator
- generators/getx_generator
- generators/localization/generate_locale_keys
- generators/localization/generate_translation_files
- generators/localization/generate_translation_service
- generators/localization/ignore_rules
- generators/localization/replace_string_with_lkeys
- generators/pagination_generator
- generators/refresh_token_service_generator
- generators/sqflite_generator
- generators/theme_generator
- templates/api_client_template
- templates/app_icon_template
- templates/app_storage_template
- templates/bloc_template
- templates/fcm_template
- templates/getx_template
- templates/localization_service_template
- templates/pagination_template
- templates/refresh_token_service_template
- templates/sqflite_template
- templates/theme_template
- utils/console_log
- utils/project_utils
- utils/version_checker