0 purchases
dependency scope
Dependency Scope #
Dependency Scope is a Flutter package designed to facilitate the use of Dependency Injection (DI) in Flutter projects.
This package provides a straightforward way to manage dependencies, improving code modularity and testability.
Features #
Simplifies dependency injection setup in Flutter applications.
Enhances code maintainability and readability.
Supports easy and efficient management of app-wide dependencies.
Installation #
Add the following to your pubspec.yaml file:
dependencies:
dependency_scope: ^1.1.0
copied to clipboard
Getting started #
Setup: Initialize the DependencyScope in your main app file.
Register Dependencies: Register your dependencies in the DependencyScope.
Inject Dependencies: Use the provided methods to inject dependencies where needed.
Usage #
Include short and useful examples for package users. Add longer examples
to /example folder.
final class AppDependency extends DependencyScope {
late final String title;
@override
Future<void> initialization() async {
title = await create(() => 'Flutter DI');
}
}
copied to clipboard
And
class App extends StatelessWidget {
final AppDependency appDependency;
const App({super.key, required this.appDependency});
@override
Widget build(BuildContext context) {
return DependencyProvider<AppDependency>(
dependency: appDependency,
child: const MaterialApp(
home: MyHomePage(),
),
);
}
}
copied to clipboard
After this you can use DI with context extension
final appDependency = context.get<AppDependency>();
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.