// "Lightweight Flutter enterprise development skill focused on feature-based clean architecture. Use when user asks to: (1) Build enterprise Flutter apps with clean architecture, (2) Implement feature-based modular structure, (3) Set up scalable Flutter project organization, (4) Create maintainable enterprise codebase. Triggers: Flutter enterprise app, clean architecture Flutter, feature-based Flutter, enterprise Flutter structure, modular Flutter architecture"
| name | flutter-enterprise |
| description | Lightweight Flutter enterprise development skill focused on feature-based clean architecture. Use when user asks to: (1) Build enterprise Flutter apps with clean architecture, (2) Implement feature-based modular structure, (3) Set up scalable Flutter project organization, (4) Create maintainable enterprise codebase. Triggers: Flutter enterprise app, clean architecture Flutter, feature-based Flutter, enterprise Flutter structure, modular Flutter architecture |
Lightweight Flutter development skill for building enterprise applications using feature-based clean architecture patterns.
"Feature-first, testable, maintainable enterprise code" - Focus on:
| Priority | Area | Purpose |
|---|---|---|
| 1 | Feature-Based Structure | Modular, scalable code organization |
| 2 | Clean Architecture | Separation of concerns and testability |
| 3 | Dependency Injection | Loose coupling and maintainability |
| 4 | Enterprise Patterns | Proven enterprise development practices |
| 5 | Code Generation | Boilerplate reduction and consistency |
Execute phases sequentially. Complete each before proceeding.
Output: Feature breakdown with dependency mapping.
Output: Feature architecture diagram and data contracts.
Feature Structure Pattern:
lib/
โโโ core/
โ โโโ constants/
โ โโโ errors/
โ โโโ network/
โ โโโ utils/
โ โโโ widgets/
โโโ features/
โ โโโ feature_name/
โ โ โโโ data/
โ โ โ โโโ datasources/
โ โ โ โโโ models/
โ โ โ โโโ repositories/
โ โ โโโ domain/
โ โ โ โโโ entities/
โ โ โ โโโ repositories/
โ โ โ โโโ usecases/
โ โ โโโ presentation/
โ โ โโโ pages/
โ โ โโโ widgets/
โ โ โโโ providers/
โ โโโ ...
โโโ main.dart
Clean Architecture Implementation:
// Domain Layer - Entity
class User {
final String id;
final String name;
final String email;
User({required this.id, required this.name, required this.email});
}
// Domain Layer - Repository (Abstract)
abstract class UserRepository {
Future<List<User>> getUsers();
Future<User> getUserById(String id);
}
// Domain Layer - Use Case
class GetUsersUseCase {
final UserRepository repository;
GetUsersUseCase(this.repository);
Future<List<User>> call() async {
return await repository.getUsers();
}
}
// Data Layer - Repository Implementation
class UserRepositoryImpl implements UserRepository {
final RemoteDataSource remoteDataSource;
UserRepositoryImpl(this.remoteDataSource);
@override
Future<List<User>> getUsers() async {
final userModels = await remoteDataSource.getUsers();
return userModels.map((model) => model.toEntity()).toList();
}
}
| Layer | Responsibility | Key Components |
|---|---|---|
| Presentation | UI and State Management | Pages, Widgets, Providers/Bloc |
| Domain | Business Logic | Entities, Use Cases, Repository Interfaces |
| Data | Data Implementation | Models, Data Sources, Repository Implementations |
// main.dart
void main() {
// Initialize dependencies
final serviceLocator = GetIt.instance;
// Data sources
serviceLocator.registerLazySingleton<RemoteDataSource>(
() => RemoteDataSourceImpl(httpClient: serviceLocator()));
// Repositories
serviceLocator.registerLazySingleton<UserRepository>(
() => UserRepositoryImpl(serviceLocator()));
// Use cases
serviceLocator.registerFactory<GetUsersUseCase>(
() => GetUsersUseCase(serviceLocator()));
runApp(MyApp());
}
This skill now supports state management neutrality with equivalent implementations for all four major approaches:
// Presentation Layer - Provider
class UserProvider extends ChangeNotifier {
final GetUsersUseCase getUsersUseCase;
List<User> _users = [];
bool _isLoading = false;
UserProvider({required this.getUsersUseCase});
List<User> get users => _users;
bool get isLoading => _isLoading;
Future<void> loadUsers() async {
_isLoading = true;
notifyListeners();
try {
_users = await getUsersUseCase();
} catch (e) {
// Handle error
} finally {
_isLoading = false;
notifyListeners();
}
}
}
// Presentation Layer - Bloc
abstract class UserEvent extends Equatable {}
class LoadUsers extends UserEvent {}
abstract class UserState extends Equatable {}
class UserLoading extends UserState {}
class UserLoaded extends UserState {
final List<User> users;
UserLoaded(this.users);
@override
List<Object> get props => [users];
}
class UserBloc extends Bloc<UserEvent, UserState> {
final GetUsersUseCase getUsersUseCase;
UserBloc({required this.getUsersUseCase}) : super(UserInitial()) {
on<LoadUsers>(_onLoadUsers);
}
Future<void> _onLoadUsers(LoadUsers event, Emitter<UserState> emit) async {
emit(UserLoading());
try {
final users = await getUsersUseCase();
emit(UserLoaded(users));
} catch (e) {
// Handle error
}
}
}
// Presentation Layer - Riverpod
class UserNotifier extends StateNotifier<AsyncValue<List<User>>> {
final GetUsersUseCase getUsersUseCase;
UserNotifier({required this.getUsersUseCase}) : super(const AsyncValue.loading());
Future<void> loadUsers() async {
state = const AsyncValue.loading();
try {
final users = await getUsersUseCase();
state = AsyncValue.data(users);
} catch (e, stackTrace) {
state = AsyncValue.error(e, stackTrace);
}
}
}
final userProvider = StateNotifierProvider<UserNotifier, AsyncValue<List<User>>>((ref) {
return UserNotifier(getUsersUseCase: ref.watch(getUsersUseCaseProvider));
});
// Presentation Layer - GetX
class UserController extends GetxController {
final GetUsersUseCase getUsersUseCase;
UserController({required this.getUsersUseCase});
final RxList<User> _users = <User>[].obs;
final RxBool _isLoading = false.obs;
List<User> get users => _users;
bool get isLoading => _isLoading.value;
Future<void> loadUsers() async {
_isLoading.value = true;
try {
final userList = await getUsersUseCase();
_users.assignAll(userList);
} catch (e) {
// Handle error
} finally {
_isLoading.value = false;
}
}
}
// Page Example with GetX
class UserListPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return GetBuilder<UserController>(
init: UserController(getUsersUseCase: Get.find()),
builder: (controller) {
return Scaffold(
appBar: AppBar(title: Text('Users')),
body: Obx(() {
if (controller.isLoading.value) {
return Center(child: CircularProgressIndicator());
}
return ListView.builder(
itemCount: controller.users.length,
itemBuilder: (context, index) {
final user = controller.users[index];
return UserTile(user: user);
},
);
}),
);
},
);
}
}
references/clean-architecture.mdreferences/feature-templates.mdreferences/testing-patterns.mdreferences/code-generation.mdThis Flutter enterprise skill transforms complex enterprise app development into a systematic process that ensures maintainable, scalable, and testable applications using feature-based clean architecture.