Skip to content

Commit

Permalink
Merge branch 'rrousselGit:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
MinByeongDon committed Mar 22, 2024
2 parents 0502a20 + 6557620 commit 947388d
Show file tree
Hide file tree
Showing 1,171 changed files with 1,273 additions and 23,303 deletions.
2 changes: 1 addition & 1 deletion benchmarks/pubspec.yaml
Expand Up @@ -4,7 +4,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1

environment:
sdk: ">=2.12.0-0 <3.0.0"
sdk: ">=2.12.0-0 <4.0.0"

dependencies:
flutter:
Expand Down
2 changes: 0 additions & 2 deletions examples/counter/pubspec_overrides.yaml
Expand Up @@ -14,5 +14,3 @@ dependency_overrides:
path: ../../packages/riverpod_annotation
riverpod_generator:
path: ../../packages/riverpod_generator
# https://github.com/vegardit/dart-hotreloader/issues/14
vm_service: ">=8.0.0 <15.0.0"
2 changes: 0 additions & 2 deletions examples/marvel/pubspec_overrides.yaml
Expand Up @@ -14,5 +14,3 @@ dependency_overrides:
path: ../../packages/riverpod_annotation
riverpod_generator:
path: ../../packages/riverpod_generator
# https://github.com/vegardit/dart-hotreloader/issues/14
vm_service: ">=8.0.0 <15.0.0"
2 changes: 0 additions & 2 deletions examples/pub/pubspec_overrides.yaml
Expand Up @@ -14,5 +14,3 @@ dependency_overrides:
path: ../../packages/riverpod_annotation
riverpod_generator:
path: ../../packages/riverpod_generator
# https://github.com/vegardit/dart-hotreloader/issues/14
vm_service: ">=8.0.0 <15.0.0"
2 changes: 0 additions & 2 deletions examples/random_number/pubspec_overrides.yaml
Expand Up @@ -12,5 +12,3 @@ dependency_overrides:
path: ../../packages/riverpod_annotation
riverpod_generator:
path: ../../packages/riverpod_generator
# https://github.com/vegardit/dart-hotreloader/issues/14
vm_service: ">=8.0.0 <15.0.0"
2 changes: 0 additions & 2 deletions examples/stackoverflow/pubspec_overrides.yaml
Expand Up @@ -14,5 +14,3 @@ dependency_overrides:
path: ../../packages/riverpod_annotation
riverpod_generator:
path: ../../packages/riverpod_generator
# https://github.com/vegardit/dart-hotreloader/issues/14
vm_service: ">=8.0.0 <15.0.0"
2 changes: 0 additions & 2 deletions examples/todos/pubspec_overrides.yaml
Expand Up @@ -14,5 +14,3 @@ dependency_overrides:
path: ../../packages/riverpod_annotation
riverpod_generator:
path: ../../packages/riverpod_generator
# https://github.com/vegardit/dart-hotreloader/issues/14
vm_service: ">=8.0.0 <15.0.0"
18 changes: 18 additions & 0 deletions packages/flutter_riverpod/CHANGELOG.md
@@ -1,3 +1,21 @@
## 2.5.2 - 2024-03-18

- Fixed various typos in the documentation (thanks to @kevalvavaliya)

## 2.5.1 - 2024-03-10

- Deprecate `ProviderScope.parent` due to fundamentally not working.
See https://github.com/rrousselGit/riverpod/issues/3261
- Improved `Provider(dependencies: [...])` documentation.
- Fix out of date `pub.dev` description
- `ref.invalidate` now correctly clear all resources associated
with the provider if the provider is no-longer used.
- Fix `selectAsync` sometimes never resolving.
- Fix `ProviderSubscription.read` returned by `ref.listen(provider.future)` not throwing if used after the subscription has been closed.
- Fix `ref.onAddListener` and other life-cycles not being triggered when
listening to `provider.future`/`provider.notifier`.
- Fix a bug that caused `Assertion failed: _lastFuture == null`

## 2.4.10 - 2024-02-03

- Fix out of date `pub.dev` description
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter_riverpod/example/pubspec.yaml
Expand Up @@ -4,7 +4,7 @@ description: A new Flutter project.
publish_to: "none"

environment:
sdk: ">=2.17.0 <3.0.0"
sdk: ">=2.17.0 <4.0.0"

dependencies:
flutter:
Expand Down
19 changes: 14 additions & 5 deletions packages/flutter_riverpod/lib/src/consumer.dart
Expand Up @@ -642,8 +642,14 @@ class ConsumerStatefulElement extends StatefulElement implements WidgetRef {
_assertNotDisposed();
final listeners = _manualListeners ??= [];

// Reading the container using "listen:false" to guarantee that this can
// be used inside initState.
final container = ProviderScope.containerOf(this, listen: false);

final sub = _ListenManual(
ProviderScope.containerOf(this, listen: false).listen(
// TODO somehow pass "this" instead for the devtool's sake
container,
container.listen(
provider,
listener,
onError: onError,
Expand All @@ -660,16 +666,19 @@ class ConsumerStatefulElement extends StatefulElement implements WidgetRef {
BuildContext get context => this;
}

class _ListenManual<T> implements ProviderSubscription<T> {
_ListenManual(this._subscription, this._element);
class _ListenManual<T> extends ProviderSubscription<T> {
_ListenManual(super.source, this._subscription, this._element);

final ProviderSubscription<T> _subscription;
final ConsumerStatefulElement _element;

@override
void close() {
_subscription.close();
_element._manualListeners?.remove(this);
if (!closed) {
_subscription.close();
_element._manualListeners?.remove(this);
}
super.close();
}

@override
Expand Down
8 changes: 7 additions & 1 deletion packages/flutter_riverpod/lib/src/framework.dart
@@ -1,4 +1,4 @@
// ignore_for_file: invalid_use_of_internal_member
// ignore_for_file: invalid_use_of_internal_member, deprecated_member_use_from_same_package

import 'package:flutter/foundation.dart' hide describeIdentity;
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -83,6 +83,9 @@ class ProviderScope extends StatefulWidget {
super.key,
this.overrides = const [],
this.observers,
@Deprecated(
'Will be removed in 3.0.0. See https://github.com/rrousselGit/riverpod/issues/3261#issuecomment-1973514033',
)
this.parent,
required this.child,
});
Expand Down Expand Up @@ -136,6 +139,9 @@ class ProviderScope extends StatefulWidget {
///
///
/// The [parent] variable must never change.
@Deprecated(
'Will be removed in 3.0.0. See https://github.com/rrousselGit/riverpod/issues/3261#issuecomment-1973514033',
)
final ProviderContainer? parent;

/// The part of the widget tree that can use Riverpod and has overridden providers.
Expand Down
6 changes: 3 additions & 3 deletions packages/flutter_riverpod/pubspec.yaml
Expand Up @@ -2,23 +2,23 @@ name: flutter_riverpod
description: >
A reactive caching and data-binding framework.
Riverpod makes working with asynchronous code a breeze.
version: 2.4.10
version: 2.5.1
homepage: https://riverpod.dev
repository: https://github.com/rrousselGit/riverpod
issue_tracker: https://github.com/rrousselGit/riverpod/issues
funding:
- https://github.com/sponsors/rrousselGit/

environment:
sdk: ">=2.17.0 <3.0.0"
sdk: ">=2.17.0 <4.0.0"
flutter: ">=3.0.0"

dependencies:
collection: ^1.15.0
flutter:
sdk: flutter
meta: ^1.4.0
riverpod: 2.5.0
riverpod: 2.5.1
state_notifier: ">=0.7.2 <2.0.0"

dev_dependencies:
Expand Down
3 changes: 3 additions & 0 deletions packages/flutter_riverpod/test/framework_test.dart
Expand Up @@ -163,6 +163,7 @@ void main() {

await tester.pumpWidget(
ProviderScope(
// ignore: deprecated_member_use_from_same_package
parent: container,
child: Consumer(
builder: (context, ref, _) {
Expand All @@ -184,13 +185,15 @@ void main() {

await tester.pumpWidget(
ProviderScope(
// ignore: deprecated_member_use_from_same_package
parent: container,
child: Container(),
),
);

await tester.pumpWidget(
ProviderScope(
// ignore: deprecated_member_use_from_same_package
parent: container2,
child: Container(),
),
Expand Down
14 changes: 14 additions & 0 deletions packages/hooks_riverpod/CHANGELOG.md
@@ -1,3 +1,17 @@
## 2.5.1 - 2024-03-10

- Deprecate `ProviderScope.parent` due to fundamentally not working.
See https://github.com/rrousselGit/riverpod/issues/3261
- Improved `Provider(dependencies: [...])` documentation.
- Fix out of date `pub.dev` description
- `ref.invalidate` now correctly clear all resources associated
with the provider if the provider is no-longer used.
- Fix `selectAsync` sometimes never resolving.
- Fix `ProviderSubscription.read` returned by `ref.listen(provider.future)` not throwing if used after the subscription has been closed.
- Fix `ref.onAddListener` and other life-cycles not being triggered when
listening to `provider.future`/`provider.notifier`.
- Fix a bug that caused `Assertion failed: _lastFuture == null`

## 2.4.10 - 2024-02-03

- Fix out of date `pub.dev` description
Expand Down
2 changes: 1 addition & 1 deletion packages/hooks_riverpod/example/pubspec.yaml
Expand Up @@ -4,7 +4,7 @@ description: A new Flutter project.
publish_to: "none"

environment:
sdk: ">=2.12.0-0 <3.0.0"
sdk: ">=2.12.0-0 <4.0.0"
flutter: ">=1.17.0"

dependencies:
Expand Down
8 changes: 4 additions & 4 deletions packages/hooks_riverpod/pubspec.yaml
Expand Up @@ -2,24 +2,24 @@ name: hooks_riverpod
description: >
A reactive caching and data-binding framework.
Riverpod makes working with asynchronous code a breeze.
version: 2.4.10
version: 2.5.1
homepage: https://riverpod.dev
repository: https://github.com/rrousselGit/riverpod
issue_tracker: https://github.com/rrousselGit/riverpod/issues
funding:
- https://github.com/sponsors/rrousselGit/

environment:
sdk: ">=2.17.0 <3.0.0"
sdk: ">=2.17.0 <4.0.0"
flutter: ">=3.0.0"

dependencies:
collection: ^1.15.0
flutter:
sdk: flutter
flutter_hooks: '>=0.18.0 <0.21.0'
flutter_riverpod: 2.4.10
riverpod: 2.5.0
flutter_riverpod: 2.5.1
riverpod: 2.5.1
state_notifier: ">=0.7.2 <2.0.0"

dev_dependencies:
Expand Down
17 changes: 12 additions & 5 deletions packages/riverpod/CHANGELOG.md
@@ -1,11 +1,18 @@
## 2.5.0 - 2024-02-03

- Add `test` argument to `AsyncValue.guard` method. (thanks to @utamori)

## Unreleased fix
## 2.5.1 - 2024-03-10

- Improved `Provider(dependencies: [...])` documentation.
- Fix out of date `pub.dev` description
- `ref.invalidate` now correctly clear all resources associated
with the provider if the provider is no-longer used.
- Fix `selectAsync` sometimes never resolving.
- Fix `ProviderSubscription.read` returned by `ref.listen(provider.future)` not throwing if used after the subscription has been closed.
- Fix `ref.onAddListener` and other life-cycles not being triggered when
listening to `provider.future`/`provider.notifier`.
- Fix a bug that caused `Assertion failed: _lastFuture == null`

## 2.5.0 - 2024-02-03

- Add `test` argument to `AsyncValue.guard` method. (thanks to @utamori)

## 2.4.9 - 2023-11-27

Expand Down
2 changes: 1 addition & 1 deletion packages/riverpod/example/pubspec.yaml
Expand Up @@ -2,7 +2,7 @@ name: riverpod_example
publish_to: "none"

environment:
sdk: ">=2.17.0 <3.0.0"
sdk: ">=2.17.0 <4.0.0"

dependencies:
crypto: ^3.0.0
Expand Down
10 changes: 4 additions & 6 deletions packages/riverpod/lib/src/async_notifier/base.dart
Expand Up @@ -466,9 +466,8 @@ mixin FutureHandlerProviderElementMixin<T>

@override
void visitChildren({
required void Function(ProviderElementBase<Object?> element) elementVisitor,
required void Function(ProxyElementValueNotifier<Object?> element)
notifierVisitor,
required void Function(ProviderElementBase element) elementVisitor,
required void Function(ProxyElementValueNotifier element) notifierVisitor,
}) {
super.visitChildren(
elementVisitor: elementVisitor,
Expand All @@ -491,9 +490,8 @@ abstract class AsyncNotifierProviderElementBase<

@override
void visitChildren({
required void Function(ProviderElementBase<Object?> element) elementVisitor,
required void Function(ProxyElementValueNotifier<Object?> element)
notifierVisitor,
required void Function(ProviderElementBase element) elementVisitor,
required void Function(ProxyElementValueNotifier element) notifierVisitor,
}) {
super.visitChildren(
elementVisitor: elementVisitor,
Expand Down
82 changes: 82 additions & 0 deletions packages/riverpod/lib/src/common/env.dart
@@ -0,0 +1,82 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// ignore_for_file: do_not_use_environment, comment_references

/// A constant that is true if the application was compiled in release mode.
///
/// More specifically, this is a constant that is true if the application was
/// compiled in Dart with the '-Ddart.vm.product=true' flag.
///
/// Since this is a const value, it can be used to indicate to the compiler that
/// a particular block of code will not be executed in release mode, and hence
/// can be removed.
///
/// Generally it is better to use [kDebugMode] or `assert` to gate code, since
/// using [kReleaseMode] will introduce differences between release and profile
/// builds, which makes performance testing less representative.
///
/// See also:
///
/// * [kDebugMode], which is true in debug builds.
/// * [kProfileMode], which is true in profile builds.
const bool kReleaseMode = bool.fromEnvironment('dart.vm.product');

/// A constant that is true if the application was compiled in profile mode.
///
/// More specifically, this is a constant that is true if the application was
/// compiled in Dart with the '-Ddart.vm.profile=true' flag.
///
/// Since this is a const value, it can be used to indicate to the compiler that
/// a particular block of code will not be executed in profile mode, an hence
/// can be removed.
///
/// See also:
///
/// * [kDebugMode], which is true in debug builds.
/// * [kReleaseMode], which is true in release builds.
const bool kProfileMode = bool.fromEnvironment('dart.vm.profile');

/// A constant that is true if the application was compiled in debug mode.
///
/// More specifically, this is a constant that is true if the application was
/// not compiled with '-Ddart.vm.product=true' and '-Ddart.vm.profile=true'.
///
/// Since this is a const value, it can be used to indicate to the compiler that
/// a particular block of code will not be executed in debug mode, and hence
/// can be removed.
///
/// An alternative strategy is to use asserts, as in:
///
/// ```dart
/// assert(() {
/// // ...debug-only code here...
/// return true;
/// }());
/// ```
///
/// See also:
///
/// * [kReleaseMode], which is true in release builds.
/// * [kProfileMode], which is true in profile builds.
const bool kDebugMode = !kReleaseMode && !kProfileMode;

/// The epsilon of tolerable double precision error.
///
/// This is used in various places in the framework to allow for floating point
/// precision loss in calculations. Differences below this threshold are safe to
/// disregard.
const double precisionErrorTolerance = 1e-10;

/// A constant that is true if the application was compiled to run on the web.
///
/// See also:
///
/// * [defaultTargetPlatform], which is used by themes to find out which
/// platform the application is running on (or, in the case of a web app,
/// which platform the application's browser is running in). Can be overridden
/// in tests with [debugDefaultTargetPlatformOverride].
/// * [dart:io.Platform], a way to find out the browser's platform that is not
/// overridable in tests.
const bool kIsWeb = bool.fromEnvironment('dart.library.js_util');

0 comments on commit 947388d

Please sign in to comment.