ub_code_structure
ub_code_structure is a Flutter package that helps you quickly scaffold a clean, modular GetX project structure.
It includes two CLI commands:
init: copies starter architecture files into your project.create: generates a new feature module with bindings, controller, and view (plus optional model/repository).
Features
- Bootstrap project folders/files under
lib/for a structured app setup. - Generate feature modules using snake_case, kebab-case, PascalCase, or spaced names.
- Optional
--with-modeland--with-repositorygeneration. - Safe generation with
--dry-runpreview and--forceoverwrite options. - Optional flat mode (
--flat) to generate module files without subfolders.
Getting Started
1) Add the package
dev_dependencies:
ub_code_structure: ^0.0.1
Then run:
flutter pub get
2) Initialize base structure
Run this inside your Flutter app project root:
dart run ub_code_structure:init
This command copies package starter files into your project lib/ and tries to add required dependencies.
Usage
Create a module
dart run ub_code_structure:create product
More examples
dart run ub_code_structure:create user_profile --with-model --with-repository
dart run ub_code_structure:create ProductDetail --dry-run
dart run ub_code_structure:create ProductDetail --flat
dart run ub_code_structure:create ProductDetail --flat --force
dart run ub_code_structure:create auth/registration
Generated module layout (default)
lib/features/product/
bindings/product_binding.dart
controllers/product_controller.dart
views/product_view.dart
models/product_model.dart # if --with-model
repository/product_repository.dart # if --with-repository
Generated module layout (--flat)
lib/features/product/
product_binding.dart
product_controller.dart
product_view.dart
product_model.dart # if --with-model
product_repository.dart # if --with-repository
Command Options
create
-m,--with-model: generate<module>_model.dart-r,--with-repository: generate<module>_repository.dart--dry-run: show planned folders/files without writing-o,--force: allow overwrite when module folder exists-f,--flat: generate files directly in module root-h,--help: print help output
Notes
createprints route snippets you can add manually to your app routing files.- The generator uses GetX-based templates (
Bindings,GetxController,GetView).
Publishing on pub.dev Checklist
Before publishing, make sure:
pubspec.yamlhas finaldescription,homepage/repository, and semantic version.CHANGELOG.mdincludes release notes for the new version.LICENSEis present.- Example app or usage in
example/works. dart pub publish --dry-runpasses without warnings.
Additional Information
- Report issues and feature requests in your repository issue tracker.
- Keep templates backward compatible when possible, since they are copied into consumer projects.
- Update version and changelog for every published release.
Libraries
- api
- app/api/api_state
- app/api/curl_logger_interceptor
- app/api/end_point
- app/api/endpoint_http_type
- app/api/map_string_dynamic_extension
- app/api/network_response_object
- app/api/web_service_helper
- app/models/product_model
- app/routes/app_pages
- app/routes/app_routes
- app/services/auth_service
- app/services/permission_service
- app/services/storage_service
- app/theme/app_colors
- app/theme/app_theme
- app/utils/constants
- app/utils/extensions
- app/utils/helpers
- app/utils/logger
- app/utils/show_tost
- app/utils/utils
- app/utils/validators
- features/auth/login/bindings/login_binding
- features/auth/login/controllers/login_controller
- features/auth/login/views/login_view
- features/auth/registration/bindings/registration_binding
- features/auth/registration/controllers/registration_controller
- features/auth/registration/views/registration_view
- features/dashboard/dashboard_binding
- features/dashboard/dashboard_controller
- features/dashboard/dashboard_view
- features/splash/splash_bindings
- features/splash/splash_controller
- features/splash/splash_view
- ub_code_structure
- widget/app_empty_state
- widget/app_loading_indicator
- widget/app_section_title
- widget/app_text_input