mirror of
https://github.com/pese-git/cherrypick.git
synced 2026-01-23 21:13:35 +00:00
28 lines
590 B
Markdown
28 lines
590 B
Markdown
|
|
---
|
||
|
|
sidebar_position: 3
|
||
|
|
---
|
||
|
|
|
||
|
|
# Getting Started
|
||
|
|
|
||
|
|
Here is a minimal example that registers and resolves a dependency:
|
||
|
|
|
||
|
|
```dart
|
||
|
|
import 'package:cherrypick/cherrypick.dart';
|
||
|
|
|
||
|
|
class AppModule extends Module {
|
||
|
|
@override
|
||
|
|
void builder(Scope currentScope) {
|
||
|
|
bind<ApiClient>().toInstance(ApiClientMock());
|
||
|
|
bind<String>().toProvide(() => "Hello, CherryPick!");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
final rootScope = CherryPick.openRootScope();
|
||
|
|
rootScope.installModules([AppModule()]);
|
||
|
|
|
||
|
|
final greeting = rootScope.resolve<String>();
|
||
|
|
print(greeting); // prints: Hello, CherryPick!
|
||
|
|
|
||
|
|
await CherryPick.closeRootScope();
|
||
|
|
```
|