flusgen
is a tool that helps you automatically generate folder and file structures for Flutter projects using the MVVM (Model-View-ViewModel) architecture pattern or Other. With this tool, you can quickly create predefined folders and files, as well as perform operations such as creating custom folders/files, renaming them, and deleting them.
test_demo_flusgen.mp4
This project is designed to simplify the setup of folder and file structures in Flutter projects. Using this tool, you can generate consistent folder and file structures following a specific architecture pattern (such as MVVM or Other). Additionally, you can customize the existing structure by adding, renaming, or deleting folders and files.
- ✅ Generate Structure: Automatically create a default folder and file structure based on predefined templates.
- ✅ Generate from File: Create a custom folder and file structure based on a
.json
file. - ✅ Create Custom Folder: Add custom folders after generating the default structure.
- ✅ Rename Folder: Rename existing folders within the project structure.
- ✅ Delete Folder: Remove folders from the project structure.
- ✅ Create Custom File: Add custom files within the project structure.
- ✅ Rename File: Rename existing files within the project structure.
- ✅ Delete File: Remove files from the project structure.
Run the following command in Command Prompt (CMD) to activate the package:
dart pub global activate flusgen
To run commands globally, add the following directory to your PATH
environment variable:
C:\Users\myaasiinh\AppData\Local\Pub\Cache\bin
-
Open Environment Variables:
- Press
Win + S
and search for "Environment Variables". - Click Edit the system environment variables.
- In the System Properties window, click Environment Variables.
- Press
-
Add PATH:
- Under System Variables, find the variable named
Path
and click Edit. - Click New, then enter:
C:\Users\myaasiinh\AppData\Local\Pub\Cache\bin
- Click OK to save changes.
- Under System Variables, find the variable named
-
Restart Terminal or IDE:
- Close the terminal (Command Prompt, PowerShell, or VS Code terminal) and reopen it to apply the configuration.
Generates the default folder and file structure:
flusgen generate-structure
Creates a custom folder after the default structure (Replace <folderPath>
with the desired folder path):
flusgen create-custom-folder <folderPath>
📌 Example:
flusgen create-custom-folder lib/features/authentication
Renames an existing folder:
flusgen rename-folder <oldPath> <newPath>
📌 Example:
flusgen rename-folder lib/features/authentication lib/features/login
Removes a folder from the project structure:
flusgen delete-folder <folderPath>
📌 Example:
flusgen delete-folder lib/features/login
Creates a custom file inside a specific folder:
flusgen create-custom-file <filePath> [content]
📌 Example:
flusgen create-custom-file lib/features/authentication/auth_service.dart
Renames a file within the project structure:
flusgen rename-file <oldPath> <newPath>
📌 Example:
flusgen rename-file lib/features/authentication/auth_service.dart lib/features/authentication/login_service.dart
Deletes a file from the project structure:
flusgen delete-file <filePath>
📌 Example:
flusgen delete-file lib/features/authentication/auth_service.dart
Generates a folder and file structure based on a .json
file, allowing for customization without relying on built-in templates.
flusgen generate-structure-from-json <filePath>
📌 Example:
flusgen generate-structure-from-json structure.json lib
{
"lib": {
"core": {
"config": ["main_app.dart"],
"global_component": ["global_widget.dart"],
"constants": ["string.dart", "color.dart", "images.dart"],
"utils": ["route_utils.dart"]
},
"data": {
"data1": {
"requests_model": ["data1_requests_model.dart"],
"responses_model": ["data1_responses_model.dart"],
"datasource": ["data1_data_source.dart"],
"repository": ["data1_repository.dart"],
"viewdatamodel": ["data1_view_datamodel.dart"]
}
},
"features": {
"features1": {
"": ["features_screen.dart"],
"widget": ["features1_widget.dart"],
"controller": ["features_controller.dart"]
}
}
}
}
Create a default folder and file structure:
flusgen generate-structure
Add a custom folder to the generated structure:
flusgen create-custom-folder lib/features/authentication
Rename the authentication
folder to login
:
flusgen rename-folder lib/features/authentication lib/features/login
Remove an unnecessary folder:
flusgen delete-folder lib/features/login
Add a custom file to the project structure:
flusgen create-custom-file lib/features/authentication/auth_service.dart
Rename auth_service.dart
to login_service.dart
:
flusgen rename-file lib/features/authentication/auth_service.dart lib/features/authentication/login_service.dart
Remove an unused file:
flusgen delete-file lib/features/authentication/auth_service.dart
Generate a custom folder and file structure from a .json
file:
flusgen generate-structure-from-json structure.json lib
If you would like to contribute to this project, feel free to submit a pull request. Follow these steps:
- Fork this repository.
- Create a new branch for your changes.
- Make your changes and ensure your code runs properly.
- Submit a pull request to merge your changes.
This project is licensed under the MIT License.
🎉 Enjoy using flusgen
! If you have any questions, feel free to ask! 🚀