Skip to content

Commit

Permalink
readme: Add get_it ViewModelFactory sample to README
Browse files Browse the repository at this point in the history
  • Loading branch information
okmanideep committed Dec 13, 2023
1 parent 92392a0 commit 81836fd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 1.0.4
* Updated installation, usage and setup in README

## 1.0.3
### Fixes
* Fix: Avoid `setState` being inside `initState` of `LiveDataBuilder` and `LiveDataListener`
Expand Down
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ A set of abstractions, utilities inspired from Android Jetpack 🚀 to help mana

<p>
<a href="https://github.com/praja/jetpack/blob/main/LICENSE"><img src="https://img.shields.io/badge/LICENSE-BSD%203-green" /></a>
<a href="https://pub.dev/packages/jetpack"><img src="https://img.shields.io/badge/pub-v1.0.3-blue" /></a>
<a href="https://pub.dev/packages/jetpack"><img src="https://img.shields.io/badge/pub-v1.0.4-blue" /></a>
</p>

## Features
Expand Down Expand Up @@ -64,7 +64,7 @@ FloatingActionButton(
)
```

## Getting started
## Setup (One time in a flutter project)

<details open>
<summary>Create a <code>ViewModelFactory</code> for your app</summary>
Expand All @@ -83,9 +83,19 @@ class MyAppViewModelFactory extends ViewModelFactory {
}
```

</details>
If you use dependency injection frameworks like `get_it`, your factory could like this
```dart
class MyAppViewModelFactory extends ViewModelFactory {
const MyAppViewModelFactory();
TBA: Add instructions for the users of dependency frameworks like [`get_it`](https://pub.dev/packages/get_it)
@override
T create<T extends ViewModel>() {
return GetIt.I.get<T>();
}
}
```

</details>

<details open>
<summary>Provide your <code>ViewModelFactory</code> at the root of your App</summary>
Expand Down

0 comments on commit 81836fd

Please sign in to comment.