Open
Conversation
Allows creating components in subdirectories for better organization: Examples: - stacked create view sales/dashboard - stacked create service api/auth - stacked create dialog alerts/error - stacked create bottom_sheet forms/client_info - stacked create widget charts/sales_graph This enhancement maintains full backward compatibility while enabling domain-driven directory structures. Implementation: - Parse path syntax (domain/component) in all create commands - Extract subfolder from input (e.g., 'sales/dashboard' -> subfolder: 'sales', name: 'dashboard') - Updated template_service to inject subfolders into output paths - Support for views, services, dialogs, bottom_sheets, and widgets Benefits: - Better code organization by domain/feature - Maintains Stacked framework compatibility - No breaking changes - backward compatible - Comprehensive README documentation with examples
When creating a view with a subfolder (e.g., 'test/dashboard'), the CLI was creating files in the correct location (lib/ui/views/test/dashboard/) but generating incorrect import paths in app.dart (pointing to lib/ui/views/dashboard/ without the subfolder). Changes: - Modified RenderFunction typedef to accept optional subfolder parameter - Updated kTemplateNameView render function to generate viewFolderName with subfolder path - Modified getTemplateRenderData() to pass subfolder to render functions - Updated all render function signatures for consistency This ensures that the generated import statement includes the full subfolder path: - Before: import 'package:app/ui/views/dashboard/dashboard_view.dart'; - After: import 'package:app/ui/views/test/dashboard/dashboard_view.dart'; Fixes build_runner error: "Route must have either a page or a redirect destination"
When using Mustache templates, the {{variable}} syntax (2 braces) automatically escapes HTML entities, converting forward slashes (/) to /. This caused invalid import statements for views, dialogs, and bottom sheets created with subfolders.
Changes:
- Modified 4 template JSON files to use {{{variable}}} (3 braces) instead of {{variable}} for folder names
- Files updated:
* view/empty/modifications/add_route_import.json
* view/web/modifications/add_route_import.json
* dialog/empty/modifications/add_dialog_import.json
* bottom_sheet/empty/modifications/add_bottom_sheet_import.json
- Recompiled templates to regenerate compiled_template_map.dart
Before:
import 'package:app/ui/views/test/dashboard/dashboard_view.dart'; ❌
After:
import 'package:app/ui/views/test/dashboard/dashboard_view.dart'; ✅
This fix ensures that imports with subfolders are valid Dart code and can be resolved by build_runner.
Applied the same subdirectory parsing logic from create commands to all delete commands, ensuring consistent handling of subfolder paths. Changes: - Modified 4 delete command files to parse and handle subfolder paths - Files updated: * delete_view_command.dart * delete_service_command.dart * delete_dialog_command.dart * delete_bottomsheet_command.dart Implementation: - Parse input path (e.g., 'test/dashboard') to extract subfolder and name - Pass subfolder parameter to getTemplateOutputPath() calls - Updated method signatures to accept optional subfolder parameter - Added documentation for subfolder parameters Before: stacked delete view test/dashboard → Error: PathNotFoundException: 'lib/ui/views/test_dashboard/' ❌ After: stacked delete view test/dashboard → Deletes 'lib/ui/views/test/dashboard/' ✅ This completes the subdirectory support feature, making create and delete commands symmetric.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎯 Feature: Subdirectory Support for Domain-Driven Organization
This PR adds support for organizing views, services, dialogs, and bottom sheets in subdirectories using a simple slash notation.
✨ What's New
Create commands now support subdirectories:
Delete commands also support subdirectories:
📁 Generated Structure
🔧 Technical Implementation
sales/dashboardintoname="dashboard"andsubfolder="sales"{{{...}}}(triple braces) to prevent HTML encoding of slashespackage:app/ui/views/sales/dashboard/dashboard_view.darthome) still work exactly as before📝 Changes
Modified Commands (7 files):
create_view_command.dartcreate_service_command.dartcreate_dialog_command.dartcreate_bottom_sheet_command.dartdelete_view_command.dartdelete_service_command.dartdelete_dialog_command.dartdelete_bottomsheet_command.dartModified Templates (4 files):
view/empty/modifications/add_route_import.jsonview/web/modifications/add_route_import.jsondialog/empty/modifications/add_dialog_import.jsonbottom_sheet/empty/modifications/add_bottom_sheet_import.json✅ Testing
Tested end-to-end in production apps:
test/dashboardtest/dashboard🎉 Benefits
📚 Related Commits