-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/openapi-lint
- Loading branch information
Showing
15 changed files
with
375 additions
and
74 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
catalyst_voices/packages/catalyst_voices_blocs/lib/src/catalyst_voices_blocs.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export 'authentication/authentication.dart'; | ||
export 'dependency/dependency.dart'; | ||
export 'login/login.dart'; |
46 changes: 46 additions & 0 deletions
46
catalyst_voices/packages/catalyst_voices_blocs/lib/src/dependency/dependency.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import 'package:catalyst_voices_blocs/catalyst_voices_blocs.dart'; | ||
import 'package:catalyst_voices_blocs/src/dependency/dependency_provider.dart'; | ||
import 'package:catalyst_voices_repositories/catalyst_voices_repositories.dart'; | ||
import 'package:catalyst_voices_services/catalyst_voices_services.dart'; | ||
|
||
final class Dependency extends DependencyProvider { | ||
static final Dependency instance = Dependency._(); | ||
|
||
Dependency._(); | ||
|
||
Future<void> init() async { | ||
_registerServices(); | ||
_registerRepositories(); | ||
_registerBlocsWithDependencies(); | ||
} | ||
|
||
void _registerBlocsWithDependencies() { | ||
this | ||
..registerSingleton<AuthenticationBloc>( | ||
AuthenticationBloc( | ||
authenticationRepository: get(), | ||
), | ||
) | ||
..registerLazySingleton<LoginBloc>( | ||
() => LoginBloc( | ||
authenticationRepository: get(), | ||
), | ||
); | ||
} | ||
|
||
void _registerRepositories() { | ||
this | ||
..registerSingleton<CredentialsStorageRepository>( | ||
CredentialsStorageRepository(secureStorageService: get()), | ||
) | ||
..registerSingleton<AuthenticationRepository>( | ||
AuthenticationRepository(credentialsStorageRepository: get()), | ||
); | ||
} | ||
|
||
void _registerServices() { | ||
registerSingleton<SecureStorageService>( | ||
SecureStorageService(), | ||
); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
catalyst_voices/packages/catalyst_voices_blocs/lib/src/dependency/dependency_provider.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:get_it/get_it.dart'; | ||
|
||
abstract class DependencyProvider { | ||
static final getIt = GetIt.instance; | ||
|
||
static Future<void> get reset => getIt.reset(); | ||
|
||
@protected | ||
Future<void> allReady() { | ||
return getIt.allReady(); | ||
} | ||
|
||
T get<T extends Object>() => getIt.get<T>(); | ||
|
||
Future<T> getAsync<T extends Object>() => getIt.getAsync<T>(); | ||
|
||
T getWithParam<T extends Object, P extends Object>({P? param}) { | ||
return getIt.get<T>(param1: param); | ||
} | ||
|
||
@protected | ||
void registerFactory<T extends Object>(ValueGetter<T> factoryFunc) { | ||
getIt.registerFactory(factoryFunc); | ||
} | ||
|
||
@protected | ||
void registerLazySingleton<T extends Object>( | ||
ValueGetter<T> factoryFunc, { | ||
DisposingFunc<T>? dispose, | ||
}) { | ||
getIt.registerLazySingleton( | ||
factoryFunc, | ||
dispose: dispose, | ||
); | ||
} | ||
|
||
@protected | ||
void registerSingleton<T extends Object>(T instance) { | ||
getIt.registerSingleton(instance); | ||
} | ||
|
||
@protected | ||
void registerSingletonAsync<T extends Object>( | ||
ValueGetter<Future<T>> factoryFunc, { | ||
Iterable<Type>? dependsOn, | ||
}) { | ||
getIt.registerSingletonAsync( | ||
factoryFunc, | ||
dependsOn: dependsOn, | ||
); | ||
} | ||
|
||
@protected | ||
void registerSingletonWithDependencies<T extends Object>( | ||
FactoryFunc<T> factoryFunc, { | ||
required List<Type> dependsOn, | ||
}) { | ||
getIt.registerSingletonWithDependencies( | ||
factoryFunc, | ||
dependsOn: dependsOn, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.