Dependency injection
Service locator package based on GetIt. with easy configuration and better focus on dependency injection error handling.
- support for the scopes
- enviormental overrides
- async initialization
- error handler
- di initialization tree
Installation
if you are using eli generated app then you have everything ready to use, otherwise install package with command.
dart pub add eit_injection -u https://gitea.prntes.space/api/packages/platform/pub/
!IMPORTANT You need access token for fetching from private pub repository. ELI add token automatically
Usage
Pre-requsities
- Current project is based on Embedit Platform
- supports clean architecture defined by Platform.
- use same folder structure and name conventions
Feature
Every single feature is responsible for a definition of dependencies
folder structure
├── lib
│ ├── config
│ │ ├── di
│ │ │ │ # App Service Locator registration
│ │ │ ├── injection.dart
│ ├── features
│ │ ├── custom
│ │ │ ├── config
│ │ │ │ ├── di
│ │ │ │ │ │ # Feature Service Locator definition
│ │ │ │ │ ├── custom_injection.dart
│ ├── ...
└── ...
you can use Embedit CLI
eit template feature
How to register dependencies
if you successfuly generate a new feature with name custom
then you should go to the lib/features/custom/config/di/custom_injection.dart
end add your dependencies defined by feature.
class CustomInjection extends InjectableFeature{
@override
Future<void> preRegister(){
registerFactory<UserBox>(UserBox())
}
@override
void register(){
...
}
@override
void postRegiser(){
...
}
}
How to register Feature in your app?
Ok, we have defined a new feature with name Custom
and now we want to register all dependencies from the new feature in the application.
edit file lib/config/di/injection.dart
...
final injection = Injection(
(GetIt di) => {
/// Add New Feature Injection
CustomInjection(di),
},
binding,
di: locator,
);
...
Note:
eit create app
will create a new app with proper structure
Feature flags
This package aims to create an implementation of FLAGD http2 provider based on package openfeature.
Keycloak
This Flutter plugin provides federated authentication for Android, iOS, and Web. It uses AppAuth for native (Android and iOS) applications and the Keycloak JavaScript adapter for web integration, offering seamless authentication across platforms.