Register it in three layers, following the skill’s DI rules: 1. Put third-party dependencies like `Dio` and Hive objects behind an `@module` 2. Register the repository as a `@LazySingleton`, because repositories should usually be shared and initialized on demand 3. Inject the repository through its abstraction, not the concrete class Example: ```dart import 'package:dio/dio.dart'; import 'package:hive/hive.dart'; import 'package:injectable/injectable.dart'; abstract class IOrderRepository { F...
Scanned 9/5/2026
Install to Claude Code
npx -y skills add HoangNguyen0403/agent-skills-standard --skill flutter-dependency-injection --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of Flutter Dependency Injection?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/hoangnguyen0403-flutter-dependency-injection-agent-skills-standard)More formats (shields.io, HTML) on the badges page.
Register it in three layers, following the skill’s DI rules:
1. Put third-party dependencies like `Dio` and Hive objects behind an `@module`
2. Register the repository as a `@LazySingleton`, because repositories should usually be shared and initialized on demand
3. Inject the repository through its abstraction, not the concrete class
Example:
```dart
import 'package:dio/dio.dart';
import 'package:hive/hive.dart';
import 'package:injectable/injectable.dart';
abstract class IOrderRepository {
Future<void> submitOrder();
}
class OrderEntity {}
@module
abstract class DataModule {
@lazySingleton
Dio get dio => Dio(
BaseOptions(baseUrl: 'https://api.example.com'),
);
@preResolve
Future<Box<OrderEntity>> get orderBox async {
return await Hive.openBox<OrderEntity>('orders');
}
}
@LazySingleton(as: IOrderRepository)
class OrderRepository implements IOrderRepository {
final Dio _dio;
final Box<OrderEntity> _orderBox;
OrderRepository(this._dio, this._orderBox);
@override
Future<void> submitOrder() async {
// use _dio for remote calls
// use _orderBox for local persistence/cache
}
}
```
Why this matches the skill:
- `@module` is the right place for external dependencies you cannot annotate directly
- `@LazySingleton` is the default choice for repositories and data sources
- `as: IOrderRepository` keeps consumers dependent on the interface instead of the implementation
- constructor injection keeps the dependency graph explicit and testable
If you want a cleaner boundary around Hive, an even better version is to wrap the box in a local data source and inject that instead of injecting `Box<OrderEntity>` directly:
```dart
abstract class IOrderLocalDataSource {}
@LazySingleton(as: IOrderLocalDataSource)
class HiveOrderLocalDataSource implements IOrderLocalDataSource {
final Box<OrderEntity> box;
HiveOrderLocalDataSource(this.box);
}
@LazySingleton(as: IOrderRepository)
class OrderRepository implements IOrderRepository {
final Dio _dio;
final IOrderLocalDataSource _local;
OrderRepository(this._dio, this._local);
}
```
That version is usually easier to mock and keeps Hive-specific details out of the repository contract.
After adding the annotations, regenerate the injectable code so `get_it` picks up the new registrations. The key idea is: module for `Dio` and Hive, `@LazySingleton` for the repository, and inject the interface everywhere else.

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.
No comments yet. Be the first to comment!