Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation update (#1618) #1728

Merged
merged 193 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
193 commits
Select commit Hold shift + click to select a range
c1e9631
Add toggles to enable/disable hooks and code generation (#1618)
rrousselGit Oct 4, 2022
da5bbe5
Upgrade packages
rrousselGit Oct 4, 2022
5b547a4
Add @babel/helper-get-function-arity
rrousselGit Oct 4, 2022
f4205c4
Update version test
rrousselGit Oct 5, 2022
132115e
Move getting_started snippets
rrousselGit Oct 5, 2022
0c3db50
Update all getting_started snippets to use interactive codegen/hooks …
rrousselGit Oct 5, 2022
4fa714b
Fix broken translation links
rrousselGit Oct 5, 2022
64168de
Add "About hooks" page
rrousselGit Oct 5, 2022
ba7a36e
Disable hooks by default
rrousselGit Oct 5, 2022
12e13cb
Add barebone "about codegen" doc
rrousselGit Oct 5, 2022
0fc5a0a
Small refactor of codegen doc
rrousselGit Oct 5, 2022
1613cd1
Redirect to getting_started for codegen usage
rrousselGit Oct 6, 2022
8202650
Small update
rrousselGit Oct 6, 2022
b15afc3
Reorganize sidebar a bit
rrousselGit Oct 6, 2022
9c861e4
Extract snippets to dart files
rrousselGit Oct 6, 2022
c2e3368
deploy branch
rrousselGit Oct 7, 2022
637e38f
Typo
rrousselGit Oct 7, 2022
88b4267
Fix mobile sidebar
rrousselGit Oct 8, 2022
e360043
Merge branch 'master' of https://github.com/rrousselGit/river_pod int…
rrousselGit Oct 8, 2022
f67a9ab
Update docs to match
rrousselGit Oct 8, 2022
d998b2d
Merge branch 'master' of https://github.com/rrousselGit/river_pod int…
rrousselGit Oct 8, 2022
f2dfa93
Update docs
rrousselGit Oct 8, 2022
9980068
Add banner to notify that the current doc page might be out of date (…
rrousselGit Oct 9, 2022
5e6adc9
Remove "what package to install" section as it is covered by docs tog…
rrousselGit Oct 9, 2022
d9b4665
Add introduction page
rrousselGit Oct 9, 2022
4ff0f74
Make docs/providers/future_provider compatible with toggles (#1752)
mansourzaki Oct 10, 2022
5ce6c63
Fixed a typo (#1755)
hamza-imran75 Oct 10, 2022
ea17468
Update copyright year text (#1760)
JAICHANGPARK Oct 12, 2022
f0750fa
Update SEO description
rrousselGit Oct 12, 2022
edbcd1f
Merge branch 'docs-v2' of https://github.com/rrousselGit/river_pod in…
rrousselGit Oct 12, 2022
16057b9
Update initial snippet to use bored API
rrousselGit Oct 12, 2022
ddc4281
Update readme to match
rrousselGit Oct 12, 2022
27cdac8
Fix analysis issues in website snippet
rrousselGit Oct 13, 2022
f0a82a1
Run generator on static folder
rrousselGit Oct 13, 2022
1c9bae9
Clean up roadmap
rrousselGit Oct 13, 2022
95d7f20
Selling points roadmap
rrousselGit Oct 14, 2022
1c3b1d1
Merge branch 'master' of https://github.com/rrousselGit/river_pod int…
rrousselGit Oct 14, 2022
7c17cb8
Remove preview banner
rrousselGit Oct 14, 2022
bb5f1f9
Create a Provider -> Create a network request
rrousselGit Oct 14, 2022
e8aa353
Trim readme from Provider content
rrousselGit Oct 14, 2022
f1d1f06
Add "Riverpod for provider users"
rrousselGit Oct 15, 2022
74ca338
Cover how to convert ProxyProvider
rrousselGit Oct 16, 2022
b07dfed
Fix typo
rrousselGit Oct 26, 2022
df93f42
Update riverpod_for_provider_users.mdx (#1842)
escwxyz Oct 30, 2022
e126080
Fix a typo (#1846)
hamza-imran75 Oct 30, 2022
c6b72ca
Changed the structure of the sentence. (#1847)
hamza-imran75 Oct 30, 2022
4dbba74
Update docs to match deprecated Reader
rrousselGit Nov 16, 2022
ba7b99a
Add codegen snippets for "Provider" Page (#1863)
leehack Nov 27, 2022
b22a871
add immutability documentation (#1690)
TimWhiting Dec 21, 2022
129e62c
add lifecycle documentation (#1689)
TimWhiting Dec 21, 2022
3c6cef5
Add documentation about scoping (#1688)
TimWhiting Dec 21, 2022
ab518c5
Merge branch 'master' of https://github.com/rrousselGit/river_pod int…
rrousselGit Dec 21, 2022
1b082b5
Fix lints
rrousselGit Dec 21, 2022
d8bb9be
Update outdated list
rrousselGit Dec 21, 2022
8f7825d
Fix merge
rrousselGit Dec 21, 2022
f55ee0e
Add gemerated files
rrousselGit Dec 21, 2022
45149ef
Update versions
rrousselGit Dec 21, 2022
0e53266
Pub get in third-party folder
rrousselGit Dec 21, 2022
d5c9ac5
Migrate Korean Documents to docs v2 (#1996)
JAICHANGPARK Jan 8, 2023
3f4afe8
Merge branch 'master' of https://github.com/rrousselGit/river_pod int…
rrousselGit Jan 8, 2023
a304c3d
Update dependencies
rrousselGit Jan 8, 2023
8f3adec
Update generated files
rrousselGit Jan 8, 2023
fd8296d
Bump versions
rrousselGit Jan 8, 2023
165cab4
Update outdated translations
rrousselGit Jan 8, 2023
77e704e
Upgrade annotation version
rrousselGit Jan 8, 2023
a2afccc
Add missing generated files
rrousselGit Jan 8, 2023
91c17ba
Update more versions
rrousselGit Jan 8, 2023
f316392
Typo
rrousselGit Jan 8, 2023
01f66c9
Add missing french translations for v2 docs (#2042)
PapiHack Jan 8, 2023
52885de
Upgrade docusaurus to 2.2.0
rrousselGit Jan 8, 2023
f891bb6
Fr Docs v2 (#2070)
GitGud31 Jan 8, 2023
6207588
Re-add imports
rrousselGit Jan 8, 2023
672936c
Merge branch 'master' of https://github.com/rrousselGit/river_pod int…
rrousselGit Jan 8, 2023
f2eae8e
Merge branch 'master' of https://github.com/rrousselGit/river_pod int…
rrousselGit Jan 8, 2023
699b65d
Merge branch 'master' of https://github.com/rrousselGit/river_pod int…
rrousselGit Jan 9, 2023
b942875
Update concept reading page code examples (#2032)
leehack Jan 10, 2023
9ec6144
Add notifier provider page to docs v2 (#2023)
leehack Jan 10, 2023
d9bdd00
Fix minor typo + (Async)NotifierProvider section translation (#2134)
PapiHack Feb 6, 2023
cef014e
Docs v2 add simplified Chinese translation (#2129)
laiiihz Feb 6, 2023
60164ff
Japanese Translation for docs v2 (#2154)
sj-h4 Feb 14, 2023
97fadb3
hook code snippets in getting started page (#2202)
mboyamike Feb 19, 2023
3955b42
Support codegen/hooks for more snippets (#2224)
mboyamike Feb 27, 2023
5ad1895
Fix typo (#2250)
iDevOrz Mar 3, 2023
ecadeb9
Docs v2: Add hook snippets for the concepts/reading a provider page (…
mboyamike Mar 7, 2023
e6f787e
Add Korean Translation in "why immutability" of docs v2 (#2280)
MinyeongHong Mar 8, 2023
37b74ae
Fix som typos in fr docs-v2 (#2292)
PapiHack Mar 10, 2023
af139d1
Merge branch 'master' of https://github.com/rrousselGit/riverpod into…
rrousselGit Mar 12, 2023
a130d5a
Install deps
rrousselGit Mar 12, 2023
d3bdf62
Update generated files
rrousselGit Mar 12, 2023
12ff660
Update dart pubspec
rrousselGit Mar 12, 2023
dcb302e
Update flutter pubsepc
rrousselGit Mar 12, 2023
6e6397e
Upgrade min SDK
rrousselGit Mar 12, 2023
f99b90f
Apply dart fix
rrousselGit Mar 12, 2023
019334b
Ignore lints in generated files
rrousselGit Mar 12, 2023
7231ff4
Update generated files
rrousselGit Mar 12, 2023
286bdce
Install json_serializable
rrousselGit Mar 12, 2023
87d80fc
Update outdated json
rrousselGit Mar 12, 2023
716994b
Remove dead files
rrousselGit Mar 12, 2023
a9047dc
Fix versions
rrousselGit Mar 12, 2023
be4d8bd
Update homepage a bit (#2308)
rrousselGit Mar 12, 2023
f65099f
docs: some updates to docs (#2319)
AhmedLSayed9 Mar 13, 2023
8303f2f
docs: extra updates to docs (#2331)
AhmedLSayed9 Mar 16, 2023
5456e7d
docs: v2 fr translations of homepage's new sections and community exa…
PapiHack Mar 20, 2023
77699d7
docs: add one line install command (#2345)
utamori Apr 1, 2023
327a511
docs: code snippets for concepts/combining_providers (#2357)
mboyamike Apr 1, 2023
5b5e842
docs(v2): refactor Chinese translations (#2433)
escwxyz Apr 8, 2023
40d4e5c
Docs v2 (#2486)
mboyamike Apr 24, 2023
a89320d
Docs v2: More consistent use of notifier over state notifier (#2513)
mboyamike May 2, 2023
c22ce14
Update getting_started.mdx (#2519)
kwill39 May 4, 2023
4a74163
Fix mismatching parameter types in code gen example (#2533)
kwill39 May 6, 2023
2c492b7
Show how to enable custom_lint's plugin in Getting Started (#2528)
kwill39 May 10, 2023
d8fa040
Navigate to Introduction instead of Getting Started when clicking Docs
kwill39 May 10, 2023
014a5b9
Emtnion refactors and link to the full list of lints/refactors
rrousselGit May 10, 2023
014724c
Delete lock file
rrousselGit May 12, 2023
1a2083d
Delete dart generator & related dependencies
rrousselGit May 12, 2023
9af7160
Add JS generator variant & run script in "npm run build"
rrousselGit May 12, 2023
0ffc038
FIx build command
rrousselGit May 12, 2023
4c3fa1b
Deleted dead workflow
rrousselGit May 12, 2023
414031f
Merge branch 'master' of https://github.com/rrousselGit/riverpod into…
rrousselGit May 12, 2023
35e233b
Fix overrides
rrousselGit May 12, 2023
c772400
Fix version test
rrousselGit May 12, 2023
d36a869
Merge pull request #2555 from rrousselGit/automate-outdated-banner
rrousselGit May 12, 2023
82d9bea
Merge branch 'master' of https://github.com/rrousselGit/riverpod into…
rrousselGit May 30, 2023
a4a757c
Update zh_Hans GettingStarted page (#2593)
laiiihz May 30, 2023
6af3f40
Merge branch 'master' of https://github.com/rrousselGit/riverpod into…
rrousselGit May 30, 2023
1ba2fa6
Merge branch 'master' of https://github.com/rrousselGit/riverpod into…
rrousselGit Jun 9, 2023
7c4d998
Merge branch 'master' of https://github.com/rrousselGit/riverpod into…
rrousselGit Jun 21, 2023
8ffcfe7
docs: Improve the "About Code generation" page to add migration guide…
AhmedLSayed9 Jun 23, 2023
eab58b5
Prefix Future/Stream with async (#2673)
AhmedLSayed9 Jun 26, 2023
01f9733
[docs-v2] Save toogle state (#2683)
CaiJingLong Jul 6, 2023
9320232
Change deprecated terminal command (#2708)
eshfield Jul 10, 2023
8bcabf8
Merge branch 'master' of https://github.com/rrousselGit/riverpod into…
rrousselGit Jul 10, 2023
5babe46
Move getting_started/hello_world's hooks to getting_started/hello_wor…
rrousselGit Jul 10, 2023
9d1f2c7
Add flutter_hooks as dependency in getting_started
rrousselGit Jul 10, 2023
6a09a92
Fix broken links
rrousselGit Jul 10, 2023
02b03b7
Use newline for install command
rrousselGit Jul 10, 2023
1655032
Format snippets in getting_Started
rrousselGit Jul 10, 2023
483ee4b
Update home snippets to stop using "when" & start using codegen/patterns
rrousselGit Jul 15, 2023
0da6c86
Add discord link
rrousselGit Jul 15, 2023
c616a71
Intro -> Why Riverpod
rrousselGit Jul 15, 2023
fd13c5d
Add why_riverpod to footer
rrousselGit Jul 15, 2023
54d8846
Update intro
rrousselGit Jul 15, 2023
3c793f4
Add Zapp embed and update TODOs app
rrousselGit Jul 15, 2023
98cd604
Update pubspecs in Getting Started to use SDK >=3
rrousselGit Jul 15, 2023
a398e85
Tone change
rrousselGit Jul 15, 2023
c89159a
Tone
rrousselGit Jul 15, 2023
9f17b3b
Bump
rrousselGit Jul 15, 2023
f7500eb
Add versions
rrousselGit Jul 15, 2023
7963838
Most recent migration first
rrousselGit Jul 15, 2023
61cca3b
Mention that code-generation is encouraged
rrousselGit Jul 15, 2023
b3fd21e
Reorder
rrousselGit Jul 15, 2023
442ed6c
Cleanup more
rrousselGit Jul 15, 2023
ebec846
Use tear-off and format
rrousselGit Jul 15, 2023
6ed3eee
Global mention
rrousselGit Jul 15, 2023
4536684
About hooks update
rrousselGit Jul 15, 2023
e4415a3
Merge branch 'master' of https://github.com/rrousselGit/riverpod into…
rrousselGit Jul 15, 2023
eb3a5d7
Super
rrousselGit Jul 15, 2023
73b978f
Improvements on grammar (#2738)
SakhileMamba Jul 16, 2023
464e053
Merge branch 'master' of https://github.com/rrousselGit/riverpod into…
rrousselGit Jul 16, 2023
aef6bd7
Update tests
rrousselGit Jul 16, 2023
ae44d2a
Mention zapp
rrousselGit Jul 16, 2023
4cfdd1e
Rename Function-based to Functional (#2737)
AhmedLSayed9 Jul 17, 2023
288f458
Merge branch 'master' of https://github.com/rrousselGit/riverpod into…
rrousselGit Jul 27, 2023
12f2faf
Add missing override
rrousselGit Jul 27, 2023
fb4d8f8
Rework sidebar (#2740)
rrousselGit Aug 29, 2023
ac48c11
Merge branch 'master' of https://github.com/rrousselGit/riverpod into…
rrousselGit Aug 29, 2023
0f53b20
Bump dev dependency
rrousselGit Aug 29, 2023
e056800
Update generated code
rrousselGit Aug 29, 2023
c0f4ac7
Update side_effects.mdx (#2868)
nah0y Aug 31, 2023
b0397f6
Fix typo (#2916)
robert-virkus Sep 24, 2023
0c28a2a
Fix. Broken links on .family modifier docs page (#2956)
droidbg Oct 5, 2023
2ac5f71
Add websocket/sync page
rrousselGit Oct 5, 2023
74754b8
Merge branch 'docs-v2' of https://github.com/rrousselGit/riverpod int…
rrousselGit Oct 5, 2023
abf3861
Merge branch 'master' of https://github.com/rrousselGit/riverpod into…
rrousselGit Oct 5, 2023
83f4819
Sync generated code
rrousselGit Oct 5, 2023
8f90f30
Merge branch 'master' of https://github.com/rrousselGit/riverpod into…
rrousselGit Oct 5, 2023
8246a7a
Sync riverpod version
rrousselGit Oct 5, 2023
2e6cdd2
Hide wip pages
rrousselGit Oct 5, 2023
1e26c30
Plan docs
rrousselGit Oct 7, 2023
a981767
Fix hash links not working
rrousselGit Oct 9, 2023
d41dc34
Add combining_request page
rrousselGit Oct 9, 2023
16ba344
Add disposal page
rrousselGit Oct 9, 2023
d4cf33c
Restore legacy docs
rrousselGit Oct 9, 2023
fa9453d
Ignore todos in website
rrousselGit Oct 9, 2023
93a4368
Add eager initialization docs
rrousselGit Oct 10, 2023
a8025fa
Merge branch 'master' of https://github.com/rrousselGit/riverpod into…
rrousselGit Oct 10, 2023
13b8771
Merge branch 'master' of https://github.com/rrousselGit/riverpod into…
rrousselGit Oct 10, 2023
e6cfe9b
Plan "show snackbar" sample
rrousselGit Oct 10, 2023
5eceb2b
Add testing page
rrousselGit Oct 10, 2023
4567a75
Update generated code
rrousselGit Oct 10, 2023
59000f7
Downgrade `test`
rrousselGit Oct 10, 2023
07aac26
Add select page
rrousselGit Oct 11, 2023
0c550d1
Highlight .future usage
rrousselGit Oct 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 8 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ on:
pull_request:
paths-ignore:
- "**.md"
- "**.mdx"
push:
branches:
- master
paths-ignore:
- "**.md"
- "**.mdx"

schedule:
# runs the CI everyday at 10AM
- cron: "0 10 * * *"
Expand Down Expand Up @@ -68,6 +71,11 @@ jobs:
if test -d "integration/build_yaml"; then
flutter pub get integration/build_yaml
fi
- name: Install dependencies (website/third-party)
run: |
if test -d "third-party"; then
flutter pub get third-party/cosmic_frontmatter
fi

- name: Check format
run: dart format --set-exit-if-changed .
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,6 @@ lib/generated_plugin_registrant.dart
# Exceptions to above rules.
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
.vscode/settings.json

node_modules
package-lock.json
122 changes: 122 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
## Contributing to Riverpod

So you want to contribute? Awesome! Contributions are welcomed.
Before we get started on setting up the development environment, check out
our [Code of conduct](./CODE_OF_CONDUCT.md).
You will also want to join our [Discord](https://discord.gg/Bbumvej) to chat.
Feel free to ping @rrousselGit there for questions related to contributing.

With that out of the way, the way to contribute may vary depending on what you
want to contribute to.
There are a few ways to contribute to the Riverpod ecosystem:

- Documentation work (adding new articles, fixing typos, translations).
This is the easiest and recommended way of contributing.
There is generally a low barrier to entry with such contributions.

- Tooling work.
You could work on side-tools for Riverpod, such as adding new lint rules
or working on a migration CLI or devtool, etc...
This is more technical, but code quality won't matter too much.

- Contributing to Riverpod itself.
This is the hardest part. Adding new APIs will be generally very difficult,
as we'll need to have an extensive discussion about that new API first.
If you want to contribute to Riverpod itself, it is recommended to work
on bug fixes instead.

**It is highly encouraged to make an issue before creating your PR**
This is especially crutial for larger work.
You do not need to spend a lot of time making that issue. The important is:

- Mention that you want to contribute
- Explain a bit what you want to do.

Making an issue is important to discuss what needs to be done.
You wouldn't want to spend tens of hours working on something, only to
have your PR rejected because we disagree on the direction taken.
An discussion may slow down the work initially, but it can save you from a lot
of frustration.

## Documentation work

Riverpod's documentation uses [Docusaurus](https://docusaurus.io/fr/docs).
This framework is responsible for various features of the website. Check out
its documentation, as it may have the answer to your questions.

Documentations are written in "mdx", which is a combination of Markdown and JSX.
If you are familiar with Markdown, this should be reasonably easy to pick up.
Feel free to look at existing pages to see how they work.

### Installing the website locally

The docs uses [node](https://nodejs.org/fr) and [yarn](https://yarnpkg.com/).
You will need to install install both and run:

```sh
yarn install
```

Then, you can start the documentation locally with:

```sh
yarn dev
```

Finally, head to `localhost:3000`

### Adding new language

Riverpod supports multiple languages.
To add new languages, it is recommended to follow the [i18n](https://docusaurus.io/fr/docs/i18n/introduction)
documentation of Docusaurus.

The english documentation is hosted in [`/website/docs`](https://github.com/rrousselGit/riverpod/tree/master/website/docs).
Translations are hosted in [`/website/i18n`](https://github.com/rrousselGit/riverpod/tree/master/website/i18n).

### Working on packages

### Updating english docs

English docs are the source of truth for Riverpod docs. As such, translations
may get "out of date" for a period of time.
To make it obvious for users that a translated page may be out of date, Riverpod's
website supports showing a warning banner at the top of the translation pages.

To support in a maintainable way, when editing english docs in a way that requires
translations to be updated, the english's "version number" needs to be bumped.
**This does not need to be done when fixing typos**

To bump the version number of a page, you should either add or update
a `version: nbr` at the very top of the file.

For example:

```md
---
title: This is an example
version: 2
# ^ This number needs to be incremented.
# Doing so will show an outdated banner on all translations of this page.
---

Some content
```

#### Adding code snippets

Unless agree otherwise, all code snippets inside docs need to be placed in a `.dart` file
and then imported in `.mdx` files.
This is important to enable static analysis of the code snippets, such that when
a breaking change happens, all associated snippets in the documentation that
need updating will be highlighted.

You can check out the [Getting Started] source for an example on how to do this.

At the same time, if you are working on a branch of the documentation
where the toggles for enabling/disabling code-generation and hooks are supported; then
your code snippets should support those.
This is done by having a separate `.dart` file for each possible scenario.
Again, look at the [Getting Started] for an example.

[Getting Started]: https://github.com/rrousselGit/riverpod/blob/rework-flow/website/docs/introduction/getting_started.mdx
162 changes: 32 additions & 130 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,108 +20,64 @@
<img src="https://github.com/rrousselGit/riverpod/blob/master/resources/icon/Facebook%20Cover%20A.png?raw=true" width="100%" alt="Riverpod" />
</p>

A state-management library that:
<p align="center">
<img src="https://github.com/rrousselGit/riverpod/blob/master/resources/icon/Facebook%20Cover%20A.png?raw=true" width="100%" alt="Riverpod" />
</p>

---

- catches programming errors at compile time rather than
at runtime
- removes nesting for listening/combining objects
- ensures that the code is testable
A reactive caching and data-binding framework. https://riverpod.dev
Riverpod makes working with asynchronous code a breeze by:

- handling errors/loading states by default. No need to manually catch errors
- natively supporting advanced scenearios, such as pull-to-refresh
- separating the logic from your UI
- ensuring your code is testable, scalable and reusable

| riverpod | [![pub package](https://img.shields.io/pub/v/riverpod.svg?label=riverpod&color=blue)](https://pub.dartlang.org/packages/riverpod) |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| flutter_riverpod | [![pub package](https://img.shields.io/pub/v/riverpod.svg?label=flutter_riverpod&color=blue)](https://pub.dartlang.org/packages/flutter_riverpod) |
| hooks_riverpod | [![pub package](https://img.shields.io/pub/v/riverpod.svg?label=hooks_riverpod&color=blue)](https://pub.dartlang.org/packages/hooks_riverpod) |

Welcome to [Riverpod]!

This project can be considered as a rewrite of [provider] to make improvements
that would be otherwise impossible.
Welcome to [Riverpod] (anagram of [Provider])!

For learning how to use [Riverpod], see its documentation: https://riverpod.dev
For learning how to use [Riverpod], see its documentation:
\>\>\> https://riverpod.dev <<<

Long story short:

- Declare your providers as global variables:
- Define network requests by writing a function annotated with `@riverpod`:

```dart
final counterProvider = NotifierProvider<Counter, int>(Counter.new);

class Counter extends Notifier<int> {
@override
int build() => 0;

void increment() => state++;
@riverpod
Future<String> boredSuggestion(BoredSuggestionRef ref) async {
final response = await http.get(
Uri.https('https://boredapi.com/api/activity'),
);
final json = jsonDecode(response.body);
return json['activity']! as String;
}
```

- Use them inside your widgets in a compile time-safe way. No runtime exceptions!
- Listen to the network request in your UI and gracefully handle loading/error states.

```dart
class Example extends ConsumerWidget {
class Home extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final count = ref.watch(counterProvider);
return Text(count.toString());
final boredSuggestion = ref.watch(boredSuggestionProvider);
// Perform a switch-case on the result to handle loading/error states
return boredSuggestion.when(
loading: () => Text('loading'),
error: (error, stackTrace) => Text('error: $error'),
data: (data) => Text(data),
);
}
}
```

See the [FAQ](#FAQ) if you have questions about what this means for [provider].

## Migration

With the release of version 1.0.0, the syntax for interacting with providers changed.

See [the migration guide](https://riverpod.dev/docs/migration/0.14.0_to_1.0.0/) for more information

## Index

- [Migration](#migration)
- [Index](#index)
- [Motivation](#motivation)
- [Contributing](#contributing)
- [FAQ](#faq)
- [Why another project when provider already exists?](#why-another-project-when-provider-already-exists)
- [Is it safe to use in production?](#is-it-safe-to-use-in-production)
- [Will this get merged with provider at some point?](#will-this-get-merged-with-provider-at-some-point)
- [Will provider be deprecated/stop being supported?](#will-provider-be-deprecatedstop-being-supported)
- [Sponsors](#sponsors)

## Motivation

If [provider] is a simplification of [InheritedWidget]s, then [Riverpod] is
a reimplementation of [InheritedWidget]s from scratch.

It is very similar to [provider] in principle, but also has major differences
as an attempt to fix the common problems that [provider] face.

[Riverpod] has multiple goals. First, it inherits the goals of [provider]:

- Being able to safely create, observe and dispose states without having to worry about
losing the state on widget rebuild.
- Making our objects visible in Flutter's devtool by default.
- Testable and composable
- Improve the readability of [InheritedWidget]s when we have multiple of them
(which would naturally lead to a deeply nested widget tree).
- Make apps more scalable with a unidirectional data flow.

From there, [Riverpod] goes a few steps beyond:

- Reading objects is now **compile-safe**. No more runtime exception.
- It makes the [provider] pattern more flexible, which allows supporting commonly
requested features like:
- Being able to have multiple providers of the same type.
- Disposing the state of a provider when it is no longer used.
- Have computed states
- Making a provider private.
- Simplifies complex object graphs. It is easier to depend on asynchronous state.
- Makes the pattern independent from Flutter

These are achieved by no longer using [InheritedWidget]s. Instead, [Riverpod]
implements its own mechanism that works in a similar fashion.

For learning how to use [Riverpod], see its documentation: https://riverpod.dev

## Contributing

Contributions are welcomed!
Expand All @@ -134,60 +90,6 @@ Here is a curated list of how you can help:
- Update the documentation / add examples
- Implement new features by making a pull-request

## FAQ

### Why another project when provider already exists?

While [provider] is largely used and well accepted by the community,
it is not perfect either.

People regularly file issues or ask questions about some problems they face, such as:

- Why do I have a `ProviderNotFoundException`?
- How can I automatically dispose my state when not used anymore?
- How to make a provider that depends on other (potentially complex) providers?

These are legitimate problems, and I believe that something can be improved to fix
those.

The issue is, these problems are deeply rooted in how [provider] works, and
fixing those problems is likely impossible without drastic changes to the
mechanism of [provider].

In a way, if [provider] is a candle then [Riverpod] is a lightbulb. They have
very similar usages, but we cannot create a lightbulb by improving our candle.

### Is it safe to use in production?

Yes.

[Riverpod] is stable and actively maintained.

### Will this get merged with provider at some point?

It is possible. Some experiments are being made that could make this
doable. But their outcome isn't clear yet.
(no link to an issue to avoid putting unnecessary pressure on the people
involved)

If those experiments are successful (although unlikely), then Provider
and Riverpod could be fused.

### Will provider be deprecated/stop being supported?

Maybe.

Provider has numerous flaws that can't quite be fixed. At the same time,
Riverpod has proven to fix many of those.
As such, deprecating Provider is being considered.

The only inconvenience of Riverpod is the need for a "Consumer",
which Provider doesn't need.
But some alternatives are being investigated to maybe remove this constraint.

Whatever the decision is, a migration tool is planned to help assist
migration from provider to [Riverpod]. Along with whatever other tool necessary to help.

## Sponsors

<p align="center">
Expand Down
Loading
Loading