clean_fold 0.0.1
clean_fold: ^0.0.1 copied to clipboard
Flutter CLI to scaffold clean architecture features with BLoC, domain, infrastructure & presentation layers.
clean_fold #
A Dart CLI tool to scaffold Flutter clean architecture features instantly with a single command.
Installation #
dart pub global activate clean_fold
Usage #
clean_fold create <feature_name>
Examples #
clean_fold create auth
clean_fold create user_profile
clean_fold create home_screen
Feature names must be snake_case (e.g. auth, user_profile).
Generated Structure #
Running clean_fold create auth generates:
lib/src/features/auth/
├── application/
│ └── auth_bloc/
│ ├── auth_bloc.dart
│ ├── auth_event.dart
│ └── auth_state.dart
├── domain/
│ └── i_auth_repository.dart
├── infrastructure/
│ └── auth_repository.dart
└── presentation/
├── screens/
└── widgets/
Generated File Contents #
auth_bloc.dart #
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
part 'auth_event.dart';
part 'auth_state.dart';
class AuthBloc extends Bloc<AuthEvent, AuthState> {
AuthBloc() : super(const AuthState());
}
auth_event.dart #
part of 'auth_bloc.dart';
sealed class AuthEvent extends Equatable {
const AuthEvent();
@override
List<Object> get props => [];
}
auth_state.dart #
part of 'auth_bloc.dart';
class AuthState extends Equatable {
const AuthState();
@override
List<Object?> get props => [];
AuthState copyWith() {
return const AuthState();
}
}
i_auth_repository.dart #
abstract class IAuthRepository {}
auth_repository.dart #
// import 'package:injectable/injectable.dart';
import '../domain/i_auth_repository.dart';
// @LazySingleton(as: IAuthRepository)
class AuthRepository implements IAuthRepository {}
Injectable Support #
The @LazySingleton annotation and its import are commented out by default.
When you add injectable to your project, simply uncomment them:
import 'package:injectable/injectable.dart';
import '../domain/i_auth_repository.dart';
@LazySingleton(as: IAuthRepository)
class AuthRepository implements IAuthRepository {}
Path Resolution #
- If
lib/exists in the current directory → generates underlib/src/features/ - Otherwise → falls back to
features/in the current directory
Overwrite Protection #
If the feature folder already exists, you'll be prompted to confirm before overwriting.