mirror of
https://github.com/rrousselGit/riverpod.git
synced 2025-08-16 11:20:55 +08:00

## Related Issues Mutations are reworked to be independent from notifiers and do not require code-gen. ## Checklist Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (`[x]`). - [x] I have updated the `CHANGELOG.md` of the relevant packages. Changelog files must be edited under the form: ```md ## Unreleased fix/major/minor - Description of your change. (thanks to @yourGithubId) ``` - [x] If this contains new features or behavior changes, I have updated the documentation to match those changes. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a new mutation system that no longer requires code generation, enabling UI to react to side-effects with loading, success, and error states. - Added experimental mutation APIs to Riverpod, Flutter Riverpod, and Hooks Riverpod packages for enhanced state management. - Included new mixins and interfaces to simplify creating custom provider listenables. - Added widget test helpers and improved mutation state matchers for testing. - **Bug Fixes** - Enhanced error handling and reporting during mutation lifecycle events. - Fixed issues with Notifier lifecycle and provider observer context related to mutations. - **Refactor** - Removed legacy mutation annotation logic and related code from analyzer, generator, and annotation packages. - Simplified generated provider classes by removing explicit element creation overrides. - Updated internal APIs to replace `MutationContext` with direct `Mutation` usage and adjusted related observer interfaces. - **Documentation** - Revised mutation feature documentation to reflect new API design without code generation. - Corrected migration guide links and updated changelogs to reflect annotation and mutation system changes. - **Tests** - Added extensive mutation tests covering state transitions, concurrency, reset behavior, and observer notifications. - Improved test utilities with new matchers for mutation states and context. - **Chores** - Removed obsolete mutation-related test files, templates, and internal annotation handling to maintain codebase clarity. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
99 lines
2.6 KiB
Dart
Generated
99 lines
2.6 KiB
Dart
Generated
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
|
|
// ignore_for_file: non_constant_identifier_names
|
|
|
|
part of 'codegen.dart';
|
|
|
|
// **************************************************************************
|
|
// RiverpodGenerator
|
|
// **************************************************************************
|
|
|
|
@ProviderFor(other)
|
|
const otherProvider = OtherProvider._();
|
|
|
|
final class OtherProvider extends $FunctionalProvider<int, int, int>
|
|
with $Provider<int> {
|
|
const OtherProvider._()
|
|
: super(
|
|
from: null,
|
|
argument: null,
|
|
retry: null,
|
|
name: r'otherProvider',
|
|
isAutoDispose: true,
|
|
dependencies: null,
|
|
$allTransitiveDependencies: null,
|
|
);
|
|
|
|
@override
|
|
String debugGetCreateSourceHash() => _$otherHash();
|
|
|
|
@$internal
|
|
@override
|
|
$ProviderElement<int> $createElement($ProviderPointer pointer) =>
|
|
$ProviderElement(pointer);
|
|
|
|
@override
|
|
int create(Ref ref) {
|
|
return other(ref);
|
|
}
|
|
|
|
/// {@macro riverpod.override_with_value}
|
|
Override overrideWithValue(int value) {
|
|
return $ProviderOverride(
|
|
origin: this,
|
|
providerOverride: $SyncValueProvider<int>(value),
|
|
);
|
|
}
|
|
}
|
|
|
|
String _$otherHash() => r'5d27b2b1b1c6bd17ba0844f74ade2088611be371';
|
|
|
|
@ProviderFor(MyNotifier)
|
|
const myNotifierProvider = MyNotifierProvider._();
|
|
|
|
final class MyNotifierProvider extends $NotifierProvider<MyNotifier, int> {
|
|
const MyNotifierProvider._()
|
|
: super(
|
|
from: null,
|
|
argument: null,
|
|
retry: null,
|
|
name: r'myNotifierProvider',
|
|
isAutoDispose: true,
|
|
dependencies: null,
|
|
$allTransitiveDependencies: null,
|
|
);
|
|
|
|
@override
|
|
String debugGetCreateSourceHash() => _$myNotifierHash();
|
|
|
|
@$internal
|
|
@override
|
|
MyNotifier create() => MyNotifier();
|
|
|
|
/// {@macro riverpod.override_with_value}
|
|
Override overrideWithValue(int value) {
|
|
return $ProviderOverride(
|
|
origin: this,
|
|
providerOverride: $SyncValueProvider<int>(value),
|
|
);
|
|
}
|
|
}
|
|
|
|
String _$myNotifierHash() => r'353efe22dd5a91b2d036286211ac9e60c9de5f6d';
|
|
|
|
abstract class _$MyNotifier extends $Notifier<int> {
|
|
int build();
|
|
@$mustCallSuper
|
|
@override
|
|
void runBuild() {
|
|
final created = build();
|
|
final ref = this.ref as $Ref<int, int>;
|
|
final element = ref.element
|
|
as $ClassProviderElement<AnyNotifier<int, int>, int, Object?, Object?>;
|
|
element.handleValue(ref, created);
|
|
}
|
|
}
|
|
|
|
// ignore_for_file: type=lint
|
|
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package
|