A VS Code extension to streamline creating feature folders, use cases, Bloc, and Cubit files for Flutter projects using Clean Architecture.
Features
This extension provides the following functionalities:
Create Feature Folders: Automatically generates the folder structure for a new feature following Clean Architecture principles.
After entering the feature name, you'll be asked whether to include Injectable annotations (@LazySingleton) in the generated files (since version 1.5.0).
Create Use Case: Quickly create a use case within an existing feature.
Create Bloc (NEW in 1.6.0): Generates a Bloc class with a template structure inside the selected feature.
Create Cubit (NEW in 1.6.0): Generates a Cubit class with a template structure inside the selected feature.
Commands
The following commands are available in the Command Palette (Ctrl+Shift+P or Cmd+Shift+P on macOS) under the Arch category:
1. Create Feature Folders
Command:Create Feature Folders
Description: Generates the Clean Architecture folder structure for a new feature in your project.
Usage:
Open the Command Palette and run the Create Feature Folders command.
Enter a feature name (e.g., auth, home).
Choose whether you want Injectable annotations added (available from version 1.5.0).
The following folder structure will be generated:
lib/
features/
feature_name/
domain/
entities/
repo/ // or repository/ based on your setup
usecases/
data/
datasources/
remote/
models/
repo/
presentation/
blocs/
pages/
widgets/
2. Create Use Case
Command:Create Use Case
Description: Adds a use case class to a specified feature’s domain/usecases folder.
Usage:
Open the Command Palette and run Create Use Case.
Enter the feature name (must already exist).
Enter the use case name (e.g., FetchUserData), and a file with the following template will be created:
import 'package:dartz/dartz.dart';
import 'package:injectable/injectable.dart';
@lazySingleton
class FetchUserDataUseCase {
final Repo _repo;
FetchUserDataUseCase(this._repo);
Future<Either<Failure, Entity>> call() async =>
await _repo.doSomething();
}
3. Create Bloc (NEW in 1.6.0)
Command:Create Bloc
Description: Generates a Bloc class (state, event, and bloc files) inside the selected feature’s presentation/blocs folder.
4. Create Cubit (NEW in 1.6.0)
Command:Create Cubit
Description: Generates a Cubit class (state and cubit files) inside the selected feature’s presentation/blocs folder.