1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-08 22:09:06 +00:00
Files
samples/provider_shopper
dependabot[bot] 017696d9e7 Bump go_router from 9.1.1 to 10.0.0 in /provider_shopper (#1959)
[//]: # (dependabot-start)
⚠️  **Dependabot is rebasing this PR** ⚠️ 

Rebasing might not happen immediately, so don't worry if this takes some
time.

Note: if you make any changes to this PR yourself, they will take
precedence over the rebase.

---

[//]: # (dependabot-end)

Bumps
[go_router](https://github.com/flutter/packages/tree/main/packages) from
9.1.1 to 10.0.0.
<details>
<summary>Commits</summary>
<ul>
<li><a
href="88a48ffb11"><code>88a48ff</code></a>
[go_router] Replaces uri related properties in GoRouterState (<a
href="https://github.com/flutter/packages/tree/main/packages/issues/4392">#4392</a>)</li>
<li><a
href="43052d9a88"><code>43052d9</code></a>
[webview_flutter_wkwebview] Updates pigeon version to
<code>10.1.4</code> (<a
href="https://github.com/flutter/packages/tree/main/packages/issues/4548">#4548</a>)</li>
<li><a
href="caabb6fc85"><code>caabb6f</code></a>
[pigeon] Adds package name to method channel. (<a
href="https://github.com/flutter/packages/tree/main/packages/issues/4443">#4443</a>)</li>
<li><a
href="e6a71440d8"><code>e6a7144</code></a>
[go_router] Remove unused dependency (<a
href="https://github.com/flutter/packages/tree/main/packages/issues/4545">#4545</a>)</li>
<li><a
href="1af4d1a40a"><code>1af4d1a</code></a>
[go_router_builder] Removes <code>path_to_regexp</code> from the
dependencies (<a
href="https://github.com/flutter/packages/tree/main/packages/issues/4524">#4524</a>)</li>
<li><a
href="203ad04a71"><code>203ad04</code></a>
[google_maps_flutter_web] Adds options for gesture handling and tilt
controls...</li>
<li><a
href="896131fa03"><code>896131f</code></a>
[url_launcher_android] Set <code>buildFeatures.buildConfig</code> to
true for compatibil...</li>
<li>See full diff in <a
href="https://github.com/flutter/packages/commits/go_router-v10.0.0/packages">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=go_router&package-manager=pub&previous-version=9.1.1&new-version=10.0.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-24 20:58:05 +10:00
..
2019-07-23 15:40:43 -07:00
2023-05-11 12:48:09 +10:00
2023-01-25 09:08:51 +10:00
2022-10-04 22:38:07 +10:00
2023-01-25 09:08:51 +10:00
2023-06-28 19:16:30 +10:00

provider_shopper

A Flutter sample app that shows a state management approach using the Provider package. This is the app discussed in the Simple app state management section of flutter.dev.

Goals for this sample

  • Show simple use of Provider for providing an immutable value to a subtree
  • Illustrate a simple state management approach using the ChangeNotifier class
  • Show use of ProxyProvider for provided objects that depend on other provided objects

The important bits

lib/main.dart

Here the app sets up objects it needs to track state: a catalog and a shopping cart. It builds a MultiProvider to provide both objects at once to widgets further down the tree.

The CartModel instance is provided using a ChangeNotifierProxyProvider, which combines two types of functionality:

  1. It will automatically subscribe to changes in CartModel (if you only want this functionality simply use ChangeNotifierProvider).
  2. It takes the value of a previously provided object (in this case, CatalogModel, provided just above), and uses it to build the value of CartModel (if you only want this functionality, simply use ProxyProvider).

lib/models/*

This directory contains the model classes that are provided in main.dart. These classes represent the app state.

lib/screens/*

This directory contains widgets used to construct the two screens of the app: the catalog and the cart. These widgets have access to the current state of both the catalog and the cart via Provider.of.

Questions/issues

If you have a general question about Provider, the best places to go are:

If you run into an issue with the sample itself, please file an issue in the main Flutter repo.