kfx_dependency_injection 1.4.0 kfx_dependency_injection: ^1.4.0 copied to clipboard
Flutter Dependency Injection library based on dotnet ServiceProvider
1.0.0 #
- Initial fully functional release
1.0.0+1 #
- Fix issues with pub.dev publishing
1.0.0+2 #
- Downgrading Dart requirements to match pub.dev and refactoring project structure
1.0.0+3 #
- Added portuguese documentation as well as some fixes in the English README.md version
1.0.0+4 #
- Add platform info to
ServiceProvider
so injected classes can be chosen by platform as well
1.0.0+5 #
- Allows override of registrations (for unit test mocking purposes, for instance)
1.2.0 #
- Allows override of registrations even before the registrations take place
1.3.0 #
- Refactoring to separate write/query methods from
ServiceProvider
- Breaking change: write methods (i.e.:
registerTransient
) no longer requiresServiceProvider.instance
(they are now static methods) - Breaking change: During registration, a
IServiceProvider
is available only with query methods (isRegistered
,optional
andrequired
) - Breaking change: to avoid conflict with the
@override
attribute, theoverride
method was renamed toreplace
1.3.1 #
- Added
registerSingletonIfNotRegistered
andregisterTransientIfNotRegistered
to avoid throwing exceptions and making registration idempotent
1.3.1+1 #
- Fixed some grammar errors and refactored the barrel file to make import easier
1.4.0 #
- Breaking change: now
registerTransient
andregisterSingleton
have the following signature:(optional, required, platform)
, so you can inject optional and required services in a easier way:
ServiceProvider.registerTransient<SomeAbstractClass>(
(optional, required, platform) => SomeConcreteClassWithDependencies(
dependencyA: optional<DependencyA>(),
dependencyB: required<DependencyB>(),
platform: platform,
),
);
class SomeConcreteClassWithDependencies {
SomeConcreteClassWithDependencies({
this.dependencyA,
this.dependencyB,
this.platform,
});
final DependencyA dependencyA;
final DependencyB dependencyB;
final IPlatformInfo platform;
}
-
Also,
getService<T>()
was renamed tooptional<T>()
andgetRequiredService<T>()
was renamed torequired<T>()
. -
Now you can implement
IMustBeTransient
orIMustBeSingleton
in your services to validate the required type of registration (i.e.: a class that implementsIMustBeTransient
will throw aInvalidRegistrationModalForTypeException
, if you try to register it withServiceProvider.registerTransient<ClassThatImplementsIMustBeTransient>((optional, required, platform) => SomeClass())
)