packed 0.1.3
packed: ^0.1.3 copied to clipboard
A CLI tool to rapidly generate Flutter feature structures following the BLoC pattern.
Packed CLI 📦 #
A Simple Flutter CLI tool to rapidly generate feature structures following the BLoC pattern. Stop wasting time creating folders and boilerplate files manually.
🚀 Features #
- Instant Feature Generation: Creates a complete feature folder structure in seconds.
- BLoC/Cubit Ready: Generates Cubit, State (with Equatable), Page, and View files.
- Best Practices: Follows a clean architecture approach with a clear separation between UI and Logic.
- Smart Templates: Includes
copyWith,props, and standardisLoading/errorstates out of the box.
📂 Generated Structure #
When you run packed generate feature login, it creates:
lib/features/login/
├── cubit/
│ ├── login_cubit.dart
│ └── login_state.dart
├── page/
│ ├── login_page.dart
│ └── login_view.dart
└── widget/ (empty directory for your components)
🛠️ Installation #
Install Packed CLI from pub.dev:
dart pub global activate packed
Alternatively, you can install it directly from GitHub:
dart pub global activate --source git https://github.com/Ahmedx44/packed
📖 Usage #
Generate a New Feature #
To generate a new feature, run:
packed generate feature <feature_name>
Example:
packed generate feature profile
📝 Templates #
State Template #
The generated state includes isLoading and error fields by default, along with copyWith and Equatable integration:
class ProfileState extends Equatable {
final bool isLoading;
final String? error;
const ProfileState({
this.isLoading = false,
this.error,
});
ProfileState copyWith({
bool? isLoading,
String? error,
}) {
return ProfileState(
isLoading: isLoading ?? this.isLoading,
error: error ?? this.error,
);
}
@override
List<Object?> get props => [isLoading, error];
}
Page & View Template #
- Page: Handles
BlocProviderinitialization. - View: Contains the
ScaffoldandBlocBuilderboilerplate.
🤝 Contributing #
Feel free to open issues or submit pull requests to improve the templates or add new commands!
📄 License #
This project is licensed under the MIT License - see the LICENSE file for details.