diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..b1f2a0c3c --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +**/*.*.dart linguist-generated=true diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f1d36fda1..9b190a266 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,8 +21,7 @@ jobs: strategy: matrix: channel: - # Waiting for WidgetStateProperty to be stable - # - stable + - stable - master package_path: - examples/counter diff --git a/.github/workflows/riverpod_lint.yml b/.github/workflows/riverpod_lint.yml index eb30d0bca..2bee84581 100644 --- a/.github/workflows/riverpod_lint.yml +++ b/.github/workflows/riverpod_lint.yml @@ -20,6 +20,7 @@ jobs: matrix: channel: - master + - stable package_path: - packages/riverpod_analyzer_utils - packages/riverpod_analyzer_utils_tests diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f4dcd9b4d..bf5b5e2e1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -35,7 +35,7 @@ You do not need to spend a lot of time making that issue. The important is: 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 +A discussion may slow down the work initially, but it can save you from a lot of frustration. ## Documentation work diff --git a/README.md b/README.md index 45112fb16..4841824a7 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ Long story short: ```dart @riverpod - Future boredSuggestion(BoredSuggestionRef ref) async { + Future boredSuggestion(Ref ref) async { final response = await http.get( Uri.https('boredapi.com', '/api/activity'), ); diff --git a/examples/counter/lib/main.g.dart b/examples/counter/lib/main.g.dart index 2a62bb8a4..de01a3856 100644 --- a/examples/counter/lib/main.g.dart +++ b/examples/counter/lib/main.g.dart @@ -64,7 +64,7 @@ final class CounterProvider extends $NotifierProvider { @override CounterProvider $copyWithBuild( int Function( - Ref, + Ref, Counter, ) build, ) { @@ -88,4 +88,4 @@ abstract class _$Counter extends $Notifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/examples/counter/pubspec.yaml b/examples/counter/pubspec.yaml index b2c4b3b6f..71a355882 100644 --- a/examples/counter/pubspec.yaml +++ b/examples/counter/pubspec.yaml @@ -24,7 +24,7 @@ dependencies: dev_dependencies: build_runner: ^2.3.3 - custom_lint: ^0.6.5 + custom_lint: ^0.7.0 flutter_test: sdk: flutter freezed: ^2.3.2 diff --git a/examples/marvel/lib/src/marvel.dart b/examples/marvel/lib/src/marvel.dart index 36f6aed18..594e04380 100644 --- a/examples/marvel/lib/src/marvel.dart +++ b/examples/marvel/lib/src/marvel.dart @@ -29,7 +29,7 @@ class MarvelRepository { }) : _getCurrentTimestamp = getCurrentTimestamp ?? (() => DateTime.now().millisecondsSinceEpoch); - final Ref ref; + final Ref ref; final int Function() _getCurrentTimestamp; final _characterCache = {}; diff --git a/examples/marvel/lib/src/widgets/search_bar.dart b/examples/marvel/lib/src/widgets/search_bar.dart index 5a1be1940..a78989098 100644 --- a/examples/marvel/lib/src/widgets/search_bar.dart +++ b/examples/marvel/lib/src/widgets/search_bar.dart @@ -6,18 +6,17 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; import '../screens/home.dart'; +const _height = 300.0; + class _SearchTheme { const _SearchTheme({ required this.width, - // ignore: unused_element, blocked by https://github.com/dart-lang/linter/issues/3232 - this.height = 300, required this.searchDecoration, required this.iconPadding, required this.searchMargin, }); final double width; - final double height; final BoxDecoration searchDecoration; final EdgeInsets iconPadding; final EdgeInsets searchMargin; @@ -187,7 +186,7 @@ class _SearchHintContainer extends StatelessWidget { Widget build(BuildContext context) { return Container( constraints: BoxConstraints( - maxHeight: theme.height, + maxHeight: _height, ), margin: theme.searchMargin, child: Material( @@ -196,7 +195,7 @@ class _SearchHintContainer extends StatelessWidget { clipBehavior: Clip.hardEdge, child: OverflowBox( alignment: Alignment.topLeft, - maxHeight: theme.height, + maxHeight: _height, maxWidth: 300, child: child, ), diff --git a/examples/marvel/pubspec.yaml b/examples/marvel/pubspec.yaml index 8b64a8c6a..dab401fe3 100644 --- a/examples/marvel/pubspec.yaml +++ b/examples/marvel/pubspec.yaml @@ -22,7 +22,7 @@ dependencies: dev_dependencies: build_runner: ^2.0.0 - custom_lint: ^0.6.5 + custom_lint: ^0.7.0 flutter_test: sdk: flutter freezed: ^2.1.0 diff --git a/examples/pub/lib/detail.dart b/examples/pub/lib/detail.dart index 707903408..c1b15ff97 100644 --- a/examples/pub/lib/detail.dart +++ b/examples/pub/lib/detail.dart @@ -13,7 +13,7 @@ import 'search.dart'; part 'detail.g.dart'; -extension CancelTokenX on Ref { +extension CancelTokenX on Ref { CancelToken cancelToken() { final cancelToken = CancelToken(); onDispose(cancelToken.cancel); @@ -23,7 +23,7 @@ extension CancelTokenX on Ref { @riverpod Future fetchPackageDetails( - FetchPackageDetailsRef ref, { + Ref ref, { required String packageName, }) async { final cancelToken = ref.cancelToken(); @@ -34,7 +34,7 @@ Future fetchPackageDetails( } @riverpod -Future> likedPackages(LikedPackagesRef ref) async { +Future> likedPackages(Ref ref) async { final cancelToken = ref.cancelToken(); return ref @@ -43,7 +43,7 @@ Future> likedPackages(LikedPackagesRef ref) async { } @riverpod -PubRepository pubRepository(PubRepositoryRef ref) => PubRepository(); +PubRepository pubRepository(Ref ref) => PubRepository(); /// A provider that fetches the likes count, popularity score and pub points /// for a given package. diff --git a/examples/pub/lib/detail.g.dart b/examples/pub/lib/detail.g.dart index 40b98a5de..634aec783 100644 --- a/examples/pub/lib/detail.g.dart +++ b/examples/pub/lib/detail.g.dart @@ -8,21 +8,17 @@ part of 'detail.dart'; // RiverpodGenerator // ************************************************************************** -typedef FetchPackageDetailsRef = Ref>; - @ProviderFor(fetchPackageDetails) const fetchPackageDetailsProvider = FetchPackageDetailsFamily._(); final class FetchPackageDetailsProvider extends $FunctionalProvider, FutureOr> - with - $FutureModifier, - $FutureProvider { + with $FutureModifier, $FutureProvider { const FetchPackageDetailsProvider._( {required FetchPackageDetailsFamily super.from, required String super.argument, FutureOr Function( - FetchPackageDetailsRef ref, { + Ref ref, { required String packageName, })? create}) : _createCb = create, @@ -35,7 +31,7 @@ final class FetchPackageDetailsProvider ); final FutureOr Function( - FetchPackageDetailsRef ref, { + Ref ref, { required String packageName, })? _createCb; @@ -57,7 +53,7 @@ final class FetchPackageDetailsProvider @override FetchPackageDetailsProvider $copyWithCreate( FutureOr Function( - FetchPackageDetailsRef ref, + Ref ref, ) create, ) { return FetchPackageDetailsProvider._( @@ -71,7 +67,7 @@ final class FetchPackageDetailsProvider } @override - FutureOr create(FetchPackageDetailsRef ref) { + FutureOr create(Ref ref) { final _$cb = _createCb ?? fetchPackageDetails; final argument = this.argument as String; return _$cb( @@ -92,7 +88,7 @@ final class FetchPackageDetailsProvider } String _$fetchPackageDetailsHash() => - r'e65ba332cb8397cc5a1aca6e656233dff698391a'; + r'16ad07d6f69412f6d456c6d482f15dc53421df74'; final class FetchPackageDetailsFamily extends Family { const FetchPackageDetailsFamily._() @@ -118,7 +114,7 @@ final class FetchPackageDetailsFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( FutureOr Function( - FetchPackageDetailsRef ref, + Ref ref, String args, ) create, ) { @@ -137,19 +133,15 @@ final class FetchPackageDetailsFamily extends Family { } } -typedef LikedPackagesRef = Ref>>; - @ProviderFor(likedPackages) const likedPackagesProvider = LikedPackagesProvider._(); final class LikedPackagesProvider extends $FunctionalProvider< AsyncValue>, FutureOr>> - with - $FutureModifier>, - $FutureProvider, LikedPackagesRef> { + with $FutureModifier>, $FutureProvider> { const LikedPackagesProvider._( {FutureOr> Function( - LikedPackagesRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -163,7 +155,7 @@ final class LikedPackagesProvider extends $FunctionalProvider< ); final FutureOr> Function( - LikedPackagesRef ref, + Ref ref, )? _createCb; @override @@ -178,32 +170,30 @@ final class LikedPackagesProvider extends $FunctionalProvider< @override LikedPackagesProvider $copyWithCreate( FutureOr> Function( - LikedPackagesRef ref, + Ref ref, ) create, ) { return LikedPackagesProvider._(create: create); } @override - FutureOr> create(LikedPackagesRef ref) { + FutureOr> create(Ref ref) { final _$cb = _createCb ?? likedPackages; return _$cb(ref); } } -String _$likedPackagesHash() => r'304a4def167e245812638cba776e8d5eb66d8844'; - -typedef PubRepositoryRef = Ref; +String _$likedPackagesHash() => r'8debee8d8fa48334d1de21fa9bbf03224265d29d'; @ProviderFor(pubRepository) const pubRepositoryProvider = PubRepositoryProvider._(); final class PubRepositoryProvider extends $FunctionalProvider - with $Provider { + with $Provider { const PubRepositoryProvider._( {PubRepository Function( - PubRepositoryRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -217,7 +207,7 @@ final class PubRepositoryProvider ); final PubRepository Function( - PubRepositoryRef ref, + Ref ref, )? _createCb; @override @@ -239,20 +229,20 @@ final class PubRepositoryProvider @override PubRepositoryProvider $copyWithCreate( PubRepository Function( - PubRepositoryRef ref, + Ref ref, ) create, ) { return PubRepositoryProvider._(create: create); } @override - PubRepository create(PubRepositoryRef ref) { + PubRepository create(Ref ref) { final _$cb = _createCb ?? pubRepository; return _$cb(ref); } } -String _$pubRepositoryHash() => r'1f4dbfa0911f6467067fab244677acbcb8c7ad4e'; +String _$pubRepositoryHash() => r'fd358feb202d2c34ad507ebf0a40bddbebc8ea98'; /// A provider that fetches the likes count, popularity score and pub points /// for a given package. @@ -319,7 +309,7 @@ final class PackageMetricsProvider @override PackageMetricsProvider $copyWithBuild( FutureOr Function( - Ref>, + Ref, PackageMetrics, ) build, ) { @@ -402,9 +392,7 @@ final class PackageMetricsFamily extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( FutureOr Function( - Ref> ref, - PackageMetrics notifier, - String argument) + Ref ref, PackageMetrics notifier, String argument) build, ) { return $FamilyOverride( @@ -437,4 +425,4 @@ abstract class _$PackageMetrics extends $AsyncNotifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/examples/pub/lib/search.dart b/examples/pub/lib/search.dart index eeafba4f1..3a9cdb2eb 100644 --- a/examples/pub/lib/search.dart +++ b/examples/pub/lib/search.dart @@ -17,7 +17,7 @@ const searchPageSize = 10; @riverpod Future> fetchPackages( - FetchPackagesRef ref, { + Ref ref, { required int page, String search = '', }) async { diff --git a/examples/pub/lib/search.g.dart b/examples/pub/lib/search.g.dart index 1f5b79dc3..571727cdf 100644 --- a/examples/pub/lib/search.g.dart +++ b/examples/pub/lib/search.g.dart @@ -8,16 +8,12 @@ part of 'search.dart'; // RiverpodGenerator // ************************************************************************** -typedef FetchPackagesRef = Ref>>; - @ProviderFor(fetchPackages) const fetchPackagesProvider = FetchPackagesFamily._(); final class FetchPackagesProvider extends $FunctionalProvider< AsyncValue>, FutureOr>> - with - $FutureModifier>, - $FutureProvider, FetchPackagesRef> { + with $FutureModifier>, $FutureProvider> { const FetchPackagesProvider._( {required FetchPackagesFamily super.from, required ({ @@ -26,7 +22,7 @@ final class FetchPackagesProvider extends $FunctionalProvider< }) super.argument, FutureOr> Function( - FetchPackagesRef ref, { + Ref ref, { required int page, String search, })? create}) @@ -40,7 +36,7 @@ final class FetchPackagesProvider extends $FunctionalProvider< ); final FutureOr> Function( - FetchPackagesRef ref, { + Ref ref, { required int page, String search, })? _createCb; @@ -64,7 +60,7 @@ final class FetchPackagesProvider extends $FunctionalProvider< @override FetchPackagesProvider $copyWithCreate( FutureOr> Function( - FetchPackagesRef ref, + Ref ref, ) create, ) { return FetchPackagesProvider._( @@ -82,7 +78,7 @@ final class FetchPackagesProvider extends $FunctionalProvider< } @override - FutureOr> create(FetchPackagesRef ref) { + FutureOr> create(Ref ref) { final _$cb = _createCb ?? fetchPackages; final argument = this.argument as ({ int page, @@ -106,7 +102,7 @@ final class FetchPackagesProvider extends $FunctionalProvider< } } -String _$fetchPackagesHash() => r'46519fce4d1661e1358deac4d806374fa68f12c8'; +String _$fetchPackagesHash() => r'b52d4beb5d9ac53769d76ccd1d81bb005c66edd5'; final class FetchPackagesFamily extends Family { const FetchPackagesFamily._() @@ -136,7 +132,7 @@ final class FetchPackagesFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( FutureOr> Function( - FetchPackagesRef ref, + Ref ref, ({ int page, String search, @@ -161,4 +157,4 @@ final class FetchPackagesFamily extends Family { } } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/examples/pub/pubspec.yaml b/examples/pub/pubspec.yaml index 822f2e513..59d69f5b1 100644 --- a/examples/pub/pubspec.yaml +++ b/examples/pub/pubspec.yaml @@ -23,7 +23,7 @@ dependencies: dev_dependencies: build_runner: ^2.0.0 - custom_lint: ^0.6.5 + custom_lint: ^0.7.0 flutter_test: sdk: flutter freezed: ^2.1.0 diff --git a/examples/random_number/lib/main.dart b/examples/random_number/lib/main.dart index 39dff754d..6b5751916 100644 --- a/examples/random_number/lib/main.dart +++ b/examples/random_number/lib/main.dart @@ -2,26 +2,25 @@ import 'dart:math'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:flutter_riverpod/legacy.dart'; void main() { runApp(const ProviderScope(child: RandomNumberApp())); } -// State notifier for generating a random number exposed by a state notifier +// Notifier for generating a random number exposed by a state notifier // provider -class RandomNumberGenerator extends StateNotifier { - RandomNumberGenerator() : super(Random().nextInt(9999)); +class RandomNumberGenerator extends Notifier { + @override + int build() => Random().nextInt(9999); void generate() { state = Random().nextInt(9999); } } -// State notifier provider holding the state -final randomNumberProvider = StateNotifierProvider( - (ref) => RandomNumberGenerator(), -); +// Notifier provider holding the state +final randomNumberProvider = + NotifierProvider(RandomNumberGenerator.new); class RandomNumberApp extends StatelessWidget { const RandomNumberApp({super.key}); diff --git a/examples/random_number/pubspec.yaml b/examples/random_number/pubspec.yaml index f1d1e4c72..770d455bd 100644 --- a/examples/random_number/pubspec.yaml +++ b/examples/random_number/pubspec.yaml @@ -14,7 +14,7 @@ dependencies: mockito: ^5.0.13 dev_dependencies: - custom_lint: ^0.6.5 + custom_lint: ^0.7.0 flutter_lints: ^1.0.0 flutter_test: sdk: flutter diff --git a/examples/stackoverflow/lib/common.dart b/examples/stackoverflow/lib/common.dart index b8625183a..fa9380eb9 100644 --- a/examples/stackoverflow/lib/common.dart +++ b/examples/stackoverflow/lib/common.dart @@ -18,7 +18,7 @@ final client = Provider((ref) => Dio()); // this provider. dependencies: [], ) -ThemeData theme(ThemeRef ref) { +ThemeData theme(Ref ref) { throw UnimplementedError(); } diff --git a/examples/stackoverflow/lib/common.g.dart b/examples/stackoverflow/lib/common.g.dart index b982683fa..21effce3f 100644 --- a/examples/stackoverflow/lib/common.g.dart +++ b/examples/stackoverflow/lib/common.g.dart @@ -8,12 +8,6 @@ part of 'common.dart'; // RiverpodGenerator // ************************************************************************** -/// A Provider that exposes the current theme. -/// -/// This is unimplemented by default, and will be overridden inside [MaterialApp] -/// with the current theme obtained using a [BuildContext]. -typedef ThemeRef = Ref; - /// A Provider that exposes the current theme. /// /// This is unimplemented by default, and will be overridden inside [MaterialApp] @@ -26,14 +20,14 @@ const themeProvider = ThemeProvider._(); /// This is unimplemented by default, and will be overridden inside [MaterialApp] /// with the current theme obtained using a [BuildContext]. final class ThemeProvider extends $FunctionalProvider - with $Provider { + with $Provider { /// A Provider that exposes the current theme. /// /// This is unimplemented by default, and will be overridden inside [MaterialApp] /// with the current theme obtained using a [BuildContext]. const ThemeProvider._( {ThemeData Function( - ThemeRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -47,7 +41,7 @@ final class ThemeProvider extends $FunctionalProvider ); final ThemeData Function( - ThemeRef ref, + Ref ref, )? _createCb; @override @@ -69,20 +63,20 @@ final class ThemeProvider extends $FunctionalProvider @override ThemeProvider $copyWithCreate( ThemeData Function( - ThemeRef ref, + Ref ref, ) create, ) { return ThemeProvider._(create: create); } @override - ThemeData create(ThemeRef ref) { + ThemeData create(Ref ref) { final _$cb = _createCb ?? theme; return _$cb(ref); } } -String _$themeHash() => r'ff39eda97684261eefc24ddb24e41172880644cd'; +String _$themeHash() => r'0fea6438c8bee8be98515c10e8e67c2e75c6af46'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/examples/stackoverflow/lib/question.dart b/examples/stackoverflow/lib/question.dart index 14a065d0d..a44bd0fda 100644 --- a/examples/stackoverflow/lib/question.dart +++ b/examples/stackoverflow/lib/question.dart @@ -124,7 +124,7 @@ final questionThemeProvider = Provider((ref) { /// This is an optional step. Since scoping is a fairly advanced mechanism, /// it's entirely fine to simply pass the [Question] to [QuestionItem] directly. @Riverpod(dependencies: []) -AsyncValue currentQuestion(CurrentQuestionRef ref) { +AsyncValue currentQuestion(Ref ref) { throw UnimplementedError(); } diff --git a/examples/stackoverflow/lib/question.g.dart b/examples/stackoverflow/lib/question.g.dart index 159693d48..11f440f5d 100644 --- a/examples/stackoverflow/lib/question.g.dart +++ b/examples/stackoverflow/lib/question.g.dart @@ -63,20 +63,6 @@ Map _$$QuestionImplToJson(_$QuestionImpl instance) => // RiverpodGenerator // ************************************************************************** -/// A scoped provider, exposing the current question used by [QuestionItem]. -/// -/// This is used as a performance optimization to pass a [Question] to -/// [QuestionItem], while still instantiating [QuestionItem] using the `const` -/// keyword. -/// -/// This allows [QuestionItem] to rebuild less often. -/// By doing so, even when using [QuestionItem] in a [ListView], even if new -/// questions are obtained, previously rendered [QuestionItem]s won't rebuild. -/// -/// This is an optional step. Since scoping is a fairly advanced mechanism, -/// it's entirely fine to simply pass the [Question] to [QuestionItem] directly. -typedef CurrentQuestionRef = Ref>; - /// A scoped provider, exposing the current question used by [QuestionItem]. /// /// This is used as a performance optimization to pass a [Question] to @@ -106,7 +92,7 @@ const currentQuestionProvider = CurrentQuestionProvider._(); /// it's entirely fine to simply pass the [Question] to [QuestionItem] directly. final class CurrentQuestionProvider extends $FunctionalProvider, AsyncValue> - with $Provider, CurrentQuestionRef> { + with $Provider> { /// A scoped provider, exposing the current question used by [QuestionItem]. /// /// This is used as a performance optimization to pass a [Question] to @@ -121,7 +107,7 @@ final class CurrentQuestionProvider /// it's entirely fine to simply pass the [Question] to [QuestionItem] directly. const CurrentQuestionProvider._( {AsyncValue Function( - CurrentQuestionRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -135,7 +121,7 @@ final class CurrentQuestionProvider ); final AsyncValue Function( - CurrentQuestionRef ref, + Ref ref, )? _createCb; @override @@ -158,20 +144,20 @@ final class CurrentQuestionProvider @override CurrentQuestionProvider $copyWithCreate( AsyncValue Function( - CurrentQuestionRef ref, + Ref ref, ) create, ) { return CurrentQuestionProvider._(create: create); } @override - AsyncValue create(CurrentQuestionRef ref) { + AsyncValue create(Ref ref) { final _$cb = _createCb ?? currentQuestion; return _$cb(ref); } } -String _$currentQuestionHash() => r'2179e068c1d64674dc292a1a027e9e338284c57f'; +String _$currentQuestionHash() => r'e9359841a5b980cd7b8c79a0b56cb98878190861'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/examples/stackoverflow/lib/tag.dart b/examples/stackoverflow/lib/tag.dart index ac2f77963..d73659011 100644 --- a/examples/stackoverflow/lib/tag.dart +++ b/examples/stackoverflow/lib/tag.dart @@ -19,7 +19,7 @@ class TagTheme with _$TagTheme { } @Riverpod(dependencies: [theme]) -TagTheme tagTheme(TagThemeRef ref) { +TagTheme tagTheme(Ref ref) { final theme = ref.watch(themeProvider); return TagTheme( diff --git a/examples/stackoverflow/lib/tag.g.dart b/examples/stackoverflow/lib/tag.g.dart index ffb3b78f6..510f04b06 100644 --- a/examples/stackoverflow/lib/tag.g.dart +++ b/examples/stackoverflow/lib/tag.g.dart @@ -8,16 +8,14 @@ part of 'tag.dart'; // RiverpodGenerator // ************************************************************************** -typedef TagThemeRef = Ref; - @ProviderFor(tagTheme) const tagThemeProvider = TagThemeProvider._(); final class TagThemeProvider extends $FunctionalProvider - with $Provider { + with $Provider { const TagThemeProvider._( {TagTheme Function( - TagThemeRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -35,7 +33,7 @@ final class TagThemeProvider extends $FunctionalProvider static const $allTransitiveDependencies0 = themeProvider; final TagTheme Function( - TagThemeRef ref, + Ref ref, )? _createCb; @override @@ -57,20 +55,20 @@ final class TagThemeProvider extends $FunctionalProvider @override TagThemeProvider $copyWithCreate( TagTheme Function( - TagThemeRef ref, + Ref ref, ) create, ) { return TagThemeProvider._(create: create); } @override - TagTheme create(TagThemeRef ref) { + TagTheme create(Ref ref) { final _$cb = _createCb ?? tagTheme; return _$cb(ref); } } -String _$tagThemeHash() => r'bf5d051ea43e2f60d370096bb756aa81f21e9d68'; +String _$tagThemeHash() => r'ccf06d5f6b009c601edd44f88bf4f853708c38df'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/examples/stackoverflow/pubspec.yaml b/examples/stackoverflow/pubspec.yaml index ec52db7db..0767c7bdd 100644 --- a/examples/stackoverflow/pubspec.yaml +++ b/examples/stackoverflow/pubspec.yaml @@ -19,7 +19,7 @@ dependencies: dev_dependencies: build_runner: ^2.0.0 - custom_lint: ^0.6.5 + custom_lint: ^0.7.0 flutter_test: sdk: flutter freezed: ^2.1.0 diff --git a/examples/todos/pubspec.yaml b/examples/todos/pubspec.yaml index 3aacdc880..80697d4de 100644 --- a/examples/todos/pubspec.yaml +++ b/examples/todos/pubspec.yaml @@ -14,11 +14,11 @@ dependencies: path: ../../packages/hooks_riverpod riverpod: path: ../../packages/riverpod - uuid: ^3.0.4 + uuid: ^4.0.4 dev_dependencies: build_runner: ^2.0.0 - custom_lint: ^0.6.5 + custom_lint: ^0.7.0 flutter_test: sdk: flutter riverpod_lint: diff --git a/packages/flutter_riverpod/CHANGELOG.md b/packages/flutter_riverpod/CHANGELOG.md index 093798bd1..b405bc9c9 100644 --- a/packages/flutter_riverpod/CHANGELOG.md +++ b/packages/flutter_riverpod/CHANGELOG.md @@ -42,6 +42,23 @@ Fix exceptions when using multiple root `ProviderContainers`/`ProviderScopes`. - **Breaking**: Removed everything marked as "deprecated" - Bumped minimum Dart SDK to >= 3.0.0-dev +## 2.6.1 - 2024-10-22 + +- Added `AsyncNotifier.listenSelf`. It was mistakenly absent from the 2.6.0 release + +## 2.6.0 - 2024-10-20 + +- Deprecated all `Ref` subclasses. Instead, use `Ref` itself. +- Deprecated `Ref`'s type argument. Use `Ref` without its generic parameter instead. +- Deprecated any `Ref` member that used `Ref`'s generic (such as `Ref.state` or `Ref.listenSelf`). + Instead, use a `Notifier`. +- Added `Notifier.listenSelf`, as a replacement to `Ref.listenSelf`. +- `Ref.watch` and other methods now accept auto-dispose providers too. + +## 2.5.3 - 2024-10-12 + +- Fixed a typo in the documentation (thanks to @ljbkusters) + ## 2.5.2 - 2024-03-18 - Fixed various typos in the documentation (thanks to @kevalvavaliya) diff --git a/packages/flutter_riverpod/lib/src/builders.dart b/packages/flutter_riverpod/lib/src/builders.dart index ba87dc02b..42e60ae7c 100644 --- a/packages/flutter_riverpod/lib/src/builders.dart +++ b/packages/flutter_riverpod/lib/src/builders.dart @@ -230,7 +230,7 @@ class ChangeNotifierProviderFamilyBuilder { /// {@endtemplate} ChangeNotifierProviderFamily call( - NotifierT Function(Ref ref, ArgT param) create, { + NotifierT Function(Ref ref, ArgT param) create, { String? name, Iterable? dependencies, Retry? retry, @@ -302,7 +302,7 @@ class AutoDisposeChangeNotifierProviderBuilder { /// {@macro riverpod.family} ChangeNotifierProvider call( - NotifierT Function(Ref ref) create, { + NotifierT Function(Ref ref) create, { String? name, Iterable? dependencies, Retry? retry, @@ -328,7 +328,7 @@ class AutoDisposeChangeNotifierProviderFamilyBuilder { /// {@macro riverpod.family} ChangeNotifierProviderFamily call( - NotifierT Function(Ref ref, ArgT param) create, { + NotifierT Function(Ref ref, ArgT param) create, { String? name, Iterable? dependencies, Retry? retry, diff --git a/packages/flutter_riverpod/lib/src/core/consumer.dart b/packages/flutter_riverpod/lib/src/core/consumer.dart index d029ac4f1..853bc2ea7 100644 --- a/packages/flutter_riverpod/lib/src/core/consumer.dart +++ b/packages/flutter_riverpod/lib/src/core/consumer.dart @@ -20,7 +20,7 @@ typedef ConsumerBuilder = Widget Function( /// /// ```dart /// @riverpod -/// Future fetchUser(FetchUserRef ref) async { +/// Future fetchUser(Ref ref) async { /// // ... /// } /// ``` diff --git a/packages/flutter_riverpod/lib/src/providers/legacy/change_notifier_provider.dart b/packages/flutter_riverpod/lib/src/providers/legacy/change_notifier_provider.dart index 7baea1590..9d3d814b9 100644 --- a/packages/flutter_riverpod/lib/src/providers/legacy/change_notifier_provider.dart +++ b/packages/flutter_riverpod/lib/src/providers/legacy/change_notifier_provider.dart @@ -131,7 +131,7 @@ final class ChangeNotifierProvider /// has changes. Refreshable get notifier => _notifier(this); - final NotifierT Function(Ref ref) _createFn; + final NotifierT Function(Ref ref) _createFn; @internal @override @@ -145,7 +145,7 @@ final class ChangeNotifierProvider @visibleForOverriding @override ChangeNotifierProvider $copyWithCreate( - Create> create, + Create create, ) { return ChangeNotifierProvider.internal( create, @@ -172,7 +172,7 @@ class ChangeNotifierProviderElement void Function()? _removeListener; @override - void create(Ref ref, {required bool didChangeDependency}) { + void create(Ref ref, {required bool didChangeDependency}) { final notifierResult = _notifierNotifier.result = Result.guard( () => provider._createFn(ref), ); @@ -238,7 +238,7 @@ class ChangeNotifierProviderFamily @override Override overrideWith( - NotifierT Function(Ref ref, Arg arg) create, + NotifierT Function(Ref ref, Arg arg) create, ) { return $FamilyOverride( from: this, diff --git a/packages/flutter_riverpod/test/provider_test.dart b/packages/flutter_riverpod/test/provider_test.dart index 5c6b9d8f8..202eadeaf 100644 --- a/packages/flutter_riverpod/test/provider_test.dart +++ b/packages/flutter_riverpod/test/provider_test.dart @@ -290,7 +290,7 @@ void main() { final provider = Provider((_) => 42); // These check the type safety - Ref? ref; + Ref? ref; final Provider provider1 = Provider((r) { final first = r.watch(provider); diff --git a/packages/flutter_riverpod/test/providers/change_notifier/auto_dispose_change_notifier_provider_test.dart b/packages/flutter_riverpod/test/providers/change_notifier/auto_dispose_change_notifier_provider_test.dart index 03388db56..9c15be3cf 100644 --- a/packages/flutter_riverpod/test/providers/change_notifier/auto_dispose_change_notifier_provider_test.dart +++ b/packages/flutter_riverpod/test/providers/change_notifier/auto_dispose_change_notifier_provider_test.dart @@ -1,11 +1,8 @@ -// 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/widgets.dart' hide Listener; import 'package:flutter_riverpod/src/internals.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:mockito/mockito.dart'; - -import '../../utils.dart'; void main() { group('ChangeNotifierProvider.autoDispose', () { @@ -21,22 +18,6 @@ void main() { container.dispose(); }); - test('can read and set current ChangeNotifier', () async { - final container = ProviderContainer.test(); - final listener = Listener>(); - late Ref> ref; - final provider = - ChangeNotifierProvider.autoDispose>((r) { - ref = r; - return ValueNotifier(0); - }); - - container.listen(provider, listener.call); - - verifyZeroInteractions(listener); - expect(ref.state.value, 0); - }); - test('can refresh .notifier', () async { var initialValue = 1; final provider = ChangeNotifierProvider.autoDispose>( diff --git a/packages/flutter_riverpod/test/providers/change_notifier/change_notifier_provider_test.dart b/packages/flutter_riverpod/test/providers/change_notifier/change_notifier_provider_test.dart index da60c932b..0585c526a 100644 --- a/packages/flutter_riverpod/test/providers/change_notifier/change_notifier_provider_test.dart +++ b/packages/flutter_riverpod/test/providers/change_notifier/change_notifier_provider_test.dart @@ -1,11 +1,10 @@ -// ignore_for_file: invalid_use_of_internal_member, avoid_types_on_closure_parameters +// ignore_for_file: invalid_use_of_internal_member, avoid_types_on_closure_parameters, deprecated_member_use_from_same_package, deprecated_member_use import 'dart:async'; import 'package:flutter/widgets.dart' hide Listener; import 'package:flutter_riverpod/src/internals.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:mockito/mockito.dart'; import '../../utils.dart'; @@ -38,12 +37,8 @@ void main() { final container = ProviderContainer.test( overrides: [ - provider.overrideWith( - (Ref> ref) => ValueNotifier(42), - ), - autoDispose.overrideWith( - (Ref> ref) => ValueNotifier(84), - ), + provider.overrideWith((ref) => ValueNotifier(42)), + autoDispose.overrideWith((ref) => ValueNotifier(84)), ], ); @@ -61,12 +56,9 @@ void main() { ); final container = ProviderContainer.test( overrides: [ - family.overrideWith( - (Ref> ref, int arg) => ValueNotifier('42 $arg'), - ), - autoDisposeFamily.overrideWith( - (Ref> ref, int arg) => ValueNotifier('84 $arg'), - ), + family.overrideWith((ref, int arg) => ValueNotifier('42 $arg')), + autoDisposeFamily + .overrideWith((ref, int arg) => ValueNotifier('84 $arg')), ], ); @@ -74,23 +66,6 @@ void main() { expect(container.read(autoDisposeFamily(10)).value, '84 10'); }); - test('ref.listenSelf listens to state changes', () { - final listener = Listener>(); - final container = ProviderContainer.test(); - final provider = ChangeNotifierProvider>((ref) { - ref.listenSelf(listener.call); - return ValueNotifier(0); - }); - - final notifier = container.read(provider); - - verifyOnly(listener, listener(null, notifier)); - - container.read(provider.notifier).value++; - - verifyOnly(listener, listener(notifier, notifier)); - }); - test('support null ChangeNotifier', () { final container = ProviderContainer.test(); final provider = ChangeNotifierProvider?>((ref) => null); @@ -101,21 +76,6 @@ void main() { container.dispose(); }); - test('can read and set current ChangeNotifier', () async { - final container = ProviderContainer.test(); - final listener = Listener>(); - late Ref> ref; - final provider = ChangeNotifierProvider>((r) { - ref = r; - return ValueNotifier(0); - }); - - container.listen(provider, listener.call); - - verifyZeroInteractions(listener); - expect(ref.state.value, 0); - }); - test('can refresh .notifier', () async { var initialValue = 1; final provider = ChangeNotifierProvider>( diff --git a/packages/hooks_riverpod/CHANGELOG.md b/packages/hooks_riverpod/CHANGELOG.md index 1688eec2d..0cd6a306f 100644 --- a/packages/hooks_riverpod/CHANGELOG.md +++ b/packages/hooks_riverpod/CHANGELOG.md @@ -35,6 +35,23 @@ Fix exceptions when using multiple root `ProviderContainers`/`ProviderScopes`. - **Breaking**: Removed everything marked as "deprecated" - Bumped minimum Dart SDK to >= 3.0.0-dev +## 2.6.1 - 2024-10-22 + +- Added `AsyncNotifier.listenSelf`. It was mistakenly absent from the 2.6.0 release + +## 2.6.0 - 2024-10-20 + +- Deprecated all `Ref` subclasses. Instead, use `Ref` itself. +- Deprecated `Ref`'s type argument. Use `Ref` without its generic parameter instead. +- Deprecated any `Ref` member that used `Ref`'s generic (such as `Ref.state` or `Ref.listenSelf`). + Instead, use a `Notifier`. +- Added `Notifier.listenSelf`, as a replacement to `Ref.listenSelf`. +- `Ref.watch` and other methods now accept auto-dispose providers too. + +## 2.5.3 - 2024-10-12 + +- Fixed a typo in the documentation (thanks to @ljbkusters) + ## 2.5.2 - 2024-08-15 - Added mutation pending state to example (thanks to @luketg8) diff --git a/packages/hooks_riverpod/test/analysis_options.yaml b/packages/hooks_riverpod/test/analysis_options.yaml new file mode 100644 index 000000000..38c1cf1a8 --- /dev/null +++ b/packages/hooks_riverpod/test/analysis_options.yaml @@ -0,0 +1,5 @@ +import: "../../analysis_options.yaml" + +analyzer: + errors: + deprecated_member_use_from_same_package: false diff --git a/packages/riverpod/CHANGELOG.md b/packages/riverpod/CHANGELOG.md index c9712f2b7..7c42ef9e4 100644 --- a/packages/riverpod/CHANGELOG.md +++ b/packages/riverpod/CHANGELOG.md @@ -17,8 +17,9 @@ rebuilds. This enables using `Ref.mounted` to check dispose. - **Breaking**: `StreamProvider` now pauses its `StreamSubscription` when the provider is not actively listened. +- **Breaking**: Calling ref.watch multiple times calls ref.onListen every-times. - **Breaking**: A provider is now considered "paused" if all - of its listeners are also paused. So if a provider `A` is watched _only_ by a provider `B`, and `B` is currently unused, + of its listeners are also paused. So if a provider `A` is watched _only_ by a provider `B`, and `B` is currently unused, then `A` will be paused. - Added `Ref.listen(..., weak: true)`. When specifying `weak: true`, the listener will not cause the provider to be @@ -75,6 +76,23 @@ Fix exceptions when using multiple root `ProviderContainers`/`ProviderScopes`. - **Breaking**: Removed everything marked as "deprecated" - Bumped minimum Dart SDK to >= 3.0.0-dev +## 2.6.1 - 2024-10-22 + +- Added `AsyncNotifier.listenSelf`. It was mistakenly absent from the 2.6.0 release + +## 2.6.0 - 2024-10-20 + +- Deprecated all `Ref` subclasses. Instead, use `Ref` itself. +- Deprecated `Ref`'s type argument. Use `Ref` without its generic parameter instead. +- Deprecated any `Ref` member that used `Ref`'s generic (such as `Ref.state` or `Ref.listenSelf`). + Instead, use a `Notifier`. +- Added `Notifier.listenSelf`, as a replacement to `Ref.listenSelf`. +- `Ref.watch` and other methods now accept auto-dispose providers too. + +## 2.5.3 - 2024-10-12 + +- Fixed a typo in the documentation (thanks to @ljbkusters) + ## 2.5.1 - 2024-03-10 - Improved `Provider(dependencies: [...])` documentation. diff --git a/packages/riverpod/lib/src/builder.dart b/packages/riverpod/lib/src/builder.dart index eb530a5e6..219444bc6 100644 --- a/packages/riverpod/lib/src/builder.dart +++ b/packages/riverpod/lib/src/builder.dart @@ -229,7 +229,7 @@ class StateProviderFamilyBuilder { /// ``` /// {@endtemplate} StateProviderFamily call( - StateT Function(Ref ref, ArgT param) create, { + StateT Function(Ref ref, ArgT param) create, { String? name, Iterable? dependencies, Retry? retry, @@ -301,7 +301,7 @@ class AutoDisposeStateProviderBuilder { /// {@macro riverpod.family} StateProvider call( - StateT Function(Ref ref) create, { + StateT Function(Ref ref) create, { String? name, Iterable? dependencies, Retry? retry, @@ -326,7 +326,7 @@ class AutoDisposeStateProviderFamilyBuilder { /// {@macro riverpod.family} StateProviderFamily call( - StateT Function(Ref ref, ArgT param) create, { + StateT Function(Ref ref, ArgT param) create, { String? name, Iterable? dependencies, Retry? retry, @@ -348,7 +348,7 @@ class StateNotifierProviderFamilyBuilder { /// {@macro riverpod.family} StateNotifierProviderFamily call, StateT, ArgT>( - NotifierT Function(Ref ref, ArgT param) create, { + NotifierT Function(Ref ref, ArgT param) create, { String? name, Iterable? dependencies, Retry? retry, @@ -373,7 +373,7 @@ class AutoDisposeStateNotifierProviderBuilder { /// {@macro riverpod.family} StateNotifierProvider call, StateT>( - NotifierT Function(Ref ref) create, { + NotifierT Function(Ref ref) create, { String? name, Iterable? dependencies, Retry? retry, @@ -399,7 +399,7 @@ class AutoDisposeStateNotifierProviderFamilyBuilder { /// {@macro riverpod.family} StateNotifierProviderFamily call, StateT, ArgT>( - NotifierT Function(Ref ref, ArgT param) create, { + NotifierT Function(Ref ref, ArgT param) create, { String? name, Iterable? dependencies, Retry? retry, @@ -420,7 +420,7 @@ class ProviderFamilyBuilder { /// {@macro riverpod.family} ProviderFamily call( - StateT Function(Ref ref, ArgT param) create, { + StateT Function(Ref ref, ArgT param) create, { String? name, Iterable? dependencies, Retry? retry, @@ -444,7 +444,7 @@ class AutoDisposeProviderBuilder { /// {@macro riverpod.family} Provider call( - StateT Function(Ref ref) create, { + StateT Function(Ref ref) create, { String? name, Iterable? dependencies, Retry? retry, @@ -469,7 +469,7 @@ class AutoDisposeProviderFamilyBuilder { /// {@macro riverpod.family} ProviderFamily call( - StateT Function(Ref ref, ArgT param) create, { + StateT Function(Ref ref, ArgT param) create, { String? name, Iterable? dependencies, Retry? retry, @@ -490,7 +490,7 @@ class FutureProviderFamilyBuilder { /// {@macro riverpod.family} FutureProviderFamily call( - FutureOr Function(Ref> ref, ArgT param) create, { + FutureOr Function(Ref ref, ArgT param) create, { String? name, Iterable? dependencies, Retry? retry, @@ -514,7 +514,7 @@ class AutoDisposeFutureProviderBuilder { /// {@macro riverpod.family} FutureProvider call( - FutureOr Function(Ref> ref) create, { + FutureOr Function(Ref ref) create, { String? name, Iterable? dependencies, Retry? retry, @@ -539,7 +539,7 @@ class AutoDisposeFutureProviderFamilyBuilder { /// {@macro riverpod.family} FutureProviderFamily call( - FutureOr Function(Ref> ref, ArgT param) create, { + FutureOr Function(Ref ref, ArgT param) create, { String? name, Iterable? dependencies, Retry? retry, @@ -560,7 +560,7 @@ class StreamProviderFamilyBuilder { /// {@macro riverpod.family} StreamProviderFamily call( - Stream Function(Ref> ref, ArgT param) create, { + Stream Function(Ref ref, ArgT param) create, { String? name, Iterable? dependencies, Retry? retry, @@ -584,7 +584,7 @@ class AutoDisposeStreamProviderBuilder { /// {@macro riverpod.family} StreamProvider call( - Stream Function(Ref> ref) create, { + Stream Function(Ref ref) create, { String? name, Iterable? dependencies, Retry? retry, @@ -609,7 +609,7 @@ class AutoDisposeStreamProviderFamilyBuilder { /// {@macro riverpod.family} StreamProviderFamily call( - Stream Function(Ref> ref, ArgT param) create, { + Stream Function(Ref ref, ArgT param) create, { String? name, Iterable? dependencies, Retry? retry, diff --git a/packages/riverpod/lib/src/core/async_value.dart b/packages/riverpod/lib/src/core/async_value.dart index 3ef0156a7..2e24a1ee8 100644 --- a/packages/riverpod/lib/src/core/async_value.dart +++ b/packages/riverpod/lib/src/core/async_value.dart @@ -186,7 +186,7 @@ sealed class AsyncValue { /// /// ```dart /// @riverpod - /// Future example(ExampleRef ref) async { + /// Future example(Ref ref) async { /// ref.state = AsyncLoading(progress: 0); /// /// await something(); diff --git a/packages/riverpod/lib/src/core/element.dart b/packages/riverpod/lib/src/core/element.dart index 53e0b9b97..e8b408d91 100644 --- a/packages/riverpod/lib/src/core/element.dart +++ b/packages/riverpod/lib/src/core/element.dart @@ -72,7 +72,8 @@ abstract class ProviderElement implements Node { /// The [ProviderContainer] that owns this [ProviderElement]. ProviderContainer get container => pointer.targetContainer; - Ref? ref; + // ignore: library_private_types_in_public_api, not public + _Ref? ref; /// Whether this [ProviderElement] is actively in use. /// @@ -229,7 +230,7 @@ This could mean a few things: _debugCurrentCreateHash = provider.debugGetCreateSourceHash(); } - final ref = this.ref = Ref._(this); + final ref = this.ref = _Ref(this); buildState(ref); _notifyListeners( @@ -254,7 +255,7 @@ This could mean a few things: /// to dependencies that are no-longer used. void _performBuild() { runOnDispose(); - final ref = this.ref = Ref._(this); + final ref = this.ref = _Ref(this); final previousStateResult = _stateResult; if (kDebugMode) _debugDidSetState = false; @@ -282,7 +283,11 @@ This could mean a few things: /// - [didChangeDependency] can be used to differentiate a rebuild caused /// by [Ref.watch] from one caused by [Ref.refresh]/[Ref.invalidate]. @visibleForOverriding - void create(Ref ref, {required bool didChangeDependency}); + void create( + // ignore: library_private_types_in_public_api, not public + _Ref ref, { + required bool didChangeDependency, + }); /// A utility for re-initializing a provider when needed. /// @@ -323,7 +328,10 @@ This could mean a few things: /// Invokes [create] and handles errors. @internal - void buildState(Ref ref) { + void buildState( + // ignore: library_private_types_in_public_api, not public + _Ref ref, + ) { if (_didChangeDependency) _retryCount = 0; ProviderElement? debugPreviouslyBuildingElement; diff --git a/packages/riverpod/lib/src/core/family.dart b/packages/riverpod/lib/src/core/family.dart index 10dedc617..63e48623a 100644 --- a/packages/riverpod/lib/src/core/family.dart +++ b/packages/riverpod/lib/src/core/family.dart @@ -5,10 +5,9 @@ part of '../framework.dart'; typedef FunctionalProviderFactory< // ProviderT, CreatedT, - RefT extends Ref, ArgT> = ProviderT Function( - Create create, { + Create create, { required String? name, required List? dependencies, required List? allTransitiveDependencies, @@ -24,15 +23,13 @@ typedef ClassProviderFactory< // NotifierT, ProviderT, CreatedT, - RefT extends Ref, ArgT> = ProviderT Function( NotifierT Function() create, { required String? name, required Iterable? dependencies, required Iterable? allTransitiveDependencies, - required RunNotifierBuild? - runNotifierBuildOverride, + required RunNotifierBuild? runNotifierBuildOverride, required bool isAutoDispose, required Family from, required ArgT argument, @@ -41,8 +38,7 @@ typedef ClassProviderFactory< // /// A [Create] equivalent used by [Family]. @internal -typedef FamilyCreate, ArgT> = CreatedT - Function(RefT ref, ArgT arg); +typedef FamilyCreate = CreatedT Function(Ref ref, ArgT arg); /// A base class for all families abstract class Family extends ProviderOrFamily implements _FamilyOverride { @@ -85,7 +81,7 @@ class FunctionalFamily< // /// This API is not meant for public consumption. const FunctionalFamily( this._createFn, { - required FunctionalProviderFactory, ArgT> + required FunctionalProviderFactory providerFactory, required super.name, required super.dependencies, @@ -94,10 +90,9 @@ class FunctionalFamily< // required super.retry, }) : _providerFactory = providerFactory; - final FunctionalProviderFactory, ArgT> - _providerFactory; + final FunctionalProviderFactory _providerFactory; - final CreatedT Function(Ref ref, ArgT arg) _createFn; + final CreatedT Function(Ref ref, ArgT arg) _createFn; /// {@template family.call} /// Create a provider from an external value. @@ -123,7 +118,7 @@ class FunctionalFamily< // /// {@macro riverpod.override_with} Override overrideWith( - CreatedT Function(Ref ref, ArgT arg) create, + CreatedT Function(Ref ref, ArgT arg) create, ) { return $FamilyOverride( from: this, @@ -148,14 +143,14 @@ class FunctionalFamily< // /// This API is not meant for public consumption. @internal class ClassFamily< // - NotifierT extends NotifierBase< // + NotifierT extends NotifierBase< // + StateT, + CreatedT>, StateT, - CreatedT>, - StateT, - ArgT, - CreatedT, - ProviderT extends $ClassProvider>> extends Family { + ArgT, + CreatedT, + ProviderT extends $ClassProvider> + extends Family { /// A base implementation for [Family], used by the various providers to /// help them define a [Family]. /// @@ -171,7 +166,7 @@ class ClassFamily< // }); @internal - final ClassProviderFactory, ArgT> + final ClassProviderFactory providerFactory; final NotifierT Function() _createFn; @@ -208,7 +203,7 @@ class ClassFamily< // /// {@macro riverpod.override_with} Override overrideWithBuild( - RunNotifierBuild> build, + RunNotifierBuild build, ) { return $FamilyOverride( from: this, diff --git a/packages/riverpod/lib/src/core/override_with_value.dart b/packages/riverpod/lib/src/core/override_with_value.dart index b7b16fc13..670b85968 100644 --- a/packages/riverpod/lib/src/core/override_with_value.dart +++ b/packages/riverpod/lib/src/core/override_with_value.dart @@ -72,7 +72,7 @@ class _ValueProviderElement extends ProviderElement { void _setValue(StateT value) => setStateResult(ResultData(value)); @override - void create(Ref ref, {required bool didChangeDependency}) { + void create(Ref ref, {required bool didChangeDependency}) { _setValue(provider._value); } diff --git a/packages/riverpod/lib/src/core/provider/functional_provider.dart b/packages/riverpod/lib/src/core/provider/functional_provider.dart index c73ffce86..e34891e96 100644 --- a/packages/riverpod/lib/src/core/provider/functional_provider.dart +++ b/packages/riverpod/lib/src/core/provider/functional_provider.dart @@ -23,7 +23,7 @@ abstract base class $FunctionalProvider< // /// This is an implementation detail of Riverpod and should not be used. @visibleForOverriding $FunctionalProvider $copyWithCreate( - Create> create, + Create create, ); /// {@template riverpod.override_with} @@ -60,7 +60,7 @@ abstract base class $FunctionalProvider< // /// ); /// ``` /// {@endtemplate} - Override overrideWith(Create> create) { + Override overrideWith(Create create) { return $ProviderOverride( origin: this, providerOverride: $copyWithCreate(create), diff --git a/packages/riverpod/lib/src/core/provider/notifier_provider.dart b/packages/riverpod/lib/src/core/provider/notifier_provider.dart index dd2496991..db3ef4566 100644 --- a/packages/riverpod/lib/src/core/provider/notifier_provider.dart +++ b/packages/riverpod/lib/src/core/provider/notifier_provider.dart @@ -24,11 +24,10 @@ This means that you tried to either: /// The prototype of `Notifier.build` overrides. @internal -typedef RunNotifierBuild< // - NotifierT, - CreatedT, - RefT extends Ref> - = CreatedT Function(RefT ref, NotifierT notifier); +typedef RunNotifierBuild = CreatedT Function( + Ref ref, + NotifierT notifier, +); /// A base class for all "notifiers". /// @@ -55,23 +54,32 @@ typedef RunNotifierBuild< // /// } /// ``` abstract class NotifierBase { - Ref? _ref; - + _Ref? _ref; @protected - Ref get ref { - final ref = _ref; - if (ref == null) throw StateError(uninitializedElementError); - - return ref; + Ref get ref => $ref; + + /// Listens to changes on the value exposed by this provider. + /// + /// The listener will be called immediately after the provider completes building. + /// + /// As opposed to [Ref.listen], the listener will be called even if + /// [updateShouldNotify] returns false, meaning that the previous + /// and new value can potentially be identical. + @protected + void listenSelf( + void Function(StateT? previous, StateT next) listener, { + void Function(Object error, StackTrace stackTrace)? onError, + }) { + $ref.listenSelf(listener, onError: onError); } @visibleForTesting @protected - StateT get state => ref.state; + StateT get state => $ref.state; @visibleForTesting @protected - set state(StateT newState) => ref.state = newState; + set state(StateT newState) => $ref.state = newState; CreatedT runBuild(); @@ -82,6 +90,15 @@ abstract class NotifierBase { @internal extension ClassBaseX on NotifierBase { ProviderElement? get element => _ref?._element; + + @internal + // ignore: library_private_types_in_public_api, not public + _Ref get $ref { + final ref = _ref; + if (ref == null) throw StateError(uninitializedElementError); + + return ref; + } } /// Implementation detail of `riverpod_generator`. @@ -91,8 +108,7 @@ abstract base class $ClassProvider< // StateT, CreatedT>, StateT, - CreatedT, - RefT extends Ref> extends ProviderBase { + CreatedT> extends ProviderBase { const $ClassProvider({ required super.name, required super.from, @@ -114,19 +130,19 @@ abstract base class $ClassProvider< // } @internal - final RunNotifierBuild? runNotifierBuildOverride; + final RunNotifierBuild? runNotifierBuildOverride; @internal NotifierT create(); @visibleForOverriding - $ClassProvider $copyWithCreate( + $ClassProvider $copyWithCreate( NotifierT Function() create, ); @visibleForOverriding - $ClassProvider $copyWithBuild( - RunNotifierBuild build, + $ClassProvider $copyWithBuild( + RunNotifierBuild build, ); /// {@macro riverpod.override_with} @@ -141,7 +157,7 @@ abstract base class $ClassProvider< // /// Hello world /// {@endtemplate} Override overrideWithBuild( - RunNotifierBuild build, + RunNotifierBuild build, ) { return $ProviderOverride( origin: this, @@ -167,14 +183,15 @@ abstract class ClassProviderElement< // ClassProviderElement(super.pointer); @override - $ClassProvider> get provider; + $ClassProvider get provider; final classListenable = ProxyElementValueListenable(); @mustCallSuper @override void create( - Ref ref, { + // ignore: library_private_types_in_public_api, not public + _Ref ref, { required bool didChangeDependency, }) { final seamless = !didChangeDependency; diff --git a/packages/riverpod/lib/src/core/provider/provider.dart b/packages/riverpod/lib/src/core/provider/provider.dart index a9dd865eb..866e5bb19 100644 --- a/packages/riverpod/lib/src/core/provider/provider.dart +++ b/packages/riverpod/lib/src/core/provider/provider.dart @@ -13,9 +13,7 @@ part of '../../framework.dart'; /// - [Ref], which exposes the methods to read other providers. /// - [Provider], a provider that uses [Create] to expose an immutable value. @internal -typedef Create> = CreatedT Function( - RefT ref, -); +typedef Create = CreatedT Function(Ref ref); /// A callback used to catches errors @internal diff --git a/packages/riverpod/lib/src/core/provider_container.dart b/packages/riverpod/lib/src/core/provider_container.dart index 3ac08842c..05be79843 100644 --- a/packages/riverpod/lib/src/core/provider_container.dart +++ b/packages/riverpod/lib/src/core/provider_container.dart @@ -289,8 +289,6 @@ class ProviderPointerManager { (e) { if (e.key.allTransitiveDependencies == null) return e; - // TODO don't fork a family if no family(42) is overridden - return MapEntry(e.key, ProviderDirectory.from(e.value)); }, ), diff --git a/packages/riverpod/lib/src/core/ref.dart b/packages/riverpod/lib/src/core/ref.dart index afd6015de..b401bee2d 100644 --- a/packages/riverpod/lib/src/core/ref.dart +++ b/packages/riverpod/lib/src/core/ref.dart @@ -1,7 +1,7 @@ part of '../framework.dart'; @internal -extension $RefArg on Ref { +extension $RefArg on Ref { // Implementation detail, do not use Object? get $arg => _element.origin.argument; @@ -37,44 +37,19 @@ Cannot use the Ref of $origin after it has been disposed. This typically happens /// - [read] and [watch], two methods that allow a provider to consume other providers. /// - [onDispose], a method that allows performing a task when the provider is destroyed. /// {@endtemplate} -base class Ref { - /// {@macro riverpod.provider_ref_base} - Ref._(this._element); - - final ProviderElement _element; +@optionalTypeArgs +sealed class Ref { + ProviderElement get _element; List? _keepAliveLinks; - List? _onChangeSelfListeners; List? _onDisposeListeners; List? _onResumeListeners; List? _onCancelListeners; List? _onAddListeners; List? _onRemoveListeners; - List? _onErrorSelfListeners; bool get mounted => _mounted; var _mounted = true; - /// Obtains the state currently exposed by this provider. - /// - /// Mutating this property will notify the provider listeners. - /// - /// If called before a value was set, there are two possible scenarios: - /// - on synchronous providers, this will throw a [StateError]. - /// - on asynchronous providers, this will return an [AsyncLoading]. - /// - /// Will throw if the provider threw during creation. - StateT get state { - _throwIfInvalidUsage(); - - return _element.readSelf(); - } - - set state(StateT newState) { - _throwIfInvalidUsage(); - - _element.setStateResult(ResultData(newState)); - } - /// The [ProviderContainer] that this provider is associated with. ProviderContainer get container => _element.container; @@ -210,10 +185,14 @@ final = Provider(dependencies: []); } /// {@template riverpod.invalidate} - /// Invalidates the state of the provider, causing it to refresh. + /// Invalidates the state of the provider, destroying the state immediately + /// and causing the provider to rebuild at some point in the future. /// - /// As opposed to [refresh], the refresh is not immediate and is instead - /// delayed to the next read or next frame. + /// As opposed to [refresh], the rebuild is not immediate and is instead + /// delayed by an undefined amount of time. + /// Typically, the rebuild happens at the next tick of the event loop. + /// But if a provider is not listened to, the rebuild may be delayed until + /// the provider is listened to again. /// /// Calling [invalidate] multiple times will refresh the provider only /// once. @@ -407,7 +386,7 @@ final = Provider(dependencies: []); /// class MyService { /// MyService(this.ref); /// - /// final Ref ref; + /// final Ref ref; /// /// Future fetchUser() { /// // We read the current configurations, but do not care about @@ -592,6 +571,38 @@ final = Provider(dependencies: []); fireImmediately: fireImmediately, ); } +} + +class _Ref extends Ref { + /// {@macro riverpod.provider_ref_base} + _Ref(this._element); + + @override + final ProviderElement _element; + + List? _onChangeSelfListeners; + List? _onErrorSelfListeners; + + /// Obtains the state currently exposed by this provider. + /// + /// Mutating this property will notify the provider listeners. + /// + /// If called before a value was set, there are two possible scenarios: + /// - on synchronous providers, this will throw a [StateError]. + /// - on asynchronous providers, this will return an [AsyncLoading]. + /// + /// Will throw if the provider threw during creation. + StateT get state { + _throwIfInvalidUsage(); + + return _element.readSelf(); + } + + set state(StateT newState) { + _throwIfInvalidUsage(); + + _element.setStateResult(ResultData(newState)); + } /// Listens to changes on the value exposed by this provider. /// diff --git a/packages/riverpod/lib/src/providers/async_notifier.dart b/packages/riverpod/lib/src/providers/async_notifier.dart index 380c73319..a0ec15738 100644 --- a/packages/riverpod/lib/src/providers/async_notifier.dart +++ b/packages/riverpod/lib/src/providers/async_notifier.dart @@ -27,8 +27,7 @@ abstract base class $AsyncNotifierProvider< // extends $ClassProvider< // NotifierT, AsyncValue, - FutureOr, - Ref>> // + FutureOr> // with $FutureModifier { /// Implementation detail of `riverpod_generator`. diff --git a/packages/riverpod/lib/src/providers/async_notifier/family.dart b/packages/riverpod/lib/src/providers/async_notifier/family.dart index 21142ea3c..18cc23b73 100644 --- a/packages/riverpod/lib/src/providers/async_notifier/family.dart +++ b/packages/riverpod/lib/src/providers/async_notifier/family.dart @@ -75,8 +75,7 @@ final class FamilyAsyncNotifierProvider< // FamilyAsyncNotifierProvider _copyWith({ NotifierT Function()? create, - RunNotifierBuild, Ref>>? - build, + RunNotifierBuild>? build, }) { return FamilyAsyncNotifierProvider._( create ?? _createNotifier, @@ -109,8 +108,7 @@ final class FamilyAsyncNotifierProvider< // @visibleForOverriding @override FamilyAsyncNotifierProvider $copyWithBuild( - RunNotifierBuild, Ref>>? - build, + RunNotifierBuild>? build, ) { return _copyWith(build: build); } diff --git a/packages/riverpod/lib/src/providers/async_notifier/orphan.dart b/packages/riverpod/lib/src/providers/async_notifier/orphan.dart index a8d91f19f..d76222ee1 100644 --- a/packages/riverpod/lib/src/providers/async_notifier/orphan.dart +++ b/packages/riverpod/lib/src/providers/async_notifier/orphan.dart @@ -104,8 +104,7 @@ final class AsyncNotifierProvider< // AsyncNotifierProvider _copyWith({ NotifierT Function()? create, - RunNotifierBuild, Ref>>? - build, + RunNotifierBuild>? build, }) { return AsyncNotifierProvider.internal( create ?? _createNotifier, @@ -132,8 +131,7 @@ final class AsyncNotifierProvider< // @visibleForOverriding @override AsyncNotifierProvider $copyWithBuild( - RunNotifierBuild, Ref>>? - build, + RunNotifierBuild>? build, ) { return _copyWith(build: build); } diff --git a/packages/riverpod/lib/src/providers/future_provider.dart b/packages/riverpod/lib/src/providers/future_provider.dart index a9ed4e201..6c5bea9c2 100644 --- a/packages/riverpod/lib/src/providers/future_provider.dart +++ b/packages/riverpod/lib/src/providers/future_provider.dart @@ -12,8 +12,8 @@ import 'stream_provider.dart' show StreamProvider; /// Implementation detail of `riverpod_generator`. /// Do not use, as this may be removed at any time. @internal -base mixin $FutureProvider on ProviderBase> { - FutureOr create(RefT ref); +base mixin $FutureProvider on ProviderBase> { + FutureOr create(Ref ref); /// {@macro riverpod.override_with_value} Override overrideWithValue(AsyncValue value) { @@ -96,7 +96,7 @@ final class FutureProvider extends $FunctionalProvider, FutureOr> with $FutureModifier, - $FutureProvider>>, + $FutureProvider, LegacyProviderMixin> { /// {@macro riverpod.future_provider} FutureProvider( @@ -131,10 +131,10 @@ final class FutureProvider /// {@macro riverpod.family} static const family = FutureProviderFamilyBuilder(); - final Create, Ref>> _create; + final Create> _create; @override - FutureOr create(Ref> ref) => this._create(ref); + FutureOr create(Ref ref) => this._create(ref); @internal @override @@ -146,7 +146,7 @@ final class FutureProvider @visibleForOverriding @override FutureProvider $copyWithCreate( - Create, Ref>> create, + Create> create, ) { return FutureProvider.internal( create, @@ -171,11 +171,11 @@ class $FutureProviderElement extends ProviderElement> $FutureProviderElement(this.provider, super.pointer); @override - final $FutureProvider>> provider; + final $FutureProvider provider; @override void create( - Ref> ref, { + Ref ref, { required bool didChangeDependency, }) { handleFuture( diff --git a/packages/riverpod/lib/src/providers/legacy/state_notifier_provider.dart b/packages/riverpod/lib/src/providers/legacy/state_notifier_provider.dart index de3fe65fb..60f8bd8ae 100644 --- a/packages/riverpod/lib/src/providers/legacy/state_notifier_provider.dart +++ b/packages/riverpod/lib/src/providers/legacy/state_notifier_provider.dart @@ -118,7 +118,7 @@ final class StateNotifierProvider< // /// {@macro riverpod.family} static const family = StateNotifierProviderFamilyBuilder(); - final NotifierT Function(Ref ref) _create; + final NotifierT Function(Ref ref) _create; /// Obtains the [StateNotifier] associated with this provider, without listening /// to state changes. @@ -149,7 +149,7 @@ final class StateNotifierProvider< // @visibleForOverriding @override StateNotifierProvider $copyWithCreate( - Create> create, + Create create, ) { return StateNotifierProvider.internal( create, @@ -177,7 +177,7 @@ class StateNotifierProviderElement, void Function()? _removeListener; @override - void create(Ref ref, {required bool didChangeDependency}) { + void create(Ref ref, {required bool didChangeDependency}) { final notifier = _notifierNotifier.result = Result.guard( () => provider._create(ref), ); diff --git a/packages/riverpod/lib/src/providers/legacy/state_provider.dart b/packages/riverpod/lib/src/providers/legacy/state_provider.dart index 4d1b3cdaa..ed2ca1c31 100644 --- a/packages/riverpod/lib/src/providers/legacy/state_provider.dart +++ b/packages/riverpod/lib/src/providers/legacy/state_provider.dart @@ -83,7 +83,7 @@ final class StateProvider extends $FunctionalProvider /// {@macro riverpod.family} static const family = StateProviderFamilyBuilder(); - final StateT Function(Ref ref) _createFn; + final StateT Function(Ref ref) _createFn; Refreshable> get notifier => _notifier(this); @@ -98,9 +98,7 @@ final class StateProvider extends $FunctionalProvider @mustBeOverridden @visibleForOverriding @override - StateProvider $copyWithCreate( - Create> create, - ) { + StateProvider $copyWithCreate(Create create) { return StateProvider.internal( create, name: name, @@ -129,7 +127,7 @@ class StateProviderElement extends ProviderElement { @override void create( - Ref ref, { + Ref ref, { required bool didChangeDependency, }) { final initialState = provider._createFn(ref); diff --git a/packages/riverpod/lib/src/providers/notifier.dart b/packages/riverpod/lib/src/providers/notifier.dart index fbc720dfb..d2ced3d23 100644 --- a/packages/riverpod/lib/src/providers/notifier.dart +++ b/packages/riverpod/lib/src/providers/notifier.dart @@ -84,7 +84,7 @@ abstract class $Notifier extends NotifierBase { /// Do not use. abstract base class $NotifierProvider // , StateT> - extends $ClassProvider> { + extends $ClassProvider { /// An internal base class for [Notifier]. /// /// Not meant for public consumption. diff --git a/packages/riverpod/lib/src/providers/notifier/family.dart b/packages/riverpod/lib/src/providers/notifier/family.dart index 104328155..a1a51732d 100644 --- a/packages/riverpod/lib/src/providers/notifier/family.dart +++ b/packages/riverpod/lib/src/providers/notifier/family.dart @@ -49,7 +49,7 @@ final class FamilyNotifierProvider // FamilyNotifierProvider _copyWith({ NotifierT Function()? create, - RunNotifierBuild>? build, + RunNotifierBuild? build, }) { return FamilyNotifierProvider._( create ?? _createNotifier, @@ -68,7 +68,7 @@ final class FamilyNotifierProvider // @mustBeOverridden @visibleForOverriding FamilyNotifierProvider $copyWithBuild( - RunNotifierBuild> build, + RunNotifierBuild build, ) { return _copyWith(build: build); } diff --git a/packages/riverpod/lib/src/providers/notifier/orphan.dart b/packages/riverpod/lib/src/providers/notifier/orphan.dart index 86d4f6abe..b63a988f3 100644 --- a/packages/riverpod/lib/src/providers/notifier/orphan.dart +++ b/packages/riverpod/lib/src/providers/notifier/orphan.dart @@ -129,7 +129,7 @@ final class NotifierProvider, StateT> NotifierProvider _copyWith({ NotifierT Function()? create, - RunNotifierBuild>? build, + RunNotifierBuild? build, }) { return NotifierProvider.internal( create ?? _createNotifier, @@ -148,7 +148,7 @@ final class NotifierProvider, StateT> @visibleForOverriding @override NotifierProvider $copyWithBuild( - RunNotifierBuild>? build, + RunNotifierBuild? build, ) { return _copyWith(build: build); } diff --git a/packages/riverpod/lib/src/providers/provider.dart b/packages/riverpod/lib/src/providers/provider.dart index 54d6355cb..26cab11fa 100644 --- a/packages/riverpod/lib/src/providers/provider.dart +++ b/packages/riverpod/lib/src/providers/provider.dart @@ -9,13 +9,13 @@ import 'stream_provider.dart' show StreamProvider; /// Implementation detail of `riverpod_generator`. /// Do not use, as this may be removed at any time. @internal -base mixin $Provider on ProviderBase { - StateT create(RefT ref); +base mixin $Provider on ProviderBase { + StateT create(Ref ref); } /// {@macro riverpod.provider} base class Provider extends $FunctionalProvider - with $Provider>, LegacyProviderMixin { + with $Provider, LegacyProviderMixin { /// {@macro riverpod.provider} Provider( this._create, { @@ -49,10 +49,10 @@ base class Provider extends $FunctionalProvider /// {@macro riverpod.family} static const family = ProviderFamilyBuilder(); - final Create> _create; + final Create _create; @override - StateT create(Ref ref) => _create(ref); + StateT create(Ref ref) => _create(ref); @internal @override @@ -63,9 +63,7 @@ base class Provider extends $FunctionalProvider @mustBeOverridden @visibleForOverriding @override - Provider $copyWithCreate( - Create> create, - ) { + Provider $copyWithCreate(Create create) { return Provider.internal( create, from: from, @@ -348,10 +346,10 @@ class $ProviderElement extends ProviderElement { $ProviderElement(this.provider, super.pointer); @override - final $Provider> provider; + final $Provider provider; @override - void create(Ref ref, {required bool didChangeDependency}) { + void create(Ref ref, {required bool didChangeDependency}) { setStateResult(ResultData(provider.create(ref))); } diff --git a/packages/riverpod/lib/src/providers/stream_notifier.dart b/packages/riverpod/lib/src/providers/stream_notifier.dart index e7ed41a05..c84e097e5 100644 --- a/packages/riverpod/lib/src/providers/stream_notifier.dart +++ b/packages/riverpod/lib/src/providers/stream_notifier.dart @@ -28,8 +28,7 @@ abstract base class $StreamNotifierProvider< extends $ClassProvider< // NotifierT, AsyncValue, - Stream, - Ref>> // + Stream> // with $FutureModifier { /// Implementation detail of `riverpod_generator`. diff --git a/packages/riverpod/lib/src/providers/stream_notifier/family.dart b/packages/riverpod/lib/src/providers/stream_notifier/family.dart index d1a574297..7196ca061 100644 --- a/packages/riverpod/lib/src/providers/stream_notifier/family.dart +++ b/packages/riverpod/lib/src/providers/stream_notifier/family.dart @@ -64,8 +64,7 @@ final class FamilyStreamNotifierProvider< // NotifierT Function()? create, RunNotifierBuild< // NotifierT, - Stream, - Ref>>? + Stream>? build, }) { return FamilyStreamNotifierProvider._( @@ -85,7 +84,7 @@ final class FamilyStreamNotifierProvider< // @mustBeOverridden @visibleForOverriding FamilyStreamNotifierProvider $copyWithBuild( - RunNotifierBuild, Ref>> build, + RunNotifierBuild> build, ) { return _copyWith(build: build); } diff --git a/packages/riverpod/lib/src/providers/stream_notifier/orphan.dart b/packages/riverpod/lib/src/providers/stream_notifier/orphan.dart index 153c6b6eb..d2ce95a05 100644 --- a/packages/riverpod/lib/src/providers/stream_notifier/orphan.dart +++ b/packages/riverpod/lib/src/providers/stream_notifier/orphan.dart @@ -91,7 +91,7 @@ final class StreamNotifierProvider< // StreamNotifierProvider _copyWith({ NotifierT Function()? create, - RunNotifierBuild, Ref>>? build, + RunNotifierBuild>? build, }) { return StreamNotifierProvider.internal( create ?? _createNotifier, @@ -118,7 +118,7 @@ final class StreamNotifierProvider< // @visibleForOverriding @override StreamNotifierProvider $copyWithBuild( - RunNotifierBuild, Ref>>? build, + RunNotifierBuild>? build, ) { return _copyWith(build: build); } diff --git a/packages/riverpod/lib/src/providers/stream_provider.dart b/packages/riverpod/lib/src/providers/stream_provider.dart index 27befb850..a87e0bc6e 100644 --- a/packages/riverpod/lib/src/providers/stream_provider.dart +++ b/packages/riverpod/lib/src/providers/stream_provider.dart @@ -13,8 +13,8 @@ import 'provider.dart' show Provider; /// Implementation detail of `riverpod_generator`. /// Do not use, as this may be removed at any time. @internal -base mixin $StreamProvider on ProviderBase> { - Stream create(RefT ref); +base mixin $StreamProvider on ProviderBase> { + Stream create(Ref ref); /// {@macro riverpod.override_with_value} Override overrideWithValue(AsyncValue value) { @@ -85,7 +85,7 @@ base class StreamProvider extends $FunctionalProvider, Stream> with $FutureModifier, - $StreamProvider>>, + $StreamProvider, LegacyProviderMixin> { /// {@macro riverpod.stream_provider} StreamProvider( @@ -120,10 +120,10 @@ base class StreamProvider /// {@macro riverpod.family} static const family = StreamProviderFamilyBuilder(); - final Create, Ref>> _create; + final Create> _create; @override - Stream create(Ref> ref) => _create(ref); + Stream create(Ref ref) => _create(ref); @internal @override @@ -135,7 +135,7 @@ base class StreamProvider @visibleForOverriding @override $FunctionalProvider, Stream> $copyWithCreate( - Create, Ref>> create, + Create> create, ) { return StreamProvider.internal( create, @@ -158,7 +158,7 @@ class $StreamProviderElement extends ProviderElement> $StreamProviderElement(this.provider, super.pointer); @override - final $StreamProvider>> provider; + final $StreamProvider provider; final _streamNotifier = ProxyElementValueListenable>(); final StreamController _streamController = @@ -166,7 +166,7 @@ class $StreamProviderElement extends ProviderElement> @override void create( - Ref> ref, { + Ref ref, { required bool didChangeDependency, }) { asyncTransition(AsyncLoading(), seamless: !didChangeDependency); diff --git a/packages/riverpod/pubspec.yaml b/packages/riverpod/pubspec.yaml index 1219bf994..aa0b421ab 100644 --- a/packages/riverpod/pubspec.yaml +++ b/packages/riverpod/pubspec.yaml @@ -20,7 +20,8 @@ dependencies: test: ^1.0.0 dev_dependencies: - analyzer: ^6.3.0 + analyzer: ^6.7.0 + expect_error: ^1.0.0 mockito: ^5.0.0 path: ^1.9.0 trotter: ^2.0.0-dev.1 diff --git a/packages/riverpod/pubspec_overrides.yaml b/packages/riverpod/pubspec_overrides.yaml index 5fe406c11..607c9fadd 100644 --- a/packages/riverpod/pubspec_overrides.yaml +++ b/packages/riverpod/pubspec_overrides.yaml @@ -1,3 +1,3 @@ dependency_overrides: # necessary for mockito - analyzer: ^6.0.0 + analyzer: ^6.7.0 diff --git a/packages/riverpod/test/meta_test.dart b/packages/riverpod/test/meta_test.dart index ccc67210c..50e894b8c 100644 --- a/packages/riverpod/test/meta_test.dart +++ b/packages/riverpod/test/meta_test.dart @@ -184,7 +184,8 @@ class _PublicAPIVisitor extends GeneralizingElementVisitor { } void _verifyInheritsAnnotations(Element element) { - final parent = element.enclosingElement3; + // ignore: deprecated_member_use, needed to support older SDK + final parent = element.enclosingElement; if (parent is! ClassElement) return; diff --git a/packages/riverpod/test/old/framework/provider_container_test.dart b/packages/riverpod/test/old/framework/provider_container_test.dart index 6f167cfd4..36c54c899 100644 --- a/packages/riverpod/test/old/framework/provider_container_test.dart +++ b/packages/riverpod/test/old/framework/provider_container_test.dart @@ -2,6 +2,7 @@ import 'package:mockito/mockito.dart'; import 'package:riverpod/src/internals.dart'; import 'package:test/test.dart'; +import '../../src/matrix.dart'; import '../utils.dart'; void main() { @@ -144,10 +145,12 @@ void main() { () async { final dep = StateProvider((ref) => 0); final provider = Provider((ref) => ref.watch(dep)); - final another = StateProvider((ref) { - ref.listen(provider, (prev, value) => ref.state++); - return 0; - }); + final another = NotifierProvider, int>( + () => DeferredNotifier((ref, self) { + ref.listen(provider, (prev, value) => self.state++); + return 0; + }), + ); final container = ProviderContainer.test(); expect(container.read(another), 0); @@ -162,10 +165,12 @@ void main() { () async { final dep = StateProvider((ref) => 0); final provider = Provider((ref) => ref.watch(dep)); - final another = StateProvider((ref) { - ref.listen(provider, (prev, value) => ref.state++); - return 0; - }); + final another = NotifierProvider, int>( + () => DeferredNotifier((ref, self) { + ref.listen(provider, (prev, value) => self.state++); + return 0; + }), + ); final container = ProviderContainer.test(); expect(container.read(another), 0); diff --git a/packages/riverpod/test/old/legacy/framework2/framework_test.dart b/packages/riverpod/test/old/legacy/framework2/framework_test.dart index 6f6cd38c5..c4ff841eb 100644 --- a/packages/riverpod/test/old/legacy/framework2/framework_test.dart +++ b/packages/riverpod/test/old/legacy/framework2/framework_test.dart @@ -504,7 +504,7 @@ void main() { final root = ProviderContainer.test(); final container = ProviderContainer.test(parent: root); var callCount = 0; - late Ref providerReference; + late Ref providerReference; var result = 0; final provider = Provider((ref) { callCount++; diff --git a/packages/riverpod/test/old/legacy/framework_test.dart b/packages/riverpod/test/old/legacy/framework_test.dart index 3108ddd89..7b3c81081 100644 --- a/packages/riverpod/test/old/legacy/framework_test.dart +++ b/packages/riverpod/test/old/legacy/framework_test.dart @@ -186,7 +186,7 @@ void main() { var callCount = 0; final onDispose = OnDisposeMock(); final error = Error(); - late Ref reference; + late Ref reference; final provider = Provider((ref) { reference = ref; callCount++; diff --git a/packages/riverpod/test/old/legacy_providers/deprecated/state_notifier_provider/auto_dispose_state_notifier_provider_test.dart b/packages/riverpod/test/old/legacy_providers/deprecated/state_notifier_provider/auto_dispose_state_notifier_provider_test.dart index 4433e2ea0..2915e4c91 100644 --- a/packages/riverpod/test/old/legacy_providers/deprecated/state_notifier_provider/auto_dispose_state_notifier_provider_test.dart +++ b/packages/riverpod/test/old/legacy_providers/deprecated/state_notifier_provider/auto_dispose_state_notifier_provider_test.dart @@ -7,21 +7,6 @@ import 'package:test/test.dart'; import '../../../utils.dart'; void main() { - test('can read and set current StateNotifier', () async { - final container = ProviderContainer.test(); - final listener = Listener(); - late Ref ref; - final provider = StateNotifierProvider.autoDispose((r) { - ref = r; - return Counter(); - }); - - container.listen(provider, listener.call); - - verifyZeroInteractions(listener); - expect(ref.state, 0); - }); - test('can be auto-scoped', () async { final dep = Provider( (ref) => 0, @@ -107,11 +92,13 @@ void main() { }); test('can specify name', () { - final provider = StateNotifierProvider.autoDispose( + final provider = StateNotifierProvider.autoDispose( (_) => TestNotifier(), name: 'example', ); - final provider2 = StateNotifierProvider.autoDispose((_) => TestNotifier()); + final provider2 = StateNotifierProvider.autoDispose( + (_) => TestNotifier(), + ); expect(provider.name, 'example'); expect(provider2.name, isNull); diff --git a/packages/riverpod/test/old/legacy_providers/deprecated/state_notifier_provider/state_notifier_provider_test.dart b/packages/riverpod/test/old/legacy_providers/deprecated/state_notifier_provider/state_notifier_provider_test.dart index 85c075959..d2fa7f120 100644 --- a/packages/riverpod/test/old/legacy_providers/deprecated/state_notifier_provider/state_notifier_provider_test.dart +++ b/packages/riverpod/test/old/legacy_providers/deprecated/state_notifier_provider/state_notifier_provider_test.dart @@ -16,7 +16,9 @@ void main() { onDispose: () => throw StateError('called'), ); final container = ProviderContainer.test(); - final provider = StateNotifierProvider((_) => notifier); + final provider = StateNotifierProvider( + (_) => notifier, + ); container.read(provider); @@ -39,12 +41,8 @@ void main() { ); final container = ProviderContainer.test( overrides: [ - provider.overrideWith( - (Ref ref) => TestNotifier(42), - ), - autoDispose.overrideWith( - (Ref ref) => TestNotifier(84), - ), + provider.overrideWith((ref) => TestNotifier(42)), + autoDispose.overrideWith((ref) => TestNotifier(84)), ], ); @@ -62,15 +60,9 @@ void main() { ); final container = ProviderContainer.test( overrides: [ - family.overrideWith( - (Ref ref, int arg) => TestNotifier(42 + arg), - ), + family.overrideWith((ref, int arg) => TestNotifier(42 + arg)), autoDisposeFamily.overrideWith( - ( - Ref ref, - int arg, - ) => - TestNotifier(84 + arg), + (ref, int arg) => TestNotifier(84 + arg), ), ], ); @@ -98,38 +90,6 @@ void main() { verifyNoMoreInteractions(listener); }); - test('ref.listenSelf listens to state changes', () { - final listener = Listener(); - final container = ProviderContainer.test(); - final provider = StateNotifierProvider, int>((ref) { - ref.listenSelf(listener.call); - return StateController(0); - }); - - final notifier = container.read(provider.notifier); - - verifyOnly(listener, listener(null, 0)); - - notifier.state++; - - verifyOnly(listener, listener(0, 1)); - }); - - test('can read and set current StateNotifier', () async { - final container = ProviderContainer.test(); - final listener = Listener(); - late Ref ref; - final provider = StateNotifierProvider((r) { - ref = r; - return Counter(); - }); - - container.listen(provider, listener.call); - - verifyZeroInteractions(listener); - expect(ref.state, 0); - }); - test('can be auto-scoped', () async { final dep = Provider( (ref) => 0, diff --git a/packages/riverpod/test/old/legacy_providers/deprecated/state_provider/state_provider_test.dart b/packages/riverpod/test/old/legacy_providers/deprecated/state_provider/state_provider_test.dart index 18063f6a3..37f5092d6 100644 --- a/packages/riverpod/test/old/legacy_providers/deprecated/state_provider/state_provider_test.dart +++ b/packages/riverpod/test/old/legacy_providers/deprecated/state_provider/state_provider_test.dart @@ -18,8 +18,8 @@ void main() { ); final container = ProviderContainer.test( overrides: [ - provider.overrideWith((Ref ref) => 42), - autoDispose.overrideWith((Ref ref) => 84), + provider.overrideWith((ref) => 42), + autoDispose.overrideWith((ref) => 84), ], ); @@ -34,12 +34,8 @@ void main() { ); final container = ProviderContainer.test( overrides: [ - family.overrideWith( - (Ref ref, int arg) => '42 $arg', - ), - autoDisposeFamily.overrideWith( - (Ref ref, int arg) => '84 $arg', - ), + family.overrideWith((ref, int arg) => '42 $arg'), + autoDisposeFamily.overrideWith((ref, int arg) => '84 $arg'), ], ); @@ -64,23 +60,6 @@ void main() { verifyNoMoreInteractions(listener); }); - test('ref.listenSelf listens to state changes', () { - final listener = Listener(); - final container = ProviderContainer.test(); - final provider = StateProvider((ref) { - ref.listenSelf(listener.call); - return 0; - }); - - final notifier = container.read(provider.notifier); - - verifyOnly(listener, listener(null, 0)); - - notifier.state++; - - verifyOnly(listener, listener(0, 1)); - }); - test('supports .name', () { expect( StateProvider((ref) => 0).name, diff --git a/packages/riverpod/test/old/legacy_providers/future_provider/auto_dispose_future_provider_test.dart b/packages/riverpod/test/old/legacy_providers/future_provider/auto_dispose_future_provider_test.dart index 66d559fee..13b38f231 100644 --- a/packages/riverpod/test/old/legacy_providers/future_provider/auto_dispose_future_provider_test.dart +++ b/packages/riverpod/test/old/legacy_providers/future_provider/auto_dispose_future_provider_test.dart @@ -9,37 +9,6 @@ import 'package:test/test.dart'; import '../../utils.dart'; void main() { - test('can read and set current AsyncValue', () { - final container = ProviderContainer.test(); - final listener = Listener>(); - late Ref> ref; - final provider = FutureProvider.autoDispose((r) { - ref = r; - return 0; - }); - - container.listen(provider, listener.call); - - expect(ref.state, const AsyncData(0)); - verifyZeroInteractions(listener); - - ref.state = const AsyncLoading(); - - expect( - ref.state, - const AsyncLoading() - .copyWithPrevious(const AsyncData(0), isRefresh: false), - ); - verifyOnly( - listener, - listener( - const AsyncData(0), - const AsyncLoading() - .copyWithPrevious(const AsyncData(0), isRefresh: false), - ), - ); - }); - test('can be auto-scoped', () async { final dep = Provider( (ref) => 0, diff --git a/packages/riverpod/test/old/legacy_providers/future_provider/future_provider_test.dart b/packages/riverpod/test/old/legacy_providers/future_provider/future_provider_test.dart index 700d50173..d4b1d9279 100644 --- a/packages/riverpod/test/old/legacy_providers/future_provider/future_provider_test.dart +++ b/packages/riverpod/test/old/legacy_providers/future_provider/future_provider_test.dart @@ -30,10 +30,8 @@ void main() { final autoDispose = FutureProvider.autoDispose((ref) => 0); final container = ProviderContainer.test( overrides: [ - provider.overrideWith((Ref> ref) => 42), - autoDispose.overrideWith( - (Ref> ref) => 84, - ), + provider.overrideWith((ref) => 42), + autoDispose.overrideWith((ref) => 84), ], ); @@ -41,44 +39,6 @@ void main() { expect(container.read(autoDispose).value, 84); }); - test('Does not skip return value if ref.state was set', () async { - final provider = FutureProvider((ref) async { - await Future.value(); - ref.state = const AsyncData(1); - await Future.value(); - ref.state = const AsyncData(2); - await Future.value(); - return 3; - }); - final container = ProviderContainer.test(); - final listener = Listener>(); - // Completer used for the sole purpose of being able to await `provider.future` - // Since `provider` emits `AsyncData` before the future completes, then - // `provider.future` completes early. - // As such, awaiting `provider.future` isn't enough to fully await the FutureProvider - final completer = Completer(); - - container.listen>( - provider, - (prev, next) { - if (next.value == 3) { - completer.complete(); - } - listener(prev, next); - }, - fireImmediately: true, - ); - - await completer.future; - - verifyInOrder([ - listener(null, const AsyncLoading()), - listener(const AsyncLoading(), const AsyncData(1)), - listener(const AsyncData(1), const AsyncData(2)), - listener(const AsyncData(2), const AsyncData(3)), - ]); - }); - test('supports family overrideWith', () { final family = FutureProvider.family((ref, arg) => '0 $arg'); final autoDisposeFamily = FutureProvider.autoDispose.family( @@ -86,12 +46,8 @@ void main() { ); final container = ProviderContainer.test( overrides: [ - family.overrideWith( - (Ref> ref, int arg) => '42 $arg', - ), - autoDisposeFamily.overrideWith( - (Ref> ref, int arg) => '84 $arg', - ), + family.overrideWith((ref, int arg) => '42 $arg'), + autoDisposeFamily.overrideWith((ref, int arg) => '84 $arg'), ], ); @@ -99,27 +55,6 @@ void main() { expect(container.read(autoDisposeFamily(10)).value, '84 10'); }); - test('Emits AsyncLoading before the create function is executed', () async { - final container = ProviderContainer.test(); - late AsyncValue state; - final provider = FutureProvider((ref) { - state = ref.state; - return 0; - }); - - container.read(provider); - - expect(state, const AsyncLoading()); - - await container.read(provider.future); - container.refresh(provider); - - expect( - state, - const AsyncLoading().copyWithPrevious(const AsyncData(0)), - ); - }); - test('On dispose, .future resolves with the future returned itself', () async { final container = ProviderContainer.test(); @@ -238,38 +173,6 @@ void main() { }); }); - test('can read and set current AsyncValue', () { - final container = ProviderContainer.test(); - final listener = Listener>(); - late Ref> ref; - final provider = FutureProvider((r) { - ref = r; - return 0; - }); - - container.listen(provider, listener.call); - - expect(ref.state, const AsyncData(0)); - verifyZeroInteractions(listener); - - ref.state = const AsyncLoading(); - - expect( - ref.state, - const AsyncLoading() - .copyWithPrevious(const AsyncData(0), isRefresh: false), - ); - - verifyOnly( - listener, - listener( - const AsyncData(0), - const AsyncLoading() - .copyWithPrevious(const AsyncData(0), isRefresh: false), - ), - ); - }); - test('can be auto-scoped', () async { final dep = Provider( (ref) => 0, diff --git a/packages/riverpod/test/old/legacy_providers/provider/auto_dispose_provider_test.dart b/packages/riverpod/test/old/legacy_providers/provider/auto_dispose_provider_test.dart index c8d937ef9..643c0b4a1 100644 --- a/packages/riverpod/test/old/legacy_providers/provider/auto_dispose_provider_test.dart +++ b/packages/riverpod/test/old/legacy_providers/provider/auto_dispose_provider_test.dart @@ -1,86 +1,9 @@ -import 'package:mockito/mockito.dart'; -import 'package:riverpod/legacy.dart'; import 'package:riverpod/riverpod.dart'; import 'package:riverpod/src/internals.dart' show ProviderElement; import 'package:test/test.dart'; -import '../../utils.dart'; - void main() { group('Provider.autoDispose', () { - group('ref.state', () { - test('can read and change current value', () { - final container = ProviderContainer.test(); - final listener = Listener(); - late Ref ref; - final provider = Provider.autoDispose((r) { - ref = r; - return 0; - }); - - container.listen(provider, listener.call); - verifyZeroInteractions(listener); - - expect(ref.state, 0); - - ref.state = 42; - - verifyOnly(listener, listener(0, 42)); - expect(ref.state, 42); - }); - - test('fails if trying to read the state before it was set', () { - final container = ProviderContainer.test(); - Object? err; - final provider = Provider.autoDispose((ref) { - try { - ref.state; - } catch (e) { - err = e; - } - return 0; - }); - - container.read(provider); - expect(err, isStateError); - }); - - test( - 'on rebuild, still fails if trying to read the state before was built', - () { - final dep = StateProvider((ref) => false); - final container = ProviderContainer.test(); - Object? err; - final provider = Provider.autoDispose((ref) { - if (ref.watch(dep)) { - try { - ref.state; - } catch (e) { - err = e; - } - } - return 0; - }); - - container.read(provider); - expect(err, isNull); - - container.read(dep.notifier).state = true; - container.read(provider); - - expect(err, isStateError); - }); - - test('can read the state if the setter was called before', () { - final container = ProviderContainer.test(); - final provider = Provider.autoDispose((ref) { - return ref.state = 42; - }); - - expect(container.read(provider), 42); - }); - }); - test('can be refreshed', () async { var result = 0; final container = ProviderContainer.test(); @@ -94,26 +17,6 @@ void main() { expect(container.read(provider), 1); }); - test('does not notify listeners when called ref.state= with == new value', - () async { - final container = ProviderContainer.test(); - final listener = Listener(); - late Ref ref; - final provider = Provider.autoDispose((r) { - ref = r; - return 0; - }); - - container.listen(provider, listener.call, fireImmediately: true); - - verifyOnly(listener, listener(null, 0)); - - ref.state = 0; - await container.pump(); - - verifyNoMoreInteractions(listener); - }); - group('scoping an override overrides all the associated subproviders', () { test('when passing the provider itself', () { final provider = Provider.autoDispose( diff --git a/packages/riverpod/test/old/legacy_providers/provider/provider_test.dart b/packages/riverpod/test/old/legacy_providers/provider/provider_test.dart index 4dd928067..917d9c82b 100644 --- a/packages/riverpod/test/old/legacy_providers/provider/provider_test.dart +++ b/packages/riverpod/test/old/legacy_providers/provider/provider_test.dart @@ -15,10 +15,8 @@ void main() { final autoDispose = Provider.autoDispose((ref) => 0); final container = ProviderContainer.test( overrides: [ - provider.overrideWith((Ref ref) => 42), - autoDispose.overrideWith( - (Ref ref) => 84, - ), + provider.overrideWith((ref) => 42), + autoDispose.overrideWith((ref) => 84), ], ); @@ -33,10 +31,8 @@ void main() { ); final container = ProviderContainer.test( overrides: [ - family.overrideWith((Ref ref, int arg) => '42 $arg'), - autoDisposeFamily.overrideWith( - (Ref ref, int arg) => '84 $arg', - ), + family.overrideWith((ref, int arg) => '42 $arg'), + autoDisposeFamily.overrideWith((ref, int arg) => '84 $arg'), ], ); @@ -57,116 +53,6 @@ void main() { expect(container.read(provider), 1); }); - group('ref.state', () { - test('throws on providers that threw', () { - final container = ProviderContainer.test(); - final provider = Provider((ref) => throw UnimplementedError()); - - expect( - () => container.read(provider), - throwsUnimplementedError, - ); - - final element = container.readProviderElement(provider); - - expect( - () => element.ref!.state, - throwsUnimplementedError, - ); - }); - - test('can read and change current value', () { - final container = ProviderContainer.test(); - final listener = Listener(); - late Ref ref; - final provider = Provider((r) { - ref = r; - return 0; - }); - - container.listen(provider, listener.call); - verifyZeroInteractions(listener); - - expect(ref.state, 0); - - ref.state = 42; - - verifyOnly(listener, listener(0, 42)); - expect(ref.state, 42); - }); - - test('fails if trying to read the state before it was set', () { - final container = ProviderContainer.test(); - Object? err; - final provider = Provider((ref) { - try { - ref.state; - } catch (e) { - err = e; - } - return 0; - }); - - container.read(provider); - expect(err, isStateError); - }); - - test( - 'on rebuild, still fails if trying to read the state before was built', - () { - final dep = StateProvider((ref) => false); - final container = ProviderContainer.test(); - Object? err; - final provider = Provider((ref) { - if (ref.watch(dep)) { - try { - ref.state; - } catch (e) { - err = e; - } - } - return 0; - }); - - container.read(provider); - expect(err, isNull); - - container.read(dep.notifier).state = true; - container.read(provider); - - expect(err, isStateError); - }); - - test('can read the state if the setter was called before', () { - final container = ProviderContainer.test(); - final provider = Provider((ref) { - return ref.state = 42; - }); - - expect(container.read(provider), 42); - }); - }); - - test('does not notify listeners when called ref.state= with == new value', - () async { - final container = ProviderContainer.test(); - final listener = Listener(); - late Ref ref; - final provider = Provider((r) { - ref = r; - return 0; - }); - - container.listen(provider, listener.call, fireImmediately: true); - - verifyOnly(listener, listener(null, 0)); - - ref.state = 0; - await container.pump(); - - verifyNoMoreInteractions(listener); - }); - group('scoping an override overrides all the associated sub-providers', () { test('when passing the provider itself', () { final provider = Provider( @@ -272,51 +158,53 @@ void main() { expect(callCount, 1); }); - test("rebuild don't notify clients if == doesn't change", () { - final container = ProviderContainer.test(); - final counter = Counter(); - final other = StateNotifierProvider((ref) => counter); - var buildCount = 0; - final provider = Provider((ref) { - buildCount++; - return ref.watch(other).isEven; - }); - final listener = Listener(); - - final sub = - container.listen(provider, listener.call, fireImmediately: true); + group('updateShouldNotify', () { + test("rebuild don't notify clients if == doesn't change", () { + final container = ProviderContainer.test(); + final counter = Counter(); + final other = StateNotifierProvider((ref) => counter); + var buildCount = 0; + final provider = Provider((ref) { + buildCount++; + return ref.watch(other).isEven; + }); + final listener = Listener(); - verifyOnly(listener, listener(null, true)); - expect(sub.read(), true); - expect(buildCount, 1); + final sub = + container.listen(provider, listener.call, fireImmediately: true); - counter.increment(); - counter.increment(); + verifyOnly(listener, listener(null, true)); + expect(sub.read(), true); + expect(buildCount, 1); - expect(sub.read(), true); - expect(buildCount, 2); - verifyNoMoreInteractions(listener); - }); + counter.increment(); + counter.increment(); - test('rebuild notify clients if == did change', () { - final container = ProviderContainer.test(); - final counter = Counter(); - final other = StateNotifierProvider((ref) => counter); - final provider = Provider((ref) { - return ref.watch(other).isEven; + expect(sub.read(), true); + expect(buildCount, 2); + verifyNoMoreInteractions(listener); }); - final listener = Listener(); - final sub = - container.listen(provider, listener.call, fireImmediately: true); + test('rebuild notify clients if == did change', () { + final container = ProviderContainer.test(); + final counter = Counter(); + final other = StateNotifierProvider((ref) => counter); + final provider = Provider((ref) { + return ref.watch(other).isEven; + }); + final listener = Listener(); - verifyOnly(listener, listener(null, true)); - expect(sub.read(), true); + final sub = + container.listen(provider, listener.call, fireImmediately: true); - counter.increment(); + verifyOnly(listener, listener(null, true)); + expect(sub.read(), true); - expect(sub.read(), false); - verifyOnly(listener, listener(true, false)); + counter.increment(); + + expect(sub.read(), false); + verifyOnly(listener, listener(true, false)); + }); }); test('can be auto-scoped', () async { diff --git a/packages/riverpod/test/old/legacy_providers/stream_provider/auto_dispose_stream_provider_test.dart b/packages/riverpod/test/old/legacy_providers/stream_provider/auto_dispose_stream_provider_test.dart index 6bba9449c..8bf9a8af6 100644 --- a/packages/riverpod/test/old/legacy_providers/stream_provider/auto_dispose_stream_provider_test.dart +++ b/packages/riverpod/test/old/legacy_providers/stream_provider/auto_dispose_stream_provider_test.dart @@ -12,45 +12,6 @@ import '../../utils.dart'; void main() { group('StreamProvider.autoDispose', () { - test('can read and set current AsyncValue', () async { - final container = ProviderContainer.test(); - final listener = Listener>(); - late Ref> ref; - final provider = StreamProvider.autoDispose((r) { - ref = r; - return Stream.value(0); - }); - - container.listen(provider, listener.call); - - await container.read(provider.future); - expect(ref.state, const AsyncData(0)); - verifyOnly( - listener, - listener( - const AsyncLoading(), - const AsyncData(0), - ), - ); - - ref.state = const AsyncLoading(); - - expect( - ref.state, - const AsyncLoading() - .copyWithPrevious(const AsyncData(0), isRefresh: false), - ); - - verifyOnly( - listener, - listener( - const AsyncData(0), - const AsyncLoading() - .copyWithPrevious(const AsyncData(0), isRefresh: false), - ), - ); - }); - test('can be auto-scoped', () async { final dep = Provider( (ref) => 0, diff --git a/packages/riverpod/test/old/legacy_providers/stream_provider/stream_provider_test.dart b/packages/riverpod/test/old/legacy_providers/stream_provider/stream_provider_test.dart index 13d3e45b6..6ea01c5ae 100644 --- a/packages/riverpod/test/old/legacy_providers/stream_provider/stream_provider_test.dart +++ b/packages/riverpod/test/old/legacy_providers/stream_provider/stream_provider_test.dart @@ -12,85 +12,50 @@ import '../../utils.dart'; void main() { test('supports overrideWith', () { - final provider = StreamProvider( - (ref) { - ref.state = const AsyncData(0); - return Stream.value(1); - }, - ); + final provider = StreamProvider((ref) => Stream.value(1)); final autoDispose = StreamProvider.autoDispose( - (ref) { - ref.state = const AsyncData(0); - return Stream.value(1); - }, + (ref) => Stream.value(1), ); final container = ProviderContainer.test( overrides: [ - provider.overrideWith((Ref> ref) { - ref.state = const AsyncData(42); - return Stream.value(43); - }), - autoDispose.overrideWith((Ref> ref) { - ref.state = const AsyncData(84); - return Stream.value(85); - }), + provider.overrideWith((ref) => Stream.value(42)), + autoDispose.overrideWith((ref) => Stream.value(84)), ], ); - expect(container.read(provider).value, 42); - expect(container.read(autoDispose).value, 84); + expect( + container.listen(provider.future, (a, b) {}).read(), + completion(42), + ); + expect( + container.listen(autoDispose.future, (a, b) {}).read(), + completion(84), + ); }); test('supports family overrideWith', () { final family = StreamProvider.family((ref, arg) { - ref.state = AsyncData('0 $arg'); - return Stream.value('1 $arg'); + return Stream.value('0 $arg'); }); final autoDisposeFamily = StreamProvider.autoDispose.family( - (ref, arg) { - ref.state = AsyncData('0 $arg'); - return Stream.value('1 $arg'); - }, + (ref, arg) => Stream.value('0 $arg'), ); final container = ProviderContainer.test( overrides: [ - family.overrideWith( - (Ref> ref, int arg) { - ref.state = AsyncData('42 $arg'); - return Stream.value('43 $arg'); - }, - ), + family.overrideWith((ref, int arg) => Stream.value('42 $arg')), autoDisposeFamily.overrideWith( - (Ref> ref, int arg) { - ref.state = AsyncData('84 $arg'); - return Stream.value('85 $arg'); - }, + (ref, int arg) => Stream.value('84 $arg'), ), ], ); - expect(container.read(family(10)).value, '42 10'); - expect(container.read(autoDisposeFamily(10)).value, '84 10'); - }); - - test('Emits AsyncLoading before the create function is executed', () async { - final container = ProviderContainer.test(); - late AsyncValue state; - final provider = StreamProvider((ref) { - state = ref.state; - return Stream.value(0); - }); - - container.listen(provider, (p, n) {}); - - expect(state, const AsyncLoading()); - - await container.read(provider.future); - container.refresh(provider); - expect( - state, - const AsyncLoading().copyWithPrevious(const AsyncData(0)), + container.listen(family(10).future, (a, b) {}).read(), + completion('42 10'), + ); + expect( + container.listen(autoDisposeFamily(10).future, (a, b) {}).read(), + completion('84 10'), ); }); @@ -171,45 +136,6 @@ void main() { }); }); - test('can read and set current AsyncValue', () async { - final container = ProviderContainer.test(); - final listener = Listener>(); - late Ref> ref; - final provider = StreamProvider((r) { - ref = r; - return Stream.value(0); - }); - - container.listen(provider, listener.call); - await container.read(provider.future); - - expect(ref.state, const AsyncData(0)); - verifyOnly( - listener, - listener( - const AsyncLoading(), - const AsyncData(0), - ), - ); - - ref.state = const AsyncLoading(); - - expect( - ref.state, - const AsyncLoading() - .copyWithPrevious(const AsyncData(0), isRefresh: false), - ); - - verifyOnly( - listener, - listener( - const AsyncData(0), - const AsyncLoading() - .copyWithPrevious(const AsyncData(0), isRefresh: false), - ), - ); - }); - test('can be auto-scoped', () async { final dep = Provider( (ref) => 0, diff --git a/packages/riverpod/test/src/core/auto_dispose_test.dart b/packages/riverpod/test/src/core/auto_dispose_test.dart index 9bb044106..76f1df389 100644 --- a/packages/riverpod/test/src/core/auto_dispose_test.dart +++ b/packages/riverpod/test/src/core/auto_dispose_test.dart @@ -95,8 +95,6 @@ void main() { expect(container.pointerManager.readPointer(provider(0)), isNull); }); - // TODO test recursive dispose does not remove pointers in unrelated containers - test( 'When a non-overridden autoDispose provider is disposed ' 'and the associated ProviderContainer has a child ProviderContainer which overrides said provider, ' diff --git a/packages/riverpod/test/src/core/family_test.dart b/packages/riverpod/test/src/core/family_test.dart index 800e0e75e..278f67e00 100644 --- a/packages/riverpod/test/src/core/family_test.dart +++ b/packages/riverpod/test/src/core/family_test.dart @@ -9,7 +9,7 @@ void main() { group('ClassProvider', () { notifierProviderFactory.createGroup((factory) { test('overrideWithBuild', () { - final provider = factory.simpleTestProvider((ref) => 0); + final provider = factory.simpleTestProvider((ref, _) => 0); final overrideWithBuild = OverrideWithBuildMock, int, int>(-1); @@ -25,7 +25,7 @@ void main() { container.read(provider); - final [ref as Ref, notifier as TestNotifier] = verify( + final [ref as Ref, notifier as TestNotifier] = verify( overrideWithBuild.call(captureAny, captureAny), ).captured; @@ -42,7 +42,7 @@ void main() { if (!factory.isFamily) return; test('overrideWithBuild', () { - final provider = factory.simpleTestProvider((ref) => 0).from!; + final provider = factory.simpleTestProvider((ref, _) => 0).from!; provider as NotifierProviderFamily, int, Object?>; @@ -61,7 +61,7 @@ void main() { container.read(provider(0)); - final [ref as Ref, notifier as TestNotifier] = verify( + final [ref as Ref, notifier as TestNotifier] = verify( overrideWithBuild.call(captureAny, captureAny), ).captured; diff --git a/packages/riverpod/test/src/core/modifiers/select_async_test.dart b/packages/riverpod/test/src/core/modifiers/select_async_test.dart index 9cc5fa94d..e43f6b85f 100644 --- a/packages/riverpod/test/src/core/modifiers/select_async_test.dart +++ b/packages/riverpod/test/src/core/modifiers/select_async_test.dart @@ -5,6 +5,7 @@ import 'package:riverpod/legacy.dart'; import 'package:riverpod/riverpod.dart'; import 'package:test/test.dart'; +import '../../matrix.dart'; import '../../utils.dart'; void main() { @@ -198,14 +199,14 @@ void main() { test('handles multiple AsyncLoading at once then data', () async { final container = ProviderContainer.test(); - late Ref> ref; - final provider = FutureProvider((r) { - ref = r; - final completer = Completer(); - ref.onDispose(() => completer.complete(84)); + final provider = AsyncNotifierProvider, int>( + () => DeferredAsyncNotifier((ref, self) { + final completer = Completer(); + ref.onDispose(() => completer.complete(84)); - return completer.future; - }); + return completer.future; + }), + ); final sub = container.listen( provider.selectAsync((data) => data + 40), @@ -214,13 +215,13 @@ void main() { expect(sub.read(), completion(42)); - ref.state = const AsyncLoading() + final notifier = container.read(provider.notifier); + notifier.state = const AsyncLoading() .copyWithPrevious(const AsyncValue.data(0)); - ref.state = const AsyncLoading() + notifier.state = const AsyncLoading() .copyWithPrevious(const AsyncError('err', StackTrace.empty)); - ref.state = const AsyncLoading(); - - ref.state = const AsyncData(2); + notifier.state = const AsyncLoading(); + notifier.state = const AsyncData(2); // the previous unawaited `completion` should resolve with 2+40 }); diff --git a/packages/riverpod/test/src/core/provider_element_test.dart b/packages/riverpod/test/src/core/provider_element_test.dart index adcd86b5d..070019fde 100644 --- a/packages/riverpod/test/src/core/provider_element_test.dart +++ b/packages/riverpod/test/src/core/provider_element_test.dart @@ -5,6 +5,7 @@ import 'package:riverpod/src/internals.dart'; import 'package:test/test.dart'; import '../../third_party/fake_async.dart'; +import '../matrix.dart'; import '../utils.dart'; void main() { @@ -527,10 +528,12 @@ void main() { final listener = Listener(); final dep = StateProvider((ref) => 0); - final provider = Provider((ref) { - ref.watch(dep); - return ref.state = 0; - }); + final provider = NotifierProvider, int>( + () => DeferredNotifier((ref, self) { + ref.watch(dep); + return self.state = 0; + }), + ); container.listen(provider, listener.call, fireImmediately: true); @@ -542,10 +545,12 @@ void main() { final listener = Listener(); final dep = StateProvider((ref) => 0); - final provider = Provider((ref) { - ref.watch(dep); - return ref.state = 0; - }); + final provider = NotifierProvider, int>( + () => DeferredNotifier((ref, self) { + ref.watch(dep); + return self.state = 0; + }), + ); container.listen(provider, listener.call, fireImmediately: true); diff --git a/packages/riverpod/test/src/core/provider_subscription_test.dart b/packages/riverpod/test/src/core/provider_subscription_test.dart index 7fc3ad108..571ca481e 100644 --- a/packages/riverpod/test/src/core/provider_subscription_test.dart +++ b/packages/riverpod/test/src/core/provider_subscription_test.dart @@ -68,7 +68,7 @@ void main() { () async { final container = ProviderContainer.test(); final provider = NotifierProvider, int>( - () => DeferredNotifier((ref) => 0), + () => DeferredNotifier((ref, _) => 0), ); final listener = Listener(); diff --git a/packages/riverpod/test/src/core/ref_test.dart b/packages/riverpod/test/src/core/ref_test.dart index e99419db8..d110b3e0d 100644 --- a/packages/riverpod/test/src/core/ref_test.dart +++ b/packages/riverpod/test/src/core/ref_test.dart @@ -6,10 +6,11 @@ import 'package:riverpod/riverpod.dart'; import 'package:riverpod/src/framework.dart'; import 'package:test/test.dart'; +import '../matrix.dart'; import '../utils.dart'; final refMethodsThatDependOnProviders = - ref, ProviderBase)>{ + )>{ 'watch': (ref, p) => ref.watch(p), 'read': (ref, p) => ref.read(p), 'listen': (ref, p) => ref.listen(p, (prev, next) {}), @@ -18,13 +19,13 @@ final refMethodsThatDependOnProviders = 'exists': (ref, p) => ref.exists(p), }; final refMethodsThatDependOnListenables = - ref, ProviderListenable)>{ + )>{ 'watch': (ref, p) => ref.watch(p), 'read': (ref, p) => ref.read(p), 'listen': (ref, p) => ref.listen(p, (prev, next) {}), }; final refMethodsThatDependOnProviderOrFamilies = - ref, ProviderOrFamily)>{ + { 'invalidate': (ref, p) => ref.invalidate(p), }; @@ -32,7 +33,7 @@ void main() { group('Ref', () { test('asserts that a lifecycle cannot be used after a ref is unmounted', () { - late Ref ref; + late Ref ref; final container = ProviderContainer.test(); final dep = StateProvider((ref) => 0); final provider = Provider((r) { @@ -42,19 +43,10 @@ void main() { }); container.read(provider); - container.read(dep.notifier).state++; final another = Provider((ref) => 0); - expect( - () => ref.state, - throwsA(isA()), - ); - expect( - () => ref.state = 42, - throwsA(isA()), - ); expect( () => ref.watch(another), throwsA(isA()), @@ -115,7 +107,7 @@ void main() { }); test('asserts that a lifecycle cannot be used inside selectors', () { - late Ref ref; + late Ref ref; final container = ProviderContainer.test(); final dep = StateProvider((ref) => 0); final provider = Provider((r) { @@ -130,14 +122,6 @@ void main() { final another = Provider((ref) => 0); - expect( - () => container.read(provider.select((_) => ref.state)), - throwsA(isA()), - ); - expect( - () => container.read(provider.select((_) => ref.state = 42)), - throwsA(isA()), - ); expect( () => container.read(provider.select((_) => ref.watch(another))), throwsA(isA()), @@ -201,7 +185,7 @@ void main() { group('invalidate', () { test('can disposes of the element if not used anymore', () async { - late Ref ref; + late Ref ref; final dep = Provider((r) { ref = r; return 0; @@ -228,7 +212,7 @@ void main() { () async { final container = ProviderContainer.test(); final provider = FutureProvider((r) async => 0); - late Ref ref; + late Ref ref; final dep = Provider((r) { ref = r; return 0; @@ -247,7 +231,7 @@ void main() { test('supports asReload', () async { final container = ProviderContainer.test(); final provider = FutureProvider((r) async => 0); - late Ref ref; + late Ref ref; final dep = Provider((r) { ref = r; return 0; @@ -270,7 +254,7 @@ void main() { test('calls dispose immediately', () { final container = ProviderContainer.test(); final listener = OnDisposeMock(); - late Ref ref; + late Ref ref; final provider = Provider((r) { ref = r; ref.onDispose(listener.call); @@ -288,7 +272,7 @@ void main() { final container = ProviderContainer.test(); final listener = Listener(); var result = 0; - late Ref ref; + late Ref ref; final provider = Provider((r) { ref = r; return result; @@ -311,7 +295,7 @@ void main() { final container = ProviderContainer.test(); final listener = Listener(); final dep = StateProvider((ref) => 0); - late Ref ref; + late Ref ref; final provider = Provider((r) { ref = r; return ref.watch(dep); @@ -331,7 +315,7 @@ void main() { }); test('can disposes of the element if not used anymore', () async { - late Ref ref; + late Ref ref; final provider = Provider.autoDispose((r) { ref = r; r.keepAlive(); @@ -349,7 +333,7 @@ void main() { test('supports asReload', () async { final container = ProviderContainer.test(); - late Ref> ref; + late Ref ref; final provider = FutureProvider((r) async { ref = r; return 0; @@ -584,9 +568,13 @@ void main() { group('listenSelf', () { test('does not break autoDispose', () async { final container = ProviderContainer.test(); - final provider = Provider.autoDispose((ref) { - ref.listenSelf((previous, next) {}); - }); + + final provider = + NotifierProvider.autoDispose, void>( + () => DeferredNotifier((ref, self) { + self.listenSelf((previous, next) {}); + }), + ); container.read(provider); expect(container.getAllProviderElements(), [anything]); @@ -601,14 +589,14 @@ void main() { final listener = Listener(); final listener2 = Listener(); - late Ref ref; - final provider = Provider((r) { - ref = r; - ref.listenSelf(listener.call); - ref.listenSelf(listener2.call); + final provider = NotifierProvider, int>( + () => DeferredNotifier((ref, self) { + self.listenSelf(listener.call); + self.listenSelf(listener2.call); - return 0; - }); + return 0; + }), + ); container.read(provider); @@ -619,7 +607,7 @@ void main() { verifyNoMoreInteractions(listener); verifyNoMoreInteractions(listener2); - ref.state = 42; + container.read(provider.notifier).state = 42; verifyInOrder([ listener(0, 42), @@ -634,12 +622,15 @@ void main() { final listener = Listener(); final listener2 = Listener(); var result = 0; - final provider = Provider((ref) { - ref.listenSelf(listener.call); - ref.listenSelf(listener2.call); - return result; - }); + final provider = NotifierProvider, int>( + () => DeferredNotifier((ref, self) { + self.listenSelf(listener.call); + self.listenSelf(listener2.call); + + return result; + }), + ); container.read(provider); @@ -665,12 +656,15 @@ void main() { final container = ProviderContainer.test(); final listener = Listener(); final listener2 = Listener(); - final provider = Provider((ref) { - ref.listenSelf(listener.call); - ref.listenSelf(listener2.call); - return 0; - }); + final provider = NotifierProvider, int>( + () => DeferredNotifier((ref, self) { + self.listenSelf(listener.call); + self.listenSelf(listener2.call); + + return 0; + }), + ); container.read(provider); @@ -696,15 +690,18 @@ void main() { final listener = Listener(); final listener2 = Listener(); var result = 0; - final provider = Provider((ref) { - if (result == 0) { - ref.listenSelf(listener.call); - } else { - ref.listenSelf(listener2.call); - } - return result; - }); + final provider = NotifierProvider, int>( + () => DeferredNotifier((ref, self) { + if (result == 0) { + self.listenSelf(listener.call); + } else { + self.listenSelf(listener2.call); + } + + return result; + }), + ); container.read(provider); @@ -726,12 +723,15 @@ void main() { final errorListener = ErrorListener(); final errorListener2 = ErrorListener(); var error = 42; - final provider = Provider((ref) { - ref.listenSelf(listener.call, onError: errorListener.call); - ref.listenSelf((prev, next) {}, onError: errorListener2.call); - Error.throwWithStackTrace(error, StackTrace.empty); - }); + final provider = NotifierProvider, int>( + () => DeferredNotifier((ref, self) { + self.listenSelf(listener.call, onError: errorListener.call); + self.listenSelf((prev, next) {}, onError: errorListener2.call); + + Error.throwWithStackTrace(error, StackTrace.empty); + }), + ); expect(() => container.read(provider), throwsA(42)); @@ -761,13 +761,18 @@ void main() { final errorListener = ErrorListener(); final errorListener2 = ErrorListener(); Exception? error; - final provider = Provider((ref) { - ref.listenSelf((prev, next) {}, onError: errorListener.call); - if (error != null) Error.throwWithStackTrace(error, StackTrace.empty); + final provider = NotifierProvider, int>( + () => DeferredNotifier((ref, self) { + self.listenSelf((prev, next) {}, onError: errorListener.call); - return 0; - }); + if (error != null) { + Error.throwWithStackTrace(error, StackTrace.empty); + } + + return 0; + }), + ); container.listen( provider, @@ -794,10 +799,13 @@ void main() { final listener = Listener(); final listener2 = Listener(); var result = 0; - final provider = Provider((ref) { - ref.listenSelf(listener.call); - return result; - }); + + final provider = NotifierProvider, int>( + () => DeferredNotifier((ref, self) { + self.listenSelf(listener.call); + return result; + }), + ); container.listen(provider, listener2.call, fireImmediately: true); @@ -826,7 +834,7 @@ void main() { test('does not invoke value listeners if paused', () { final container = ProviderContainer.test(); final listener = Listener(); - late Ref ref; + late Ref ref; final provider = Provider((r) { ref = r; return 0; @@ -845,7 +853,7 @@ void main() { test('does not invoke error listeners if paused', () { final container = ProviderContainer.test(); final listener = ErrorListener(); - late Ref ref; + late Ref ref; var throws = false; final provider = Provider((r) { ref = r; @@ -1156,17 +1164,17 @@ void main() { test('cannot listen itself', () { final container = ProviderContainer.test(); final listener = Listener(); - late Ref ref; - late Provider provider; - provider = Provider((r) { - ref = r; - ref.listen(provider, (previous, next) {}); - return 0; - }); + late NotifierProvider, int> provider; + provider = NotifierProvider, int>( + () => DeferredNotifier((ref, self) { + ref.listen(provider, (previous, next) {}); + return 0; + }), + ); expect(() => container.read(provider), throwsA(isAssertionError)); - ref.state = 42; + container.read(provider.notifier).state = 42; verifyZeroInteractions(listener); }); @@ -1802,7 +1810,7 @@ void main() { 'the provider will not be disposed.', () async { final container = ProviderContainer.test(); late KeepAliveLink a; - late Ref ref; + late Ref ref; final provider = Provider.autoDispose((r) { ref = r; @@ -1834,7 +1842,7 @@ void main() { test('refreshes a provider and return the new state', () { var value = 0; final state = Provider((ref) => value); - late Ref ref; + late Ref ref; final provider = Provider((r) { ref = r; }); @@ -1856,12 +1864,12 @@ void main() { final listener = Listener(); final selfListener = Listener(); final container = ProviderContainer.test(observers: [observer]); - late Ref ref; - final provider = Provider((r) { - ref = r; - ref.listenSelf(selfListener.call); - return 0; - }); + final provider = NotifierProvider, int>( + () => DeferredNotifier((ref, self) { + self.listenSelf(selfListener.call); + return 0; + }), + ); container.listen(provider, listener.call, fireImmediately: true); @@ -1869,7 +1877,7 @@ void main() { verifyOnly(listener, listener(null, 0)); verifyOnly(selfListener, selfListener(null, 0)); - ref.notifyListeners(); + container.read(provider.notifier).ref.notifyListeners(); verifyOnly(listener, listener(0, 0)); verifyOnly(selfListener, selfListener(0, 0)); @@ -1886,11 +1894,14 @@ void main() { final selfListener = Listener(); final listener = Listener(); final container = ProviderContainer.test(observers: [observer]); - final provider = Provider((ref) { - ref.listenSelf(selfListener.call); - ref.notifyListeners(); - return 0; - }); + + final provider = NotifierProvider, int>( + () => DeferredNotifier((ref, self) { + self.listenSelf(selfListener.call); + ref.notifyListeners(); + return 0; + }), + ); container.listen(provider, listener.call, fireImmediately: true); @@ -1910,13 +1921,16 @@ void main() { const firstValue = 'first'; const secondValue = 'second'; var result = firstValue; - final provider = Provider((ref) { - ref.listenSelf(selfListener.call); - if (callNotifyListeners) { - ref.notifyListeners(); - } - return result; - }); + + final provider = NotifierProvider, Object>( + () => DeferredNotifier((ref, self) { + self.listenSelf(selfListener.call); + if (callNotifyListeners) { + ref.notifyListeners(); + } + return result; + }), + ); container.listen(provider, listener.call, fireImmediately: true); @@ -1949,7 +1963,7 @@ void main() { group('.refresh', () { test('Throws if a circular dependency is detected', () { // Regression test for https://github.com/rrousselGit/riverpod/issues/2336 - late Ref ref; + late Ref ref; final a = Provider((r) { ref = r; return 0; @@ -1969,7 +1983,7 @@ void main() { group('.invalidate', () { test('Throws if a circular dependency is detected', () { // Regression test for https://github.com/rrousselGit/riverpod/issues/2336 - late Ref ref; + late Ref ref; final a = Provider((r) { ref = r; return 0; @@ -1986,7 +2000,7 @@ void main() { }); test('Circular dependency ignores families', () { - late Ref ref; + late Ref ref; final a = Provider((r) { ref = r; return 0; @@ -2007,7 +2021,7 @@ void main() { final listener = Listener(); var result = 0; final provider = Provider((r) => result); - late Ref ref; + late Ref ref; final another = Provider((r) { ref = r; }); @@ -2036,7 +2050,7 @@ void main() { var result = 0; final unrelated = Provider((ref) => result); final provider = Provider.family((r, i) => '$result-$i'); - late Ref ref; + late Ref ref; final another = Provider((r) { ref = r; }); @@ -2072,7 +2086,7 @@ void main() { (r, i) => result, dependencies: const [], ); - late Ref ref; + late Ref ref; final another = Provider((r) => ref = r, dependencies: [provider]); final listener = Listener(); @@ -2160,7 +2174,7 @@ void main() { ref.onRemoveListener(listener2.call); }, ); - late Ref ref; + late Ref ref; final provider = Provider( name: 'provider', (r) { @@ -2205,7 +2219,7 @@ void main() { ref.onRemoveListener(listener2.call); }, ); - late Ref ref; + late Ref ref; final provider = Provider( name: 'provider', (r) => ref = r, @@ -2328,7 +2342,7 @@ void main() { ref.onAddListener(listener2.call); }, ); - late Ref ref; + late Ref ref; final provider = Provider( name: 'provider', (r) => ref = r, @@ -2361,12 +2375,12 @@ void main() { ref.onAddListener(listener2.call); }, ); - late Ref ref; + late Ref ref; final provider = Provider( name: 'provider', (r) => ref = r, ); - late Ref ref2; + late Ref ref2; final provider2 = Provider( name: 'provider', (r) => ref2 = r, @@ -2384,7 +2398,6 @@ void main() { ref.watch(dep); - // TODO changelog breaking: Calling ref.watch multiple times calls ref.onListen everytime verifyInOrder([listener(), listener2()]); verifyNoMoreInteractions(listener); verifyNoMoreInteractions(listener2); @@ -2500,7 +2513,7 @@ void main() { ref.onResume(listener2.call); }, ); - late Ref ref; + late Ref ref; final provider = Provider( name: 'provider', (r) => ref = r, @@ -2537,7 +2550,7 @@ void main() { ref.onAddListener(listener2.call); }, ); - late Ref ref; + late Ref ref; final provider = Provider( name: 'provider', (r) => ref = r, @@ -2702,7 +2715,7 @@ void main() { ref.onCancel(listener.call); ref.onCancel(listener2.call); }); - late Ref ref; + late Ref ref; final provider = Provider((r) { ref = r; }); @@ -2957,7 +2970,7 @@ void main() { group('mounted', () { test('stays false on older refs while new refs are building', () { final container = ProviderContainer.test(); - late Ref ref; + late Ref ref; final provider = Provider((r) { ref = r; return 0; @@ -2975,7 +2988,7 @@ void main() { test('is false during onDispose caused by ref.watch', () { final container = ProviderContainer.test(); bool? mounted; - late Ref ref; + late Ref ref; final dep = StateProvider((ref) => 0); final provider = Provider((r) { ref = r; @@ -2994,7 +3007,7 @@ void main() { test('is false during onDispose caused by container dispose', () { final container = ProviderContainer.test(); bool? mounted; - late Ref ref; + late Ref ref; final dep = StateProvider((ref) => 0); final provider = Provider((r) { ref = r; @@ -3013,7 +3026,7 @@ void main() { test('is false in between rebuilds', () { final container = ProviderContainer.test(); final dep = StateProvider((ref) => 0); - late Ref ref; + late Ref ref; final provider = Provider((r) { ref = r; ref.watch(dep); diff --git a/packages/riverpod/test/src/core/uni_directional_test.dart b/packages/riverpod/test/src/core/uni_directional_test.dart index ae63b2072..2bf07a19f 100644 --- a/packages/riverpod/test/src/core/uni_directional_test.dart +++ b/packages/riverpod/test/src/core/uni_directional_test.dart @@ -2,6 +2,7 @@ import 'package:mockito/mockito.dart'; import 'package:riverpod/src/internals.dart'; import 'package:test/test.dart'; +import '../matrix.dart'; import '../utils.dart'; void main() { @@ -34,10 +35,12 @@ void main() { test('rebuilding a provider can modify other providers', () async { final dep = StateProvider((ref) => 0); final provider = Provider((ref) => ref.watch(dep)); - final another = StateProvider((ref) { - ref.listen(provider, (prev, value) => ref.state++); - return 0; - }); + final another = NotifierProvider, int>( + () => DeferredNotifier((ref, self) { + ref.listen(provider, (prev, value) => self.state++); + return 0; + }), + ); final container = ProviderContainer.test(); expect(container.read(another), 0); diff --git a/packages/riverpod/test/src/matrix.dart b/packages/riverpod/test/src/matrix.dart index 09cd1bd27..8643c0a61 100644 --- a/packages/riverpod/test/src/matrix.dart +++ b/packages/riverpod/test/src/matrix.dart @@ -31,9 +31,9 @@ class TestFactory { final bool isFamily; } -typedef ProviderFactory - = ProviderT Function([Object? arg]) Function( - BaseT Function(RefT ref, Object? arg) create, { +typedef ProviderFactory = ProviderT Function([Object? arg]) + Function( + BaseT Function(Ref? ref, Object? arg) create, { String? name, Iterable? dependencies, Retry? retry, @@ -57,8 +57,7 @@ extension $Modifiers on ProviderBase { } } -final providerFactory = - , Ref>>[ +final providerFactory = >>[ (create, {name, dependencies, retry}) => ([arg]) { return Provider( (ref) => create(ref, arg), @@ -94,7 +93,7 @@ final providerFactory = ]; final futureProviderFactories = - , FutureProvider, Ref>>[ + , FutureProvider>>[ (create, {name, dependencies, retry}) => ([arg]) { return FutureProvider( (ref) => create(ref, arg), @@ -130,7 +129,7 @@ final futureProviderFactories = ]; final streamProviderFactories = - , StreamProvider, Ref>>[ + , StreamProvider>>[ (create, {name, dependencies, retry}) => ([arg]) { return StreamProvider( (ref) => create(ref, arg), @@ -166,7 +165,7 @@ final streamProviderFactories = ]; final asyncProviderFactory = - >, Ref>>[ + >>>[ for (final factory in futureProviderFactories) (create, {name, dependencies, retry}) => factory( (ref, arg) async => create(ref, arg), diff --git a/packages/riverpod/test/src/matrix/async_notifier_provider.dart b/packages/riverpod/test/src/matrix/async_notifier_provider.dart index 714660222..193dfdee7 100644 --- a/packages/riverpod/test/src/matrix/async_notifier_provider.dart +++ b/packages/riverpod/test/src/matrix/async_notifier_provider.dart @@ -6,8 +6,9 @@ final asyncNotifierProviderFactory = TestMatrix( isAutoDispose: false, isFamily: false, deferredNotifier: DeferredAsyncNotifier.new, - deferredProvider: (create, {updateShouldNotify}) { + deferredProvider: (create, {updateShouldNotify, retry}) { return AsyncNotifierProvider, StateT>( + retry: retry, () => DeferredAsyncNotifier( create, updateShouldNotify: updateShouldNotify, @@ -31,9 +32,10 @@ final asyncNotifierProviderFactory = TestMatrix( isAutoDispose: true, isFamily: false, deferredNotifier: DeferredAsyncNotifier.new, - deferredProvider: (create, {updateShouldNotify}) { + deferredProvider: (create, {updateShouldNotify, retry}) { return AsyncNotifierProvider.autoDispose, StateT>( + retry: retry, () => DeferredAsyncNotifier( create, updateShouldNotify: updateShouldNotify, @@ -59,9 +61,10 @@ final asyncNotifierProviderFactory = TestMatrix( isAutoDispose: false, isFamily: true, deferredNotifier: DeferredFamilyAsyncNotifier.new, - deferredProvider: (create, {updateShouldNotify}) { + deferredProvider: (create, {updateShouldNotify, retry}) { return AsyncNotifierProvider.family, StateT, Object?>( + retry: retry, () => DeferredFamilyAsyncNotifier( create, updateShouldNotify: updateShouldNotify, @@ -88,9 +91,10 @@ final asyncNotifierProviderFactory = TestMatrix( isAutoDispose: true, isFamily: true, deferredNotifier: DeferredFamilyAsyncNotifier.new, - deferredProvider: (create, {updateShouldNotify}) { + deferredProvider: (create, {updateShouldNotify, retry}) { return AsyncNotifierProvider.family .autoDispose, StateT, Object?>( + retry: retry, () => DeferredFamilyAsyncNotifier( create, updateShouldNotify: updateShouldNotify, @@ -134,14 +138,14 @@ class DeferredAsyncNotifier extends AsyncNotifier bool Function(AsyncValue, AsyncValue)? updateShouldNotify, }) : _updateShouldNotify = updateShouldNotify; - final FutureOr Function(Ref> ref) _create; + final FutureOr Function(Ref ref, $AsyncNotifier self) _create; final bool Function( AsyncValue previousState, AsyncValue newState, )? _updateShouldNotify; @override - FutureOr build() => _create(ref); + FutureOr build() => _create(ref, this); @override bool updateShouldNotify( @@ -160,7 +164,7 @@ class DeferredFamilyAsyncNotifier bool Function(AsyncValue, AsyncValue)? updateShouldNotify, }) : _updateShouldNotify = updateShouldNotify; - final FutureOr Function(Ref> ref) _create; + final FutureOr Function(Ref ref, $AsyncNotifier self) _create; final bool Function( AsyncValue previousState, @@ -168,7 +172,7 @@ class DeferredFamilyAsyncNotifier )? _updateShouldNotify; @override - FutureOr build(int arg) => _create(ref); + FutureOr build(int arg) => _create(ref, this); @override bool updateShouldNotify( @@ -180,7 +184,7 @@ class DeferredFamilyAsyncNotifier } class AsyncNotifierTestFactory extends TestFactory< - ProviderFactory<$AsyncNotifier, ProviderBase, void>> { + ProviderFactory<$AsyncNotifier, ProviderBase>> { AsyncNotifierTestFactory({ required super.isAutoDispose, required super.isFamily, @@ -191,13 +195,14 @@ class AsyncNotifierTestFactory extends TestFactory< }); final TestAsyncNotifier Function( - FutureOr Function(Ref> ref) create, + FutureOr Function(Ref ref, $AsyncNotifier self) create, ) deferredNotifier; final $AsyncNotifierProvider, StateT> Function( - FutureOr Function(Ref> ref) create, { + FutureOr Function(Ref ref, $AsyncNotifier self) create, { bool Function(AsyncValue, AsyncValue)? updateShouldNotify, + Retry? retry, }) deferredProvider; final $AsyncNotifierProvider<$AsyncNotifier, StateT> Function( @@ -206,12 +211,14 @@ class AsyncNotifierTestFactory extends TestFactory< $AsyncNotifierProvider, StateT> simpleTestProvider( - FutureOr Function(Ref> ref) create, { + FutureOr Function(Ref ref, $AsyncNotifier self) create, { bool Function(AsyncValue, AsyncValue)? updateShouldNotify, + Retry? retry, }) { return deferredProvider( - (ref) => create(ref), + (ref, self) => create(ref, self), updateShouldNotify: updateShouldNotify, + retry: retry, ); } } diff --git a/packages/riverpod/test/src/matrix/notifier_provider.dart b/packages/riverpod/test/src/matrix/notifier_provider.dart index 58971acd5..dd4299b51 100644 --- a/packages/riverpod/test/src/matrix/notifier_provider.dart +++ b/packages/riverpod/test/src/matrix/notifier_provider.dart @@ -5,11 +5,12 @@ final notifierProviderFactory = TestMatrix( 'NotifierProvider': NotifierTestFactory( isAutoDispose: false, isFamily: false, - deferredNotifier: DeferredNotifier.new, + deferredNotifier: (create) => + DeferredNotifier((ref, self) => create(ref, self)), deferredProvider: (create, {updateShouldNotify}) { return NotifierProvider, StateT>( () => DeferredNotifier( - create, + (ref, self) => create(ref, self), updateShouldNotify: updateShouldNotify, ), ); @@ -29,11 +30,12 @@ final notifierProviderFactory = TestMatrix( 'NotifierProvider.autoDispose': NotifierTestFactory( isAutoDispose: true, isFamily: false, - deferredNotifier: DeferredNotifier.new, + deferredNotifier: (create) => + DeferredNotifier((ref, self) => create(ref, self)), deferredProvider: (create, {updateShouldNotify}) { return NotifierProvider.autoDispose, StateT>( () => DeferredNotifier( - create, + (ref, self) => create(ref, self), updateShouldNotify: updateShouldNotify, ), ); @@ -122,6 +124,12 @@ abstract class TestNotifier implements $Notifier { @override set state(StateT value); + + @override + void listenSelf( + void Function(StateT? previous, StateT next) listener, { + void Function(Object error, StackTrace stackTrace)? onError, + }); } class DeferredNotifier extends Notifier @@ -131,14 +139,23 @@ class DeferredNotifier extends Notifier bool Function(StateT, StateT)? updateShouldNotify, }) : _updateShouldNotify = updateShouldNotify; - final StateT Function(Ref ref) _create; + final StateT Function(Ref ref, DeferredNotifier self) _create; final bool Function( StateT previousState, StateT newState, )? _updateShouldNotify; @override - StateT build() => _create(ref); + Ref get ref; + + @override + void listenSelf( + void Function(StateT? previous, StateT next) listener, { + void Function(Object error, StackTrace stackTrace)? onError, + }); + + @override + StateT build() => _create(ref, this); @override bool updateShouldNotify(StateT previousState, StateT newState) => @@ -153,7 +170,7 @@ class DeferredFamilyNotifier extends FamilyNotifier bool Function(StateT, StateT)? updateShouldNotify, }) : _updateShouldNotify = updateShouldNotify; - final StateT Function(Ref ref) _create; + final StateT Function(Ref ref, DeferredFamilyNotifier self) _create; final bool Function( StateT previousState, @@ -161,7 +178,7 @@ class DeferredFamilyNotifier extends FamilyNotifier )? _updateShouldNotify; @override - StateT build(int arg) => _create(ref); + StateT build(int arg) => _create(ref, this); @override bool updateShouldNotify( @@ -173,7 +190,7 @@ class DeferredFamilyNotifier extends FamilyNotifier } class NotifierTestFactory extends TestFactory< - ProviderFactory<$Notifier, ProviderBase, void>> { + ProviderFactory<$Notifier, ProviderBase>> { NotifierTestFactory({ required super.isAutoDispose, required super.isFamily, @@ -184,11 +201,11 @@ class NotifierTestFactory extends TestFactory< }); final TestNotifier Function( - StateT Function(Ref ref) create, + StateT Function(Ref ref, $Notifier self) create, ) deferredNotifier; final $NotifierProvider, StateT> Function( - StateT Function(Ref ref) create, { + StateT Function(Ref ref, $Notifier self) create, { bool Function(StateT, StateT)? updateShouldNotify, }) deferredProvider; @@ -197,11 +214,11 @@ class NotifierTestFactory extends TestFactory< ) provider; $NotifierProvider, StateT> simpleTestProvider( - StateT Function(Ref ref) create, { + StateT Function(Ref ref, $Notifier self) create, { bool Function(StateT, StateT)? updateShouldNotify, }) { return deferredProvider( - (ref) => create(ref), + (ref, self) => create(ref, self), updateShouldNotify: updateShouldNotify, ); } diff --git a/packages/riverpod/test/src/matrix/stream_notifier_provider.dart b/packages/riverpod/test/src/matrix/stream_notifier_provider.dart index c141cd236..0bdf165fd 100644 --- a/packages/riverpod/test/src/matrix/stream_notifier_provider.dart +++ b/packages/riverpod/test/src/matrix/stream_notifier_provider.dart @@ -139,14 +139,17 @@ class DeferredStreamNotifier extends StreamNotifier bool Function(AsyncValue, AsyncValue)? updateShouldNotify, }) : _updateShouldNotify = updateShouldNotify; - final Stream Function(Ref> ref) _create; + final Stream Function( + Ref ref, + DeferredStreamNotifier self, + ) _create; final bool Function( AsyncValue previousState, AsyncValue newState, )? _updateShouldNotify; @override - Stream build() => _create(ref); + Stream build() => _create(ref, this); @override bool updateShouldNotify( @@ -165,7 +168,10 @@ class DeferredFamilyStreamNotifier bool Function(AsyncValue, AsyncValue)? updateShouldNotify, }) : _updateShouldNotify = updateShouldNotify; - final Stream Function(Ref> ref) _create; + final Stream Function( + Ref ref, + DeferredFamilyStreamNotifier self, + ) _create; final bool Function( AsyncValue previousState, @@ -173,7 +179,7 @@ class DeferredFamilyStreamNotifier )? _updateShouldNotify; @override - Stream build(int arg) => _create(ref); + Stream build(int arg) => _create(ref, this); @override bool updateShouldNotify( @@ -185,7 +191,7 @@ class DeferredFamilyStreamNotifier } class StreamNotifierTestFactory extends TestFactory< - ProviderFactory<$StreamNotifier, ProviderBase, void>> { + ProviderFactory<$StreamNotifier, ProviderBase>> { StreamNotifierTestFactory({ required super.isAutoDispose, required super.isFamily, @@ -196,12 +202,12 @@ class StreamNotifierTestFactory extends TestFactory< }); final TestStreamNotifier Function( - Stream Function(Ref> ref) create, + Stream Function(Ref ref, $StreamNotifier self) create, ) deferredNotifier; final $StreamNotifierProvider, StateT> Function( - Stream Function(Ref> ref) create, { + Stream Function(Ref ref, $StreamNotifier self) create, { bool Function(AsyncValue, AsyncValue)? updateShouldNotify, Retry? retry, }) deferredProvider; @@ -213,12 +219,14 @@ class StreamNotifierTestFactory extends TestFactory< $StreamNotifierProvider, StateT> simpleTestProvider( - Stream Function(Ref> ref) create, { + Stream Function(Ref ref, $StreamNotifier self) create, { bool Function(AsyncValue, AsyncValue)? updateShouldNotify, + Retry? retry, }) { return deferredProvider( - (ref) => create(ref), + (ref, self) => create(ref, self), updateShouldNotify: updateShouldNotify, + retry: retry, ); } } diff --git a/packages/riverpod/test/src/providers/async_notifier_test.dart b/packages/riverpod/test/src/providers/async_notifier_test.dart index 81eabed32..497fc2609 100644 --- a/packages/riverpod/test/src/providers/async_notifier_test.dart +++ b/packages/riverpod/test/src/providers/async_notifier_test.dart @@ -10,6 +10,7 @@ import 'package:riverpod/src/framework.dart' show UnmountedRefException; import 'package:riverpod/src/providers/async_notifier.dart' show $AsyncNotifier; import 'package:test/test.dart'; +import '../../third_party/fake_async.dart'; import '../matrix.dart'; import '../utils.dart'; @@ -32,7 +33,7 @@ void main() { test('sets provider(arg) dependencies/allTransitiveDependencies to null', () { final provider = factory.value( - (_, arg) => factory.deferredNotifier((ref) => 0), + (_, arg) => factory.deferredNotifier((ref, _) => 0), dependencies: [], ); @@ -41,9 +42,127 @@ void main() { }); } + group('retry', () { + test( + 'handles retry', + () => fakeAsync((fake) async { + final container = ProviderContainer.test(); + var err = Exception('foo'); + final stack = StackTrace.current; + final provider = factory.simpleTestProvider( + (ref, self) => Error.throwWithStackTrace(err, stack), + retry: (_, __) => const Duration(seconds: 1), + ); + final listener = Listener>(); + + container.listen(provider, fireImmediately: true, listener.call); + await container.read(provider.future).catchError((e) => 0); + + verifyOnly( + listener, + listener(any, AsyncValue.error(err, stack)), + ); + + err = Exception('bar'); + + fake.elapse(const Duration(seconds: 1)); + fake.flushMicrotasks(); + + await container.read(provider.future).catchError((e) => 0); + + verifyOnly( + listener, + listener(any, AsyncValue.error(err, stack)), + ); + }), + ); + + test( + 'manually setting the state to an error does not cause a retry', + () => fakeAsync((fake) async { + final container = ProviderContainer.test(); + var retryCount = 0; + final provider = factory.simpleTestProvider( + (ref, self) => 0, + retry: (_, __) { + retryCount++; + return const Duration(seconds: 1); + }, + ); + final listener = Listener>(); + + container.listen(provider, fireImmediately: true, listener.call); + + expect(retryCount, 0); + + container.read(provider.notifier).state = AsyncValue.error( + Error(), + StackTrace.current, + ); + + expect(retryCount, 0); + }), + ); + }); + + test('resets progress to 0 if restarting while the future is pending', () { + final container = ProviderContainer.test(); + final completer = Completer(); + addTearDown(() => completer.complete(42)); + + final provider = factory.simpleTestProvider((ref, self) { + return completer.future; + }); + + expect(container.read(provider), const AsyncValue.loading()); + + container.read(provider.notifier).state = + const AsyncValue.loading(progress: .2); + + container.refresh(provider); + + expect(container.read(provider), const AsyncValue.loading()); + }); + + test('Does not skip return value if ref.state was set', () async { + final provider = factory.simpleTestProvider((ref, self) async { + await Future.value(); + self.state = const AsyncData(1); + await Future.value(); + self.state = const AsyncData(2); + await Future.value(); + return 3; + }); + final container = ProviderContainer.test(); + final listener = Listener>(); + // Completer used for the sole purpose of being able to await `provider.future` + // Since `provider` emits `AsyncData` before the future completes, then + // `provider.future` completes early. + // As such, awaiting `provider.future` isn't enough to fully await the FutureProvider + final completer = Completer(); + + container.listen>( + provider, + (prev, next) { + if (next.value == 3) completer.complete(); + listener(prev, next); + }, + fireImmediately: true, + ); + + await completer.future; + + verifyInOrder([ + listener(null, const AsyncLoading()), + listener(const AsyncLoading(), const AsyncData(1)), + listener(const AsyncData(1), const AsyncData(2)), + listener(const AsyncData(2), const AsyncData(3)), + ]); + }); + test('Cannot share a Notifier instance between providers ', () { final container = ProviderContainer.test(); - final notifier = factory.deferredNotifier((ref) => 0); + final notifier = factory.deferredNotifier((ref, _) => 0); final provider = factory.provider(() => notifier); final provider2 = factory.provider(() => notifier); @@ -60,7 +179,7 @@ void main() { final container = ProviderContainer.test(); late TestAsyncNotifier notifier; late List errors; - final provider = factory.simpleTestProvider((ref) { + final provider = factory.simpleTestProvider((ref, _) { ref.onDispose(() { errors = captureErrors([ () => notifier.state, @@ -84,7 +203,7 @@ void main() { test('Using the notifier after dispose throws', () { final container = ProviderContainer.test(); - final provider = factory.simpleTestProvider((ref) => 0); + final provider = factory.simpleTestProvider((ref, _) => 0); container.listen(provider.notifier, (prev, next) {}); final notifier = container.read(provider.notifier); @@ -112,7 +231,7 @@ void main() { test('Can assign `AsyncLoading` to `AsyncValue`', () { // Regression test for https://github.com/rrousselGit/riverpod/issues/2120 - final provider = factory.simpleTestProvider((ref) => 42); + final provider = factory.simpleTestProvider((ref, _) => 42); final container = ProviderContainer.test(); final sub = container.listen(provider.notifier, (prev, next) {}); @@ -131,7 +250,7 @@ void main() { test('Can assign `AsyncData` to `AsyncValue`', () { // Regression test for https://github.com/rrousselGit/riverpod/issues/2120 - final provider = factory.simpleTestProvider((ref) => 42); + final provider = factory.simpleTestProvider((ref, _) => 42); final container = ProviderContainer.test(); final sub = container.listen(provider.notifier, (prev, next) {}); @@ -150,7 +269,7 @@ void main() { test('Can assign `AsyncError` to `AsyncValue`', () { // Regression test for https://github.com/rrousselGit/riverpod/issues/2120 - final provider = factory.simpleTestProvider((ref) => 42); + final provider = factory.simpleTestProvider((ref, _) => 42); final container = ProviderContainer.test(); final sub = container.listen(provider.notifier, (prev, next) {}); @@ -176,7 +295,7 @@ void main() { final container = ProviderContainer.test(); var count = 0; final provider = factory.simpleTestProvider( - (ref) => Future.value(count++), + (ref, _) => Future.value(count++), ); container.listen(provider, (previous, next) {}); @@ -206,7 +325,9 @@ void main() { 'performs seamless:false copyWithPrevious on `state = AsyncLoading()`', () async { final container = ProviderContainer.test(); - final provider = factory.simpleTestProvider((ref) => Future.value(0)); + final provider = factory.simpleTestProvider( + (ref, _) => Future.value(0), + ); final sub = container.listen(provider.notifier, (previous, next) {}); @@ -228,7 +349,7 @@ void main() { final container = ProviderContainer.test(); final dep = StateProvider((ref) => 0); final provider = factory.simpleTestProvider( - (ref) => Future.value(ref.watch(dep)), + (ref, _) => Future.value(ref.watch(dep)), ); container.listen(provider, (previous, next) {}); @@ -279,7 +400,7 @@ void main() { final container = ProviderContainer.test(); final dep = StateProvider((ref) => 0); final provider = factory.simpleTestProvider( - (ref) => Future.value(ref.watch(dep)), + (ref, _) => Future.value(ref.watch(dep)), ); container.listen(provider, (previous, next) {}); @@ -300,7 +421,7 @@ void main() { }); test('does not notify listeners when refreshed during loading', () async { - final provider = factory.simpleTestProvider((ref) => Future.value(0)); + final provider = factory.simpleTestProvider((ref, _) => Future.value(0)); final container = ProviderContainer.test(); final listener = Listener>(); @@ -321,8 +442,8 @@ void main() { test('supports listenSelf', () { final listener = Listener>(); final onError = ErrorListener(); - final provider = factory.simpleTestProvider((ref) { - ref.listenSelf(listener.call, onError: onError.call); + final provider = factory.simpleTestProvider((ref, self) { + self.listenSelf(listener.call, onError: onError.call); Error.throwWithStackTrace(42, StackTrace.empty); }); final container = ProviderContainer.test(); @@ -350,7 +471,7 @@ void main() { test( 'converts AsyncNotifier.build into an AsyncData if the future completes', () async { - final provider = factory.simpleTestProvider((ref) => Future.value(0)); + final provider = factory.simpleTestProvider((ref, _) => Future.value(0)); final container = ProviderContainer.test(); final listener = Listener>(); @@ -377,7 +498,7 @@ void main() { test('converts AsyncNotifier.build into an AsyncError if the future fails', () async { final provider = factory.simpleTestProvider( - (ref) => Future.error(0, StackTrace.empty), + (ref, _) => Future.error(0, StackTrace.empty), ); final container = ProviderContainer.test(); final listener = Listener>(); @@ -426,7 +547,7 @@ void main() { test( 'synchronously emits AsyncData if AsyncNotifier.build emits synchronously', () async { - final provider = factory.simpleTestProvider((ref) => 0); + final provider = factory.simpleTestProvider((ref, _) => 0); final container = ProviderContainer.test(); final listener = Listener>(); @@ -441,7 +562,7 @@ void main() { 'synchronously emits AsyncError if AsyncNotifier.build throws synchronously', () async { final provider = factory.simpleTestProvider( - (ref) => Error.throwWithStackTrace(42, StackTrace.empty), + (ref, _) => Error.throwWithStackTrace(42, StackTrace.empty), ); final container = ProviderContainer.test(); final listener = Listener>(); @@ -469,7 +590,7 @@ void main() { 1: Completer.sync(), }; final provider = factory.simpleTestProvider( - (ref) => completers[ref.watch(dep)]!.future, + (ref, _) => completers[ref.watch(dep)]!.future, ); final listener = Listener>(); @@ -508,7 +629,7 @@ void main() { 1: Completer.sync(), }; final provider = factory.simpleTestProvider( - (ref) => completers[ref.watch(dep)]!.future, + (ref, _) => completers[ref.watch(dep)]!.future, ); final listener = Listener>(); @@ -544,7 +665,7 @@ void main() { test( 'when manually modifying the state, the new exposed value contains the previous state when possible', () async { - final provider = factory.simpleTestProvider((ref) => 0); + final provider = factory.simpleTestProvider((ref, _) => 0); final container = ProviderContainer.test(); final sub = container.listen(provider.notifier, (previous, next) {}); @@ -582,12 +703,10 @@ void main() { final provider = factory.provider( () { late TestAsyncNotifier notifier; - return notifier = factory.deferredNotifier( - (ref) { - state = notifier.state; - return Future.value(ref.watch(dep)); - }, - ); + return notifier = factory.deferredNotifier((ref, _) { + state = notifier.state; + return Future.value(ref.watch(dep)); + }); }, ); final container = ProviderContainer.test(); @@ -606,7 +725,7 @@ void main() { }); test('notifies listeners when the setter is called', () { - final provider = factory.simpleTestProvider((ref) => 0); + final provider = factory.simpleTestProvider((ref, _) => 0); final container = ProviderContainer.test(); final listener = Listener>(); @@ -628,7 +747,7 @@ void main() { () async { final container = ProviderContainer.test(); final listener = Listener>(); - var body = () => factory.deferredNotifier((ref) => 0); + var body = () => factory.deferredNotifier((ref, _) => 0); final provider = factory.provider(() => body()); container.listen(provider.future, listener.call); @@ -655,7 +774,7 @@ void main() { final container = ProviderContainer.test(); final completer = Completer.sync(); final provider = factory.simpleTestProvider( - (ref) => completer.future, + (ref, _) => completer.future, ); final future = container.read(provider.future); @@ -672,7 +791,7 @@ void main() { final container = ProviderContainer.test(); final completer = Completer.sync(); final provider = factory.simpleTestProvider( - (ref) => completer.future, + (ref, _) => completer.future, ); final future = container.read(provider.future); @@ -691,7 +810,7 @@ void main() { final container = ProviderContainer.test(); final completer = Completer.sync(); final provider = factory.simpleTestProvider( - (ref) => completer.future, + (ref, _) => completer.future, ); container.read(provider); @@ -714,7 +833,7 @@ void main() { final container = ProviderContainer.test(); final completer = Completer.sync(); final provider = factory.simpleTestProvider( - (ref) => completer.future, + (ref, _) => completer.future, ); container.read(provider); @@ -738,7 +857,7 @@ void main() { final container = ProviderContainer.test(); final completer = Completer.sync(); final provider = factory.simpleTestProvider( - (ref) => completer.future, + (ref, _) => completer.future, ); final listener = Listener>(); @@ -763,7 +882,7 @@ void main() { test('resolves with the new state when notifier.state is changed', () async { final container = ProviderContainer.test(); - final provider = factory.simpleTestProvider((ref) => 0); + final provider = factory.simpleTestProvider((ref, _) => 0); final listener = Listener>(); final sub = container.listen(provider.notifier, (previous, next) {}); @@ -788,7 +907,7 @@ void main() { final listener = OnBuildMock(); final dep = StateProvider((ref) => 0); final provider = factory.simpleTestProvider( - (ref) { + (ref, _) { listener(); return Future.value(ref.watch(dep)); }, @@ -808,7 +927,7 @@ void main() { final container = ProviderContainer.test(); final listener = Listener<$AsyncNotifier>(); final onError = ErrorListener(); - var body = () => factory.deferredNotifier((ref) => 0); + var body = () => factory.deferredNotifier((ref, _) => 0); final provider = factory.provider(() => body()); container.listen( @@ -839,7 +958,7 @@ void main() { final dep = StateProvider((ref) => 0); final provider = factory.provider(() { return factory.deferredNotifier( - (ref) => Future.value(ref.watch(dep)), + (ref, _) => Future.value(ref.watch(dep)), ); }); final container = ProviderContainer.test(); @@ -870,7 +989,7 @@ void main() { 'Can override AsyncNotifier.updateShouldNotify to change the default filter logic', () { final provider = factory.simpleTestProvider>( - (ref) => Equal(42), + (ref, _) => Equal(42), updateShouldNotify: (a, b) => a != b, ); final container = ProviderContainer.test(); @@ -901,7 +1020,7 @@ void main() { test('passes in the latest state', () async { final container = ProviderContainer.test(); final provider = factory.simpleTestProvider( - (ref) => 0, + (ref, _) => 0, ); final sub = container.listen(provider.notifier, (prev, next) {}); @@ -928,7 +1047,7 @@ void main() { test('can specify onError to handle error scenario', () async { final container = ProviderContainer.test(); final provider = factory.simpleTestProvider( - (ref) => Error.throwWithStackTrace(42, StackTrace.empty), + (ref, _) => Error.throwWithStackTrace(42, StackTrace.empty), ); var callCount = 0; Object? actualErr; @@ -964,7 +1083,7 @@ void main() { test('executes immediately with current state if a state is available', () async { final container = ProviderContainer.test(); - final provider = factory.simpleTestProvider((ref) => 1); + final provider = factory.simpleTestProvider((ref, _) => 1); final sub = container.listen(provider.notifier, (prev, next) {}); @@ -981,7 +1100,7 @@ void main() { () async { final container = ProviderContainer.test(); final provider = factory.simpleTestProvider( - (ref) => Error.throwWithStackTrace(42, StackTrace.empty), + (ref, _) => Error.throwWithStackTrace(42, StackTrace.empty), ); var callCount = 0; @@ -1010,7 +1129,7 @@ void main() { test('awaits the future resolution if in loading state', () async { final container = ProviderContainer.test(); final provider = factory.simpleTestProvider( - (ref) => Future.value(42), + (ref, _) => Future.value(42), ); final sub = container.listen(provider.notifier, (prev, next) {}); @@ -1028,17 +1147,17 @@ void main() { test('supports overrideWith', () { final provider = AsyncNotifierProvider, int>( - () => DeferredAsyncNotifier((ref) => 0), + () => DeferredAsyncNotifier((ref, _) => 0), ); final autoDispose = AsyncNotifierProvider.autoDispose, int>( - () => DeferredAsyncNotifier((ref) => 0), + () => DeferredAsyncNotifier((ref, _) => 0), ); final container = ProviderContainer.test( overrides: [ - provider.overrideWith(() => DeferredAsyncNotifier((ref) => 42)), + provider.overrideWith(() => DeferredAsyncNotifier((ref, _) => 42)), autoDispose.overrideWith( - () => DeferredAsyncNotifier((ref) => 84), + () => DeferredAsyncNotifier((ref, _) => 84), ), ], ); @@ -1050,19 +1169,19 @@ void main() { test('supports family overrideWith', () { final family = AsyncNotifierProvider.family< DeferredFamilyAsyncNotifier, int, int>( - () => DeferredFamilyAsyncNotifier((ref) => 0), + () => DeferredFamilyAsyncNotifier((ref, _) => 0), ); final autoDisposeFamily = AsyncNotifierProvider.autoDispose .family, int, int>( - () => DeferredFamilyAsyncNotifier((ref) => 0), + () => DeferredFamilyAsyncNotifier((ref, _) => 0), ); final container = ProviderContainer.test( overrides: [ family.overrideWith( - () => DeferredFamilyAsyncNotifier((ref) => 42), + () => DeferredFamilyAsyncNotifier((ref, _) => 42), ), autoDisposeFamily.overrideWith( - () => DeferredFamilyAsyncNotifier((ref) => 84), + () => DeferredFamilyAsyncNotifier((ref, _) => 84), ), ], ); @@ -1082,7 +1201,7 @@ void main() { test('provider', () { final provider = AsyncNotifierProvider, int>( - () => DeferredAsyncNotifier((ref) => 0), + () => DeferredAsyncNotifier((ref, _) => 0), ); provider.select((AsyncValue value) => 0); @@ -1101,7 +1220,7 @@ void main() { test('autoDispose', () { final autoDispose = AsyncNotifierProvider.autoDispose, int>( - () => DeferredAsyncNotifier((ref) => 0), + () => DeferredAsyncNotifier((ref, _) => 0), ); autoDispose.select((AsyncValue value) => 0); @@ -1124,7 +1243,7 @@ void main() { test('family', () { final family = AsyncNotifierProvider.family< DeferredFamilyAsyncNotifier, String, int>( - () => DeferredFamilyAsyncNotifier((ref) => '0'), + () => DeferredFamilyAsyncNotifier((ref, _) => '0'), ); family(0).select((AsyncValue value) => 0); @@ -1152,7 +1271,7 @@ void main() { final autoDisposeFamily = AsyncNotifierProvider.autoDispose .family, String, int>( - () => DeferredFamilyAsyncNotifier((ref) => '0'), + () => DeferredFamilyAsyncNotifier((ref, _) => '0'), ); autoDisposeFamily(0).select((AsyncValue value) => 0); diff --git a/packages/riverpod/test/src/providers/future_provider_test.dart b/packages/riverpod/test/src/providers/future_provider_test.dart index c202622be..2a8f2722e 100644 --- a/packages/riverpod/test/src/providers/future_provider_test.dart +++ b/packages/riverpod/test/src/providers/future_provider_test.dart @@ -1,5 +1,3 @@ -import 'dart:async'; - import 'package:mockito/mockito.dart'; import 'package:riverpod/riverpod.dart'; import 'package:test/test.dart'; @@ -9,26 +7,6 @@ import '../utils.dart'; void main() { group('FutureProvider', () { - test('resets progress to 0 if restarting while the future is pending', () { - final container = ProviderContainer.test(); - late Ref> ref; - final completer = Completer(); - addTearDown(() => completer.complete(42)); - - final provider = FutureProvider((r) { - ref = r; - return completer.future; - }); - - expect(container.read(provider), const AsyncValue.loading()); - - ref.state = const AsyncValue.loading(progress: .2); - - container.refresh(provider); - - expect(container.read(provider), const AsyncValue.loading()); - }); - group('retry', () { test( 'handles retry', @@ -63,34 +41,6 @@ void main() { ); }), ); - - test( - 'manually setting the state to an error does not cause a retry', - () => fakeAsync((fake) async { - final container = ProviderContainer.test(); - var retryCount = 0; - late Ref> r; - final provider = FutureProvider( - (ref) { - r = ref; - return 0; - }, - retry: (_, __) { - retryCount++; - return const Duration(seconds: 1); - }, - ); - final listener = Listener>(); - - container.listen(provider, fireImmediately: true, listener.call); - - expect(retryCount, 0); - - r.state = AsyncValue.error(Error(), StackTrace.current); - - expect(retryCount, 0); - }), - ); }); }); } diff --git a/packages/riverpod/test/src/providers/notifier_test.dart b/packages/riverpod/test/src/providers/notifier_test.dart index 35ae2a421..bbd164b7d 100644 --- a/packages/riverpod/test/src/providers/notifier_test.dart +++ b/packages/riverpod/test/src/providers/notifier_test.dart @@ -26,7 +26,7 @@ void main() { notifierProviderFactory.createGroup((factory) { test('Cannot share a Notifier instance between providers ', () { final container = ProviderContainer.test(); - final notifier = factory.deferredNotifier((ref) => 0); + final notifier = factory.deferredNotifier((ref, _) => 0); final provider = factory.provider(() => notifier); final provider2 = factory.provider(() => notifier); @@ -43,7 +43,7 @@ void main() { final container = ProviderContainer.test(); late TestNotifier notifier; late List errors; - final provider = factory.simpleTestProvider((ref) { + final provider = factory.simpleTestProvider((ref, _) { ref.onDispose(() { errors = captureErrors([ () => notifier.state, @@ -66,7 +66,7 @@ void main() { test('Using the notifier after dispose throws', () { final container = ProviderContainer.test(); - final provider = factory.simpleTestProvider((ref) => 0); + final provider = factory.simpleTestProvider((ref, _) => 0); container.listen(provider.notifier, (prev, next) {}); final notifier = container.read(provider.notifier); @@ -90,7 +90,7 @@ void main() { // Regression test for https://github.com/rrousselGit/riverpod/issues/2617 final container = ProviderContainer.test(); - final notifier = factory.deferredNotifier((ref) => 0); + final notifier = factory.deferredNotifier((ref, _) => 0); final provider = factory.provider(() => notifier); final provider2 = factory.provider(() => notifier); @@ -109,7 +109,7 @@ void main() { final provider = factory.provider(() { late TestNotifier notifier; - return notifier = factory.deferredNotifier((ref) { + return notifier = factory.deferredNotifier((ref, _) { stateInBuild.add(notifier.stateOrNull); return 0; }); @@ -128,7 +128,7 @@ void main() { test('returns null if Notifier.build threw', () { final provider = factory.simpleTestProvider( - (ref) => throw Exception('42'), + (ref, _) => throw Exception('42'), ); final container = ProviderContainer.test(); @@ -147,7 +147,7 @@ void main() { final provider = factory.provider(() { late TestNotifier notifier; - return notifier = factory.deferredNotifier((ref) { + return notifier = factory.deferredNotifier((ref, _) { stateInBuild.add(notifier.stateOrNull); return 0; }); @@ -167,7 +167,7 @@ void main() { test('Post build, returns the current state', () { final provider = factory.simpleTestProvider( - (ref) => 0, + (ref, _) => 0, ); final container = ProviderContainer.test(); @@ -187,7 +187,7 @@ void main() { 'On invalidated providers, rebuilds the notifier and return the new state', () { final provider = factory.simpleTestProvider( - (ref) => 0, + (ref, _) => 0, ); final container = ProviderContainer.test(); @@ -209,7 +209,7 @@ void main() { test( 'uses notifier.build as initial state and update listeners when state changes', () { - final provider = factory.simpleTestProvider((ref) => 0); + final provider = factory.simpleTestProvider((ref, _) => 0); final container = ProviderContainer.test(); final listener = Listener(); @@ -229,7 +229,7 @@ void main() { final notifierListener = Listener<$Notifier>(); final dep = StateProvider((ref) => 0); final provider = factory.provider(() { - return factory.deferredNotifier((ref) => ref.watch(dep)); + return factory.deferredNotifier((ref, _) => ref.watch(dep)); }); final container = ProviderContainer.test(); @@ -253,7 +253,7 @@ void main() { test('calls notifier.build on every watch update', () async { final dep = StateProvider((ref) => 0); - final provider = factory.simpleTestProvider((ref) { + final provider = factory.simpleTestProvider((ref, _) { return ref.watch(dep); }); final container = ProviderContainer.test(); @@ -274,7 +274,7 @@ void main() { test('After a state initialization error, the notifier is still available', () { - final provider = factory.simpleTestProvider((ref) { + final provider = factory.simpleTestProvider((ref, _) { throw StateError('Hey'); }); final container = ProviderContainer.test(); @@ -344,7 +344,7 @@ void main() { }); test('can read/set the current state within the notifier', () { - final provider = factory.simpleTestProvider((ref) => 0); + final provider = factory.simpleTestProvider((ref, _) => 0); final container = ProviderContainer.test(); final listener = Listener(); @@ -368,8 +368,8 @@ void main() { test( 'Reading the state inside the notifier rethrows initialization error, if any', () { - final provider = - factory.simpleTestProvider((ref) => throw UnimplementedError()); + final provider = factory + .simpleTestProvider((ref, _) => throw UnimplementedError()); final container = ProviderContainer.test(); final notifier = container.read(provider.notifier); @@ -383,7 +383,7 @@ void main() { final err = UnimplementedError(); final stack = StackTrace.current; final provider = factory.simpleTestProvider( - (ref) => Error.throwWithStackTrace(err, stack), + (ref, _) => Error.throwWithStackTrace(err, stack), ); final container = ProviderContainer.test(); final listener = Listener(); @@ -421,7 +421,7 @@ void main() { }); test('supports ref.refresh(provider)', () { - final provider = factory.simpleTestProvider((ref) => 0); + final provider = factory.simpleTestProvider((ref, _) => 0); final container = ProviderContainer.test(); expect(container.read(provider), 0); @@ -438,8 +438,8 @@ void main() { test('supports listenSelf((State? prev, State next) {})', () { final listener = Listener(); final onError = ErrorListener(); - final provider = factory.simpleTestProvider((ref) { - ref.listenSelf(listener.call, onError: onError.call); + final provider = factory.simpleTestProvider((ref, self) { + self.listenSelf(listener.call, onError: onError.call); Error.throwWithStackTrace(42, StackTrace.empty); }); final container = ProviderContainer.test(); @@ -451,7 +451,7 @@ void main() { test('filters state update by identical by default', () { final provider = - factory.simpleTestProvider>((ref) => Equal(42)); + factory.simpleTestProvider>((ref, _) => Equal(42)); final container = ProviderContainer.test(); final listener = Listener>(); @@ -474,7 +474,7 @@ void main() { 'Can override Notifier.updateShouldNotify to change the default filter logic', () { final provider = factory.simpleTestProvider>( - (ref) => Equal(42), + (ref, _) => Equal(42), updateShouldNotify: (a, b) => a != b, ); final container = ProviderContainer.test(); @@ -505,7 +505,7 @@ void main() { test('keeps state alive if notifier is listened', () async { final container = ProviderContainer.test(); final onDispose = OnDisposeMock(); - final provider = factory.simpleTestProvider((ref) { + final provider = factory.simpleTestProvider((ref, _) { ref.onDispose(onDispose.call); return 0; }); @@ -531,17 +531,17 @@ void main() { test('supports overrideWith', () { final provider = NotifierProvider, int>( - () => DeferredNotifier((ref) => 0), + () => DeferredNotifier((ref, _) => 0), ); final autoDispose = NotifierProvider.autoDispose, int>( - () => DeferredNotifier((ref) => 0), + () => DeferredNotifier((ref, _) => 0), ); final container = ProviderContainer.test( overrides: [ - provider.overrideWith(() => DeferredNotifier((ref) => 42)), + provider.overrideWith(() => DeferredNotifier((ref, _) => 42)), autoDispose.overrideWith( - () => DeferredNotifier((ref) => 84), + () => DeferredNotifier((ref, _) => 84), ), ], ); @@ -553,19 +553,19 @@ void main() { test('supports family overrideWith', () { final family = NotifierProvider.family, int, int>( - () => DeferredFamilyNotifier((ref) => 0), + () => DeferredFamilyNotifier((ref, _) => 0), ); final autoDisposeFamily = NotifierProvider.autoDispose .family, int, int>( - () => DeferredFamilyNotifier((ref) => 0), + () => DeferredFamilyNotifier((ref, _) => 0), ); final container = ProviderContainer.test( overrides: [ family.overrideWith( - () => DeferredFamilyNotifier((ref) => 42), + () => DeferredFamilyNotifier((ref, _) => 42), ), autoDisposeFamily.overrideWith( - () => DeferredFamilyNotifier((ref) => 84), + () => DeferredFamilyNotifier((ref, _) => 84), ), ], ); @@ -585,7 +585,7 @@ void main() { test('provider', () { final provider = NotifierProvider, int>( - () => DeferredNotifier((ref) => 0), + () => DeferredNotifier((ref, _) => 0), ); provider.select((int value) => 0); @@ -600,7 +600,7 @@ void main() { test('autoDispose', () { final autoDispose = NotifierProvider.autoDispose, int>( - () => DeferredNotifier((ref) => 0), + () => DeferredNotifier((ref, _) => 0), ); autoDispose.select((int value) => 0); @@ -619,7 +619,7 @@ void main() { test('family', () { final family = NotifierProvider.family, String, int>( - () => DeferredFamilyNotifier((ref) => '0'), + () => DeferredFamilyNotifier((ref, _) => '0'), ); family(0).select((String value) => 0); @@ -643,7 +643,7 @@ void main() { final autoDisposeFamily = NotifierProvider.autoDispose .family, String, int>( - () => DeferredFamilyNotifier((ref) => '0'), + () => DeferredFamilyNotifier((ref, _) => '0'), ); autoDisposeFamily(0).select((String value) => 0); diff --git a/packages/riverpod/test/src/providers/stream_notifier_test.dart b/packages/riverpod/test/src/providers/stream_notifier_test.dart index 1482d64bf..6a6f93bc0 100644 --- a/packages/riverpod/test/src/providers/stream_notifier_test.dart +++ b/packages/riverpod/test/src/providers/stream_notifier_test.dart @@ -34,7 +34,7 @@ void main() { final onCancel = OnCancelMock(); final container = ProviderContainer.test(); final cancelCompleter = Completer.sync(); - final provider = factory.simpleTestProvider((ref) { + final provider = factory.simpleTestProvider((ref, _) { final controller = StreamController(); ref.onDispose(() { controller.addError(42); @@ -72,15 +72,13 @@ void main() { final container = ProviderContainer.test(); - final provider = factory.simpleTestProvider( - (ref) { - return DelegatingStream( - streamController.stream, - onSubscriptionPause: onSubPause.call, - onSubscriptionResume: onSubResume.call, - ); - }, - ); + final provider = factory.simpleTestProvider((ref, _) { + return DelegatingStream( + streamController.stream, + onSubscriptionPause: onSubPause.call, + onSubscriptionResume: onSubResume.call, + ); + }); final sub = container.listen(provider, (previous, next) {}); @@ -105,7 +103,7 @@ void main() { var err = Exception('foo'); final stack = StackTrace.current; final provider = factory.deferredProvider( - (ref) => Error.throwWithStackTrace(err, stack), + (ref, _) => Error.throwWithStackTrace(err, stack), retry: (_, __) => const Duration(seconds: 1), ); final listener = Listener>(); @@ -137,16 +135,16 @@ void main() { () => fakeAsync((fake) async { final container = ProviderContainer.test(); var retryCount = 0; - late Ref> r; - final provider = FutureProvider( - (ref) { - r = ref; - return 0; - }, + late Ref r; + final provider = factory.simpleTestProvider( retry: (_, __) { retryCount++; return const Duration(seconds: 1); }, + (ref, self) { + self.state = const AsyncValue.data(0); + return const Stream.empty(); + }, ); final listener = Listener>(); @@ -154,7 +152,10 @@ void main() { expect(retryCount, 0); - r.state = AsyncValue.error(Error(), StackTrace.current); + container.read(provider.notifier).state = AsyncValue.error( + Error(), + StackTrace.current, + ); expect(retryCount, 0); }), @@ -163,7 +164,7 @@ void main() { test('Cannot share a Notifier instance between providers ', () { final container = ProviderContainer.test(); - final notifier = factory.deferredNotifier((ref) => Stream.value(0)); + final notifier = factory.deferredNotifier((ref, _) => Stream.value(0)); final provider = factory.provider(() => notifier); final provider2 = factory.provider(() => notifier); @@ -180,7 +181,7 @@ void main() { final container = ProviderContainer.test(); late TestStreamNotifier notifier; late List errors; - final provider = factory.simpleTestProvider((ref) { + final provider = factory.simpleTestProvider((ref, self) { ref.onDispose(() { errors = captureErrors([ () => notifier.state, @@ -204,7 +205,9 @@ void main() { test('Using the notifier after dispose throws', () { final container = ProviderContainer.test(); - final provider = factory.simpleTestProvider((ref) => Stream.value(0)); + final provider = factory.simpleTestProvider( + (ref, self) => Stream.value(0), + ); container.listen(provider.notifier, (prev, next) {}); final notifier = container.read(provider.notifier); @@ -237,7 +240,7 @@ void main() { final container = ProviderContainer.test(); var count = 0; final provider = factory.simpleTestProvider( - (ref) => Stream.value(count++), + (ref, self) => Stream.value(count++), ); container.listen(provider, (previous, next) {}); @@ -267,7 +270,9 @@ void main() { 'performs seamless:false copyWithPrevious on `state = AsyncLoading()`', () async { final container = ProviderContainer.test(); - final provider = factory.simpleTestProvider((ref) => Stream.value(0)); + final provider = factory.simpleTestProvider( + (ref, self) => Stream.value(0), + ); final sub = container.listen(provider.notifier, (previous, next) {}); @@ -289,7 +294,7 @@ void main() { final container = ProviderContainer.test(); final dep = StateProvider((ref) => 0); final provider = factory.simpleTestProvider( - (ref) => Stream.value(ref.watch(dep)), + (ref, self) => Stream.value(ref.watch(dep)), ); container.listen(provider, (previous, next) {}); @@ -314,7 +319,7 @@ void main() { final container = ProviderContainer.test(); final dep = StateProvider((ref) => 0); final provider = factory.simpleTestProvider( - (ref) => Stream.value(ref.watch(dep)), + (ref, self) => Stream.value(ref.watch(dep)), ); container.listen(provider, (previous, next) {}); @@ -335,7 +340,9 @@ void main() { }); test('does not notify listeners when refreshed during loading', () async { - final provider = factory.simpleTestProvider((ref) => Stream.value(0)); + final provider = factory.simpleTestProvider( + (ref, self) => Stream.value(0), + ); final container = ProviderContainer.test(); final listener = Listener>(); @@ -356,8 +363,8 @@ void main() { test('supports listenSelf', () { final listener = Listener>(); final onError = ErrorListener(); - final provider = factory.simpleTestProvider((ref) { - ref.listenSelf(listener.call, onError: onError.call); + final provider = factory.simpleTestProvider((ref, self) { + self.listenSelf(listener.call, onError: onError.call); Error.throwWithStackTrace(42, StackTrace.empty); }); final container = ProviderContainer.test(); @@ -385,7 +392,9 @@ void main() { test( 'converts StreamNotifier.build into an AsyncData if the future completes', () async { - final provider = factory.simpleTestProvider((ref) => Stream.value(0)); + final provider = factory.simpleTestProvider( + (ref, self) => Stream.value(0), + ); final container = ProviderContainer.test(); final listener = Listener>(); @@ -412,7 +421,7 @@ void main() { test('converts StreamNotifier.build into an AsyncError if the future fails', () async { final provider = factory.simpleTestProvider( - (ref) => Stream.error(0, StackTrace.empty), + (ref, _) => Stream.error(0, StackTrace.empty), ); final container = ProviderContainer.test(); final listener = Listener>(); @@ -463,7 +472,7 @@ void main() { 'synchronously emits AsyncError if StreamNotifier.build throws synchronously', () async { final provider = factory.simpleTestProvider( - (ref) => Error.throwWithStackTrace(42, StackTrace.empty), + (ref, _) => Error.throwWithStackTrace(42, StackTrace.empty), ); final container = ProviderContainer.test(); final listener = Listener>(); @@ -491,7 +500,7 @@ void main() { 1: Completer.sync(), }; final provider = factory.simpleTestProvider( - (ref) => Stream.fromFuture(completers[ref.watch(dep)]!.future), + (ref, _) => Stream.fromFuture(completers[ref.watch(dep)]!.future), ); final listener = Listener>(); @@ -530,7 +539,7 @@ void main() { 1: Completer.sync(), }; final provider = factory.simpleTestProvider( - (ref) => Stream.fromFuture(completers[ref.watch(dep)]!.future), + (ref, _) => Stream.fromFuture(completers[ref.watch(dep)]!.future), ); final listener = Listener>(); @@ -567,7 +576,7 @@ void main() { 'when manually modifying the state, the new exposed value contains the previous state when possible', () async { final provider = factory.simpleTestProvider( - (ref) => Stream.value(0), + (ref, _) => Stream.value(0), ); final container = ProviderContainer.test(); @@ -610,12 +619,10 @@ void main() { final provider = factory.provider( () { late TestStreamNotifier notifier; - return notifier = factory.deferredNotifier( - (ref) { - state = notifier.state; - return Stream.value(ref.watch(dep)); - }, - ); + return notifier = factory.deferredNotifier((ref, _) { + state = notifier.state; + return Stream.value(ref.watch(dep)); + }); }, ); final container = ProviderContainer.test(); @@ -634,7 +641,9 @@ void main() { }); test('notifies listeners when the setter is called', () async { - final provider = factory.simpleTestProvider((ref) => Stream.value(0)); + final provider = factory.simpleTestProvider( + (ref, self) => Stream.value(0), + ); final container = ProviderContainer.test(); final listener = Listener>(); @@ -661,7 +670,7 @@ void main() { final container = ProviderContainer.test(); final completer = Completer.sync(); final provider = factory.simpleTestProvider( - (ref) => Stream.fromFuture(completer.future), + (ref, _) => Stream.fromFuture(completer.future), ); final future = container.read(provider.future); @@ -678,7 +687,7 @@ void main() { final container = ProviderContainer.test(); final completer = Completer.sync(); final provider = factory.simpleTestProvider( - (ref) => Stream.fromFuture(completer.future), + (ref, _) => Stream.fromFuture(completer.future), ); final future = container.read(provider.future); @@ -697,7 +706,7 @@ void main() { final container = ProviderContainer.test(); final completer = Completer.sync(); final provider = factory.simpleTestProvider( - (ref) => Stream.fromFuture(completer.future), + (ref, _) => Stream.fromFuture(completer.future), ); container.read(provider); @@ -719,7 +728,7 @@ void main() { final container = ProviderContainer.test(); final completer = Completer.sync(); final provider = factory.simpleTestProvider( - (ref) => Stream.fromFuture(completer.future), + (ref, _) => Stream.fromFuture(completer.future), ); container.listen(provider, (previous, next) {}); @@ -742,7 +751,7 @@ void main() { final container = ProviderContainer.test(); final completer = Completer.sync(); final provider = factory.simpleTestProvider( - (ref) => Stream.fromFuture(completer.future), + (ref, _) => Stream.fromFuture(completer.future), ); final listener = Listener>(); @@ -768,7 +777,7 @@ void main() { () async { final container = ProviderContainer.test(); final provider = factory.simpleTestProvider( - (ref) => Stream.value(0), + (ref, _) => Stream.value(0), ); final listener = Listener>(); @@ -793,12 +802,10 @@ void main() { test('returns a Future identical to that of .future', () { final listener = OnBuildMock(); final dep = StateProvider((ref) => 0); - final provider = factory.simpleTestProvider( - (ref) { - listener(); - return Stream.value(ref.watch(dep)); - }, - ); + final provider = factory.simpleTestProvider((ref, _) { + listener(); + return Stream.value(ref.watch(dep)); + }); final container = ProviderContainer.test(); container.listen(provider.notifier, (previous, next) {}); @@ -816,7 +823,7 @@ void main() { final dep = StateProvider((ref) => 0); final provider = factory.provider(() { return factory.deferredNotifier( - (ref) => Stream.value(ref.watch(dep)), + (ref, _) => Stream.value(ref.watch(dep)), ); }); final container = ProviderContainer.test(); @@ -847,7 +854,7 @@ void main() { 'Can override StreamNotifier.updateShouldNotify to change the default filter logic', () async { final provider = factory.simpleTestProvider>( - (ref) => Stream.value(Equal(42)), + (ref, _) => Stream.value(Equal(42)), updateShouldNotify: (a, b) => a != b, ); final container = ProviderContainer.test(); @@ -881,7 +888,7 @@ void main() { test('passes in the latest state', () async { final container = ProviderContainer.test(); final provider = factory.simpleTestProvider( - (ref) => Stream.value(0), + (ref, _) => Stream.value(0), ); // Skip the loading @@ -911,7 +918,7 @@ void main() { test('can specify onError to handle error scenario', () async { final container = ProviderContainer.test(); final provider = factory.simpleTestProvider( - (ref) => Error.throwWithStackTrace(42, StackTrace.empty), + (ref, _) => Error.throwWithStackTrace(42, StackTrace.empty), ); var callCount = 0; Object? actualErr; @@ -948,7 +955,7 @@ void main() { () async { final container = ProviderContainer.test(); final provider = factory.simpleTestProvider( - (ref) => Stream.value(1), + (ref, _) => Stream.value(1), ); // Skip the loading @@ -969,7 +976,7 @@ void main() { () async { final container = ProviderContainer.test(); final provider = factory.simpleTestProvider( - (ref) => Error.throwWithStackTrace(42, StackTrace.empty), + (ref, _) => Error.throwWithStackTrace(42, StackTrace.empty), ); var callCount = 0; @@ -998,7 +1005,7 @@ void main() { test('awaits the future resolution if in loading state', () async { final container = ProviderContainer.test(); final provider = factory.simpleTestProvider( - (ref) => Stream.value(42), + (ref, _) => Stream.value(42), ); final sub = container.listen(provider.notifier, (prev, next) {}); @@ -1016,19 +1023,19 @@ void main() { test('supports overrideWith', () async { final provider = StreamNotifierProvider, int>( - () => DeferredStreamNotifier((ref) => Stream.value(0)), + () => DeferredStreamNotifier((ref, _) => Stream.value(0)), ); final autoDispose = StreamNotifierProvider.autoDispose, int>( - () => DeferredStreamNotifier((ref) => Stream.value(0)), + () => DeferredStreamNotifier((ref, _) => Stream.value(0)), ); final container = ProviderContainer.test( overrides: [ provider.overrideWith( - () => DeferredStreamNotifier((ref) => Stream.value(42)), + () => DeferredStreamNotifier((ref, _) => Stream.value(42)), ), autoDispose.overrideWith( - () => DeferredStreamNotifier((ref) => Stream.value(84)), + () => DeferredStreamNotifier((ref, _) => Stream.value(84)), ), ], ); @@ -1044,20 +1051,20 @@ void main() { test('supports family overrideWith', () async { final family = StreamNotifierProvider.family< DeferredFamilyStreamNotifier, int, int>( - () => DeferredFamilyStreamNotifier((ref) => Stream.value(0)), + () => DeferredFamilyStreamNotifier((ref, _) => Stream.value(0)), ); final autoDisposeFamily = StreamNotifierProvider.autoDispose .family, int, int>( - () => DeferredFamilyStreamNotifier((ref) => Stream.value(0)), + () => DeferredFamilyStreamNotifier((ref, _) => Stream.value(0)), ); final container = ProviderContainer.test( overrides: [ family.overrideWith( - () => DeferredFamilyStreamNotifier((ref) => Stream.value(42)), + () => DeferredFamilyStreamNotifier((ref, _) => Stream.value(42)), ), autoDisposeFamily.overrideWith( () => DeferredFamilyStreamNotifier( - (ref) => Stream.value(84), + (ref, _) => Stream.value(84), ), ), ], @@ -1078,7 +1085,7 @@ void main() { final dep = Provider.autoDispose((ref) => 0); final provider = StreamNotifierProvider.autoDispose, int>( - () => DeferredStreamNotifier((ref) { + () => DeferredStreamNotifier((ref, _) { return Stream.value(ref.watch(dep)); }), ); @@ -1102,7 +1109,7 @@ void main() { test('provider', () { final provider = StreamNotifierProvider, int>( - () => DeferredStreamNotifier((ref) => Stream.value(0)), + () => DeferredStreamNotifier((ref, _) => Stream.value(0)), ); provider.select((AsyncValue value) => 0); @@ -1121,7 +1128,7 @@ void main() { test('autoDispose', () { final autoDispose = StreamNotifierProvider.autoDispose, int>( - () => DeferredStreamNotifier((ref) => Stream.value(0)), + () => DeferredStreamNotifier((ref, _) => Stream.value(0)), ); autoDispose.select((AsyncValue value) => 0); @@ -1144,7 +1151,7 @@ void main() { test('family', () { final family = StreamNotifierProvider.family< DeferredFamilyStreamNotifier, String, int>( - () => DeferredFamilyStreamNotifier((ref) => Stream.value('0')), + () => DeferredFamilyStreamNotifier((ref, _) => Stream.value('0')), ); family(0).select((AsyncValue value) => 0); @@ -1172,7 +1179,7 @@ void main() { final autoDisposeFamily = StreamNotifierProvider.autoDispose .family, String, int>( - () => DeferredFamilyStreamNotifier((ref) => Stream.value('0')), + () => DeferredFamilyStreamNotifier((ref, _) => Stream.value('0')), ); autoDisposeFamily(0).select((AsyncValue value) => 0); diff --git a/packages/riverpod/test/src/utils.dart b/packages/riverpod/test/src/utils.dart index 6705992f7..d2344bcf3 100644 --- a/packages/riverpod/test/src/utils.dart +++ b/packages/riverpod/test/src/utils.dart @@ -119,7 +119,7 @@ class OverrideWithBuildMock extends Mock { final CreatedT fallback; - CreatedT call(Ref? ref, NotifierT? value) { + CreatedT call(Ref? ref, NotifierT? value) { return super.noSuchMethod( Invocation.method(#call, [ref, value]), returnValue: fallback, diff --git a/packages/riverpod_analyzer_utils/CHANGELOG.md b/packages/riverpod_analyzer_utils/CHANGELOG.md index 629c4d80c..2836f63f1 100644 --- a/packages/riverpod_analyzer_utils/CHANGELOG.md +++ b/packages/riverpod_analyzer_utils/CHANGELOG.md @@ -13,7 +13,16 @@ - Added `GeneratorProviderDeclarationElement.isFamily` -## Unreleased patch +## 0.5.7 - 2024-10-27 + +- Support latest custom_lint + +## 0.5.6 - 2024-10-22 + +- Support analyzer >=6.7.0 <7.0.0 + This should make it compatible with Flutter's stable channel. + +## 0.5.5 - 2024-10-12 Bumped minimum analyzer to 6.9.0 diff --git a/packages/riverpod_analyzer_utils/lib/src/nodes/dependencies.dart b/packages/riverpod_analyzer_utils/lib/src/nodes/dependencies.dart index 73e42b417..474132174 100644 --- a/packages/riverpod_analyzer_utils/lib/src/nodes/dependencies.dart +++ b/packages/riverpod_analyzer_utils/lib/src/nodes/dependencies.dart @@ -333,7 +333,9 @@ extension on AnnotatedNode { // Always initialize root declarations, // to handle cases where a method in a class has @Dependencies // but the class itself does not. - this is! CompilationUnitMember) return null; + this is! CompilationUnitMember) { + return null; + } return AccumulatedDependencyList._( node: this, diff --git a/packages/riverpod_analyzer_utils/lib/src/nodes/provider_or_family.dart b/packages/riverpod_analyzer_utils/lib/src/nodes/provider_or_family.dart index fcb0f11b9..84c62ee84 100644 --- a/packages/riverpod_analyzer_utils/lib/src/nodes/provider_or_family.dart +++ b/packages/riverpod_analyzer_utils/lib/src/nodes/provider_or_family.dart @@ -63,7 +63,9 @@ final class ProviderOrFamilyExpression { final returnType = expression.staticType; if (returnType == null) return null; if (!providerBaseType.isAssignableFromType(returnType) && - !familyType.isAssignableFromType(returnType)) return null; + !familyType.isAssignableFromType(returnType)) { + return null; + } final parseResult = _parsesProviderExpression(expression); if (parseResult == null) return null; diff --git a/packages/riverpod_analyzer_utils/lib/src/nodes/ref_invocation.dart b/packages/riverpod_analyzer_utils/lib/src/nodes/ref_invocation.dart index e69a3f494..5a0515010 100644 --- a/packages/riverpod_analyzer_utils/lib/src/nodes/ref_invocation.dart +++ b/packages/riverpod_analyzer_utils/lib/src/nodes/ref_invocation.dart @@ -16,7 +16,8 @@ extension RefInvocationX on MethodInvocation { final functionOwner = function.staticElement .cast() ?.declaration - .enclosingElement3; + // ignore: deprecated_member_use, required to support lower versions of analyzer + .enclosingElement; if (functionOwner == null || // Since Ref is sealed, checking that the function is from the package:riverpod diff --git a/packages/riverpod_analyzer_utils/lib/src/nodes/widget_ref_invocation.dart b/packages/riverpod_analyzer_utils/lib/src/nodes/widget_ref_invocation.dart index 5bdf93f49..aa052d0dc 100644 --- a/packages/riverpod_analyzer_utils/lib/src/nodes/widget_ref_invocation.dart +++ b/packages/riverpod_analyzer_utils/lib/src/nodes/widget_ref_invocation.dart @@ -21,7 +21,8 @@ extension WidgetRefInvocationX on MethodInvocation { final functionOwner = function.staticElement .cast() ?.declaration - .enclosingElement3; + // ignore: deprecated_member_use, required to support lower versions of analyzer + .enclosingElement; if (functionOwner == null || // Since Ref is sealed, checking that the function is from the package:riverpod diff --git a/packages/riverpod_analyzer_utils/lib/src/nodes/widgets/stateful_widget.dart b/packages/riverpod_analyzer_utils/lib/src/nodes/widgets/stateful_widget.dart index 6bd15f065..cb6dd5ff7 100644 --- a/packages/riverpod_analyzer_utils/lib/src/nodes/widgets/stateful_widget.dart +++ b/packages/riverpod_analyzer_utils/lib/src/nodes/widgets/stateful_widget.dart @@ -21,7 +21,10 @@ ClassElement? _findStateFromReturnType(ClassElement node) { } ClassElement? _findStateWithMatchingGeneric(ClassElement node) { - for (final clazz in node.enclosingElement3.classes) { + for (final clazz in node + // ignore: deprecated_member_use, required to support lower versions of analyzer + .enclosingElement + .classes) { final type = clazz.supertype; if (type != null && isState(type) && _findStateWidget(clazz) == node) { return clazz; diff --git a/packages/riverpod_analyzer_utils/pubspec.yaml b/packages/riverpod_analyzer_utils/pubspec.yaml index 6df2391c1..c88856251 100644 --- a/packages/riverpod_analyzer_utils/pubspec.yaml +++ b/packages/riverpod_analyzer_utils/pubspec.yaml @@ -10,10 +10,10 @@ environment: sdk: ">=3.0.0<4.0.0" dependencies: - analyzer: ^6.9.0 + analyzer: ^6.7.0 collection: ^1.16.0 crypto: ^3.0.2 - custom_lint_core: ^0.6.5 + custom_lint_core: ^0.7.0 freezed_annotation: ^2.2.0 meta: ^1.7.0 path: ^1.8.0 diff --git a/packages/riverpod_analyzer_utils_tests/pubspec.yaml b/packages/riverpod_analyzer_utils_tests/pubspec.yaml index 2327173ed..aae67e74c 100644 --- a/packages/riverpod_analyzer_utils_tests/pubspec.yaml +++ b/packages/riverpod_analyzer_utils_tests/pubspec.yaml @@ -6,7 +6,7 @@ environment: sdk: ">=3.0.0<4.0.0" dependencies: - analyzer: ">=5.12.0 <7.0.0" + analyzer: ^6.7.0 collection: ^1.16.0 freezed_annotation: ^2.2.0 meta: ^1.7.0 diff --git a/packages/riverpod_analyzer_utils_tests/test/legacy_provider_declaration_test.dart b/packages/riverpod_analyzer_utils_tests/test/legacy_provider_declaration_test.dart index c6e05c054..079668e09 100644 --- a/packages/riverpod_analyzer_utils_tests/test/legacy_provider_declaration_test.dart +++ b/packages/riverpod_analyzer_utils_tests/test/legacy_provider_declaration_test.dart @@ -56,11 +56,11 @@ part 'foo.g.dart'; final legacy = Provider((ref) => 0); @riverpod -int simple(SimpleRef ref) => 0; +int simple(Ref ref) => 0; // Regression test for https://github.com/rrousselGit/riverpod/issues/2194 @riverpod -int complex(ComplexRef ref, {int? id, String? another}) => 0; +int complex(Ref ref, {int? id, String? another}) => 0; ''', (resolver, unit, units) async { final result = await resolver.resolveRiverpodAnalysisResult(); diff --git a/packages/riverpod_analyzer_utils_tests/test/nodes/dependencies_test.dart b/packages/riverpod_analyzer_utils_tests/test/nodes/dependencies_test.dart index d5c526523..5585672bb 100644 --- a/packages/riverpod_analyzer_utils_tests/test/nodes/dependencies_test.dart +++ b/packages/riverpod_analyzer_utils_tests/test/nodes/dependencies_test.dart @@ -13,7 +13,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter/material.dart'; @riverpod -int a(ARef ref) => 0; +int a(Ref ref) => 0; @riverpod class B extends _$B { @@ -22,7 +22,7 @@ class B extends _$B { } @riverpod -int c(CRef ref, int arg) => 0; +int c(Ref ref, int arg) => 0; @riverpod class D extends _$D { diff --git a/packages/riverpod_analyzer_utils_tests/test/nodes/providers/generated_providers_test.dart b/packages/riverpod_analyzer_utils_tests/test/nodes/providers/generated_providers_test.dart index e18371f3b..eed80d7fd 100644 --- a/packages/riverpod_analyzer_utils_tests/test/nodes/providers/generated_providers_test.dart +++ b/packages/riverpod_analyzer_utils_tests/test/nodes/providers/generated_providers_test.dart @@ -9,7 +9,7 @@ void main() { import 'package:riverpod_annotation/riverpod_annotation.dart'; @riverpod -T generic(GenericRef ref) => throw UnimplementedError(); +T generic(Ref ref) => throw UnimplementedError(); @riverpod class GenericClass extends _$GenericClass { @@ -18,7 +18,7 @@ class GenericClass extends _$GenericClass { } @riverpod -int value(ValueRef ref) => throw UnimplementedError(); +int value(Ref ref) => throw UnimplementedError(); @riverpod class ValueClass extends _$ValueClass { @@ -27,7 +27,7 @@ class ValueClass extends _$ValueClass { } @riverpod -int parametrized(ParametrizedRef ref, int id) => throw UnimplementedError(); +int parametrized(Ref ref, int id) => throw UnimplementedError(); @riverpod class ParametrizedClass extends _$ParametrizedClass { @@ -57,13 +57,13 @@ class ParametrizedClass extends _$ParametrizedClass { import 'package:riverpod_annotation/riverpod_annotation.dart'; @riverpod -Raw> value(ValueRef ref) async => 0; +Raw> value(Ref ref) async => 0; @riverpod -Future value2(Value2Ref ref) async => 0; +Future value2(Ref ref) async => 0; @riverpod -Future> value3(Value3Ref ref) async => 0; +Future> value3(Ref ref) async => 0; ''', (resolver, unit, units) async { final value = unit.declarations.findByName('value').provider!; @@ -110,7 +110,7 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; int scoped() => 0; @riverpod -int plain(PlainRef ref) => 0; +int plain(Ref ref) => 0; ''', (resolver, unit, units) async { final scoped = unit.declarations.findByName('scoped').provider!; @@ -127,10 +127,10 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'foo.g.dart'; @riverpod -int first(FirstRef ref) => 0; +int first(Ref ref) => 0; @Riverpod() -int second(SecondRef ref) => 0; +int second(Ref ref) => 0; @riverpod class Counter extends _$Counter { @@ -159,13 +159,13 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'foo.g.dart'; @riverpod -int autoDispose(AutoDisposeRef ref) => 0; +int autoDispose(Ref ref) => 0; @Riverpod(keepAlive: false) -int autoDispose2(AutoDisposeRef ref) => 0; +int autoDispose2(Ref ref) => 0; @Riverpod(keepAlive: true) -int keepAlive(KeepAliveRef ref) => 0; +int keepAlive(Ref ref) => 0; @riverpod class AutoDisposeNotifierTest extends _$AutoDisposeNotifierTest { @@ -245,7 +245,7 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'foo.g.dart'; @riverpod -int root(RootRef ref) => 0; +int root(Ref ref) => 0; @riverpod class RootNotifier extends _$RootNotifier { @@ -254,7 +254,7 @@ class RootNotifier extends _$RootNotifier { } @Riverpod(dependencies: []) -int empty(EmptyRef ref) => 0; +int empty(Ref ref) => 0; @Riverpod(dependencies: []) class EmptyNotifier extends _$EmptyNotifier { @@ -263,7 +263,7 @@ class EmptyNotifier extends _$EmptyNotifier { } @Riverpod(dependencies: [empty, EmptyNotifier]) -int providerDependency(ProviderDependencyRef ref) => 0; +int providerDependency(Ref ref) => 0; @Riverpod(dependencies: [empty, EmptyNotifier]) class ProviderDependencyNotifier extends _$ProviderDependencyNotifier { @@ -272,7 +272,7 @@ class ProviderDependencyNotifier extends _$ProviderDependencyNotifier { } @Riverpod(dependencies: [providerDependency, ProviderDependencyNotifier]) -int nestedDependency(NestedDependencyRef ref) => 0; +int nestedDependency(Ref ref) => 0; @Riverpod(dependencies: [providerDependency, ProviderDependencyNotifier]) class NestedDependencyNotifier extends _$NestedDependencyNotifier { @@ -281,7 +281,7 @@ class NestedDependencyNotifier extends _$NestedDependencyNotifier { } @Riverpod(dependencies: [empty, EmptyNotifier]) -int family(NestedDependencyRef ref) => 0; +int family(Ref ref) => 0; @Riverpod(dependencies: [empty, EmptyNotifier]) class FamilyClass extends _$FamilyClass { diff --git a/packages/riverpod_analyzer_utils_tests/test/nodes/providers/identifiers_test.dart b/packages/riverpod_analyzer_utils_tests/test/nodes/providers/identifiers_test.dart index 6a55d413a..93c46fb2e 100644 --- a/packages/riverpod_analyzer_utils_tests/test/nodes/providers/identifiers_test.dart +++ b/packages/riverpod_analyzer_utils_tests/test/nodes/providers/identifiers_test.dart @@ -16,7 +16,7 @@ part 'foo.g.dart'; // Let's define some providers @riverpod -int a(ARef ref) => 0; +int a(Ref ref) => 0; @riverpod class B extends _$B { diff --git a/packages/riverpod_analyzer_utils_tests/test/nodes/riverpod_test.dart b/packages/riverpod_analyzer_utils_tests/test/nodes/riverpod_test.dart index 62c1f2a66..5335ae89a 100644 --- a/packages/riverpod_analyzer_utils_tests/test/nodes/riverpod_test.dart +++ b/packages/riverpod_analyzer_utils_tests/test/nodes/riverpod_test.dart @@ -13,27 +13,27 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; const deps = []; @Riverpod(dependencies: deps) -int first(FirstRef ref) => 0; +int first(Ref ref) => 0; @Riverpod(dependencies: ) -int second(SecondRef ref) => 0; +int second(Ref ref) => 0; @Riverpod(dependencies: [gibberish]) -int forth(ForthRef ref) => 0; +int forth(Ref ref) => 0; @Riverpod(dependencies: [if (true) forth]) -int fifth(FifthRef ref) => 0; +int fifth(Ref ref) => 0; @Riverpod(dependencies: [int]) -int sixth(SixthRef ref) => 0; +int sixth(Ref ref) => 0; void fn() {} @Riverpod(dependencies: [fn]) -int seven(SevenRef ref) => 0; +int seven(Ref ref) => 0; @Riverpod(dependencies: ['foo']) -int eight(EightRef ref) => 0; +int eight(Ref ref) => 0; ''', (resolver, unit, units) async { final errors = collectErrors(() { for (final d in unit.declarations) { @@ -117,13 +117,13 @@ int eight(EightRef ref) => 0; import 'package:riverpod_annotation/riverpod_annotation.dart'; @riverpod -int dependency(DependencyRef ref) => 0; +int dependency(Ref ref) => 0; @Riverpod(dependencies: [dependency]) -int fn(FnRef ref) => 0; +int fn(Ref ref) => 0; @Riverpod(dependencies: [dependency]) -int fn2(FnRef ref) => 0; +int fn2(Ref ref) => 0; ''', (resolver, unit, units) async { final dependency = unit.declarations.findByName('dependency').riverpod; @@ -148,13 +148,13 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; int unrelated() => 0; @riverpod -int variable(VariableRef ref) => 0; +int variable(Ref ref) => 0; @Riverpod() -int constructor(ConstructorRef ref) => 0; +int constructor(Ref ref) => 0; @Riverpod(keepAlive: false, dependencies: null) -int explicit(ExplicitRef ref) => 0; +int explicit(Ref ref) => 0; @Riverpod(keepAlive: true, dependencies: [variable]) int constructor2(Constructor2Ref ref) => 0; diff --git a/packages/riverpod_analyzer_utils_tests/test/ref_invocation_test.dart b/packages/riverpod_analyzer_utils_tests/test/ref_invocation_test.dart index 36cf64bab..b56d2c3c7 100644 --- a/packages/riverpod_analyzer_utils_tests/test/ref_invocation_test.dart +++ b/packages/riverpod_analyzer_utils_tests/test/ref_invocation_test.dart @@ -36,7 +36,7 @@ import 'file.dart' as alias; part 'foo.g.dart'; @Riverpod(keepAlive: true) -int aliased(AliasedRef ref) { +int aliased(Ref ref) { ref.watch(alias.aProvider); return 0; } @@ -99,7 +99,7 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'foo.g.dart'; @riverpod -int generated(GeneratedRef ref) => 0; +int generated(Ref ref) => 0; @riverpod class MyNotifier extends _$MyNotifier { @@ -444,7 +444,7 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; final dep = FutureProvider((ref) => 0); final dep2 = FutureProvider((ref) => 0); -void fn(Ref ref) { +void fn(Ref ref) { ref.read(dep); ref.read(dep2); } diff --git a/packages/riverpod_analyzer_utils_tests/test/type_utils_test.dart b/packages/riverpod_analyzer_utils_tests/test/type_utils_test.dart index 7fd884c13..ddc0205ca 100644 --- a/packages/riverpod_analyzer_utils_tests/test/type_utils_test.dart +++ b/packages/riverpod_analyzer_utils_tests/test/type_utils_test.dart @@ -45,7 +45,7 @@ part 'foo.g.dart'; Never throws() => throw UnimplementedError(); @riverpod -int a(ARef ref) => throws(); +int a(Ref ref) => throws(); @riverpod class B extends _$B { @@ -54,7 +54,7 @@ class B extends _$B { } @riverpod -int c(CRef ref, int arg) => throws(); +int c(Ref ref, int arg) => throws(); @riverpod class D extends _$D { diff --git a/packages/riverpod_annotation/CHANGELOG.md b/packages/riverpod_annotation/CHANGELOG.md index 739e84940..a677b4bc5 100644 --- a/packages/riverpod_annotation/CHANGELOG.md +++ b/packages/riverpod_annotation/CHANGELOG.md @@ -25,6 +25,18 @@ - `riverpod` upgraded to `3.0.0-dev.0` +## 2.6.1 - 2024-10-22 + +- `riverpod` upgraded to `2.6.1` + +## 2.6.0 - 2024-10-20 + +- `riverpod` upgraded to `2.6.0` + +## 2.5.3 - 2024-10-12 + +- `riverpod` upgraded to `2.5.3` + ## 2.3.5 - 2024-03-10 - `riverpod` upgraded to `2.5.1` diff --git a/packages/riverpod_annotation/lib/riverpod_annotation.dart b/packages/riverpod_annotation/lib/riverpod_annotation.dart index fb6b71d14..feb355c4a 100644 --- a/packages/riverpod_annotation/lib/riverpod_annotation.dart +++ b/packages/riverpod_annotation/lib/riverpod_annotation.dart @@ -16,10 +16,10 @@ export 'package:riverpod/src/internals.dart' $FamilyOverride, $FunctionalProvider, $FutureModifier, + Ref, NotifierBase, $AsyncClassModifier, $ClassProvider, - Ref, $ValueProvider, $ProviderOverride, $RefArg, diff --git a/packages/riverpod_annotation/lib/src/riverpod_annotation.dart b/packages/riverpod_annotation/lib/src/riverpod_annotation.dart index 4092357a0..b2a7f0886 100644 --- a/packages/riverpod_annotation/lib/src/riverpod_annotation.dart +++ b/packages/riverpod_annotation/lib/src/riverpod_annotation.dart @@ -55,12 +55,12 @@ final class Riverpod { /// ```dart /// // By not specifying "dependencies", we are saying that this provider is never scoped /// @riverpod - /// Foo root(RootRef ref) => Foo(); + /// Foo root(Ref ref) => Foo(); /// /// // By specifying "dependencies" (even if the list is empty), /// // we are saying that this provider is potentially scoped /// @Riverpod(dependencies: []) - /// Foo scoped(ScopedRef ref) => Foo(); + /// Foo scoped(Ref ref) => Foo(); /// /// // Alternatively, notifiers with an abstract build method are also considered scoped /// @riverpod @@ -75,14 +75,14 @@ final class Riverpod { /// /// ```dart /// @riverpod - /// Object? dependent(DependentRef ref) { + /// Object? dependent(Ref ref) { /// ref.watch(rootProvider); /// // This provider does not depend on any scoped provider, /// // as such "dependencies" is optional /// } /// /// @Riverpod(dependencies: []) - /// Object? dependent(DependentRef ref) { + /// Object? dependent(Ref ref) { /// ref.watch(rootProvider); /// // This provider decided to specify "dependencies" anyway, marking /// // "dependentProvider" as possibly scoped. @@ -91,7 +91,7 @@ final class Riverpod { /// } /// /// @Riverpod(dependencies: [root]) - /// Object? dependent(DependentRef ref) { + /// Object? dependent(Ref ref) { /// ref.watch(rootProvider); /// // Including "rootProvider" in "dependencies" is fine too, even though /// // it is not required. It is a no-op. @@ -102,7 +102,7 @@ final class Riverpod { /// /// ```dart /// @Riverpod(dependencies: [scoped]) - /// Object? dependent(DependentRef ref) { + /// Object? dependent(Ref ref) { /// ref.watch(scopedProvider); /// // Since "scopedProvider" specifies "dependencies", any provider that /// // depends on it must also specify "dependencies" and include "scopedProvider". @@ -203,7 +203,7 @@ class MissingScopeException implements Exception { MissingScopeException(this.ref); /// The [Ref] that threw the exception - final Ref ref; + final Ref ref; @override String toString() { @@ -232,7 +232,7 @@ class MissingScopeException implements Exception { /// Consider the following scoped provider: /// ```dart /// @Riverpod(dependencies: []) -/// String selectedBookID(SelectedBookIDRef ref) => throw UnimplementedError(); +/// String selectedBookID(Ref ref) => throw UnimplementedError(); /// ``` /// /// Since this provider is scoped, we should specify `@Dependencies` on any object diff --git a/packages/riverpod_generator/CHANGELOG.md b/packages/riverpod_generator/CHANGELOG.md index 1fb5e7681..b209439e1 100644 --- a/packages/riverpod_generator/CHANGELOG.md +++ b/packages/riverpod_generator/CHANGELOG.md @@ -6,7 +6,7 @@ ```dart @riverpod - String example(ExampleRef ref, int arg, {required int anotherArg}) {...} + String example(Ref ref, int arg, {required int anotherArg}) {...} // ... exampleProvider.overrideWith( (ref, ({int arg, int anotherArg}) args) { @@ -17,7 +17,30 @@ - Added support for `@Riverpod(retry: ...)` -## Unreleased patch +## 2.6.2 - 2024-10-27 + +- `riverpod_analyzer_utils` upgraded to `0.5.7` + +## 2.6.1 - 2024-10-22 + +- Support analyzer >=6.7.0 <7.0.0 + This should make it compatible with Flutter's stable channel. + +## 2.6.0 - 2024-10-20 + +- Deprecated the generated `Ref` subclasses. + Instead of: + ```dart + @riverpod + Model foo(FooRef ref) => .. + ``` + Do: + ```dart + @riverpod + Model foo(Ref ref) => .. + ``` + +## 2.4.4 - 2024-10-12 - `@Riverpod(dependencies: [...])` now respects `build.yaml` options diff --git a/packages/riverpod_generator/README.md b/packages/riverpod_generator/README.md index d331bec0d..d3566d46d 100644 --- a/packages/riverpod_generator/README.md +++ b/packages/riverpod_generator/README.md @@ -38,7 +38,7 @@ part 'my_file.g.dart'; // In this example, riverpod_generator will use this function and generate a matching "fetchProductProvider". // The following example would be the equivalent of a "FutureProvider.autoDispose.family" @riverpod -Future> fetchProducts(FetchProductRef ref, {required int page, int limit = 50}) async { +Future> fetchProducts(Ref ref, {required int page, int limit = 50}) async { final dio = Dio(); final response = await dio.get('https://my-api/products?page=$page&limit=$limit'); final json = response.data! as List; @@ -138,7 +138,7 @@ part 'main.g.dart'; // Providers are defined by annotating a function with @riverpod @riverpod -String label(LabelRef ref) => 'Hello world'; +String label(Ref ref) => 'Hello world'; void main() { runApp(ProviderScope(child: Home())); diff --git a/packages/riverpod_generator/integration/build_yaml/lib/dependencies.dart b/packages/riverpod_generator/integration/build_yaml/lib/dependencies.dart index 04de89ed6..4b3fc48b4 100644 --- a/packages/riverpod_generator/integration/build_yaml/lib/dependencies.dart +++ b/packages/riverpod_generator/integration/build_yaml/lib/dependencies.dart @@ -20,7 +20,7 @@ part 'dependencies.g.dart'; CountStreamNotifier2, ], ) -int calc2(Calc2Ref ref, String id) { +int calc2(Ref ref, String id) { ref.watch(myCountPod); ref.watch(myCountFuturePod); ref.watch(myCountStreamPod); diff --git a/packages/riverpod_generator/integration/build_yaml/lib/dependencies.g.dart b/packages/riverpod_generator/integration/build_yaml/lib/dependencies.g.dart index 5be9cfabb..dfcc891f4 100644 --- a/packages/riverpod_generator/integration/build_yaml/lib/dependencies.g.dart +++ b/packages/riverpod_generator/integration/build_yaml/lib/dependencies.g.dart @@ -6,18 +6,16 @@ part of 'dependencies.dart'; // RiverpodGenerator // ************************************************************************** -typedef Calc2Ref = Ref; - @ProviderFor(calc2) const myFamilyCalc2ProviderFamily = Calc2Family._(); final class Calc2Provider extends $FunctionalProvider - with $Provider { + with $Provider { const Calc2Provider._( {required Calc2Family super.from, required String super.argument, int Function( - Calc2Ref ref, + Ref ref, String id, )? create}) : _createCb = create, @@ -46,7 +44,7 @@ final class Calc2Provider extends $FunctionalProvider myFamilyCountStreamNotifier2ProviderFamily; final int Function( - Calc2Ref ref, + Ref ref, String id, )? _createCb; @@ -76,7 +74,7 @@ final class Calc2Provider extends $FunctionalProvider @override Calc2Provider $copyWithCreate( int Function( - Calc2Ref ref, + Ref ref, ) create, ) { return Calc2Provider._( @@ -90,7 +88,7 @@ final class Calc2Provider extends $FunctionalProvider } @override - int create(Calc2Ref ref) { + int create(Ref ref) { final _$cb = _createCb ?? calc2; final argument = this.argument as String; return _$cb( @@ -110,7 +108,7 @@ final class Calc2Provider extends $FunctionalProvider } } -String _$calc2Hash() => r'0972ac060d49cb3f08f9192af9cea0611a6b4616'; +String _$calc2Hash() => r'ae1d601ff7cdda569255e8014bd5d8d1c178b3eb'; final class Calc2Family extends Family { const Calc2Family._() @@ -162,7 +160,7 @@ final class Calc2Family extends Family { /// {@macro riverpod.override_with} Override overrideWith( int Function( - Calc2Ref ref, + Ref ref, String args, ) create, ) { @@ -181,4 +179,4 @@ final class Calc2Family extends Family { } } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/packages/riverpod_generator/integration/build_yaml/lib/main.dart b/packages/riverpod_generator/integration/build_yaml/lib/main.dart index 1cfb4ea9a..df64e3942 100644 --- a/packages/riverpod_generator/integration/build_yaml/lib/main.dart +++ b/packages/riverpod_generator/integration/build_yaml/lib/main.dart @@ -3,17 +3,17 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'main.g.dart'; @riverpod -int count(CountRef ref) { +int count(Ref ref) { return 1; } @riverpod -FutureOr countFuture(CountFutureRef ref) { +FutureOr countFuture(Ref ref) { return 1; } @riverpod -Stream countStream(CountStreamRef ref) { +Stream countStream(Ref ref) { return Stream.value(1); } @@ -42,17 +42,17 @@ class CountStreamNotifier extends _$CountStreamNotifier { } @riverpod -int count2(Count2Ref ref, int a) { +int count2(Ref ref, int a) { return 1; } @riverpod -FutureOr countFuture2(CountFuture2Ref ref, int a) { +FutureOr countFuture2(Ref ref, int a) { return 1; } @riverpod -Stream countStream2(CountStream2Ref ref, int a) { +Stream countStream2(Ref ref, int a) { return Stream.value(1); } diff --git a/packages/riverpod_generator/integration/build_yaml/lib/main.g.dart b/packages/riverpod_generator/integration/build_yaml/lib/main.g.dart index fad75ddb1..2f67f0f14 100644 --- a/packages/riverpod_generator/integration/build_yaml/lib/main.g.dart +++ b/packages/riverpod_generator/integration/build_yaml/lib/main.g.dart @@ -6,16 +6,14 @@ part of 'main.dart'; // RiverpodGenerator // ************************************************************************** -typedef CountRef = Ref; - @ProviderFor(count) const myCountPod = CountProvider._(); final class CountProvider extends $FunctionalProvider - with $Provider { + with $Provider { const CountProvider._( {int Function( - CountRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -29,7 +27,7 @@ final class CountProvider extends $FunctionalProvider ); final int Function( - CountRef ref, + Ref ref, )? _createCb; @override @@ -51,32 +49,30 @@ final class CountProvider extends $FunctionalProvider @override CountProvider $copyWithCreate( int Function( - CountRef ref, + Ref ref, ) create, ) { return CountProvider._(create: create); } @override - int create(CountRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? count; return _$cb(ref); } } -String _$countHash() => r'4c7e72b275767a60ece5e8662ab1e28f73cf7e44'; - -typedef CountFutureRef = Ref>; +String _$countHash() => r'a31bb5cbb0ddb2466df2cc62a306709ea24fae12'; @ProviderFor(countFuture) const myCountFuturePod = CountFutureProvider._(); final class CountFutureProvider extends $FunctionalProvider, FutureOr> - with $FutureModifier, $FutureProvider { + with $FutureModifier, $FutureProvider { const CountFutureProvider._( {FutureOr Function( - CountFutureRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -90,7 +86,7 @@ final class CountFutureProvider ); final FutureOr Function( - CountFutureRef ref, + Ref ref, )? _createCb; @override @@ -104,32 +100,30 @@ final class CountFutureProvider @override CountFutureProvider $copyWithCreate( FutureOr Function( - CountFutureRef ref, + Ref ref, ) create, ) { return CountFutureProvider._(create: create); } @override - FutureOr create(CountFutureRef ref) { + FutureOr create(Ref ref) { final _$cb = _createCb ?? countFuture; return _$cb(ref); } } -String _$countFutureHash() => r'ec7cc31ce1c1a10607f1dcb35dd217acd2877729'; - -typedef CountStreamRef = Ref>; +String _$countFutureHash() => r'c292214b486fdd9ec98a61e277812f29fc4b5802'; @ProviderFor(countStream) const myCountStreamPod = CountStreamProvider._(); final class CountStreamProvider extends $FunctionalProvider, Stream> - with $FutureModifier, $StreamProvider { + with $FutureModifier, $StreamProvider { const CountStreamProvider._( {Stream Function( - CountStreamRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -143,7 +137,7 @@ final class CountStreamProvider ); final Stream Function( - CountStreamRef ref, + Ref ref, )? _createCb; @override @@ -157,20 +151,20 @@ final class CountStreamProvider @override CountStreamProvider $copyWithCreate( Stream Function( - CountStreamRef ref, + Ref ref, ) create, ) { return CountStreamProvider._(create: create); } @override - Stream create(CountStreamRef ref) { + Stream create(Ref ref) { final _$cb = _createCb ?? countStream; return _$cb(ref); } } -String _$countStreamHash() => r'1dbe49244ea19e8dbc3af0534429bb323720c07a'; +String _$countStreamHash() => r'472c06085fb994619f54de368f047b7cc8466872'; @ProviderFor(CountNotifier) const myCountNotifierPod = CountNotifierProvider._(); @@ -219,7 +213,7 @@ final class CountNotifierProvider @override CountNotifierProvider $copyWithBuild( int Function( - Ref, + Ref, CountNotifier, ) build, ) { @@ -281,7 +275,7 @@ final class CountAsyncNotifierProvider @override CountAsyncNotifierProvider $copyWithBuild( FutureOr Function( - Ref>, + Ref, CountAsyncNotifier, ) build, ) { @@ -344,7 +338,7 @@ final class CountStreamNotifierProvider @override CountStreamNotifierProvider $copyWithBuild( Stream Function( - Ref>, + Ref, CountStreamNotifier, ) build, ) { @@ -368,18 +362,16 @@ abstract class _$CountStreamNotifier extends $StreamNotifier { Stream runBuild() => build(); } -typedef Count2Ref = Ref; - @ProviderFor(count2) const myFamilyCount2ProviderFamily = Count2Family._(); final class Count2Provider extends $FunctionalProvider - with $Provider { + with $Provider { const Count2Provider._( {required Count2Family super.from, required int super.argument, int Function( - Count2Ref ref, + Ref ref, int a, )? create}) : _createCb = create, @@ -392,7 +384,7 @@ final class Count2Provider extends $FunctionalProvider ); final int Function( - Count2Ref ref, + Ref ref, int a, )? _createCb; @@ -422,7 +414,7 @@ final class Count2Provider extends $FunctionalProvider @override Count2Provider $copyWithCreate( int Function( - Count2Ref ref, + Ref ref, ) create, ) { return Count2Provider._( @@ -436,7 +428,7 @@ final class Count2Provider extends $FunctionalProvider } @override - int create(Count2Ref ref) { + int create(Ref ref) { final _$cb = _createCb ?? count2; final argument = this.argument as int; return _$cb( @@ -456,7 +448,7 @@ final class Count2Provider extends $FunctionalProvider } } -String _$count2Hash() => r'6256825480d83bb13acde282cf3c9d9524cc3a6c'; +String _$count2Hash() => r'4146ae486161f9d444b4d80ec846199b13eeaae2'; final class Count2Family extends Family { const Count2Family._() @@ -482,7 +474,7 @@ final class Count2Family extends Family { /// {@macro riverpod.override_with} Override overrideWith( int Function( - Count2Ref ref, + Ref ref, int args, ) create, ) { @@ -501,19 +493,17 @@ final class Count2Family extends Family { } } -typedef CountFuture2Ref = Ref>; - @ProviderFor(countFuture2) const myFamilyCountFuture2ProviderFamily = CountFuture2Family._(); final class CountFuture2Provider extends $FunctionalProvider, FutureOr> - with $FutureModifier, $FutureProvider { + with $FutureModifier, $FutureProvider { const CountFuture2Provider._( {required CountFuture2Family super.from, required int super.argument, FutureOr Function( - CountFuture2Ref ref, + Ref ref, int a, )? create}) : _createCb = create, @@ -526,7 +516,7 @@ final class CountFuture2Provider ); final FutureOr Function( - CountFuture2Ref ref, + Ref ref, int a, )? _createCb; @@ -548,7 +538,7 @@ final class CountFuture2Provider @override CountFuture2Provider $copyWithCreate( FutureOr Function( - CountFuture2Ref ref, + Ref ref, ) create, ) { return CountFuture2Provider._( @@ -562,7 +552,7 @@ final class CountFuture2Provider } @override - FutureOr create(CountFuture2Ref ref) { + FutureOr create(Ref ref) { final _$cb = _createCb ?? countFuture2; final argument = this.argument as int; return _$cb( @@ -582,7 +572,7 @@ final class CountFuture2Provider } } -String _$countFuture2Hash() => r'096675b70a267f5d7c62ac7d3e7dd231ef529034'; +String _$countFuture2Hash() => r'6acaa58de0116853fd831efb4ac1a8047205f12b'; final class CountFuture2Family extends Family { const CountFuture2Family._() @@ -608,7 +598,7 @@ final class CountFuture2Family extends Family { /// {@macro riverpod.override_with} Override overrideWith( FutureOr Function( - CountFuture2Ref ref, + Ref ref, int args, ) create, ) { @@ -627,19 +617,17 @@ final class CountFuture2Family extends Family { } } -typedef CountStream2Ref = Ref>; - @ProviderFor(countStream2) const myFamilyCountStream2ProviderFamily = CountStream2Family._(); final class CountStream2Provider extends $FunctionalProvider, Stream> - with $FutureModifier, $StreamProvider { + with $FutureModifier, $StreamProvider { const CountStream2Provider._( {required CountStream2Family super.from, required int super.argument, Stream Function( - CountStream2Ref ref, + Ref ref, int a, )? create}) : _createCb = create, @@ -652,7 +640,7 @@ final class CountStream2Provider ); final Stream Function( - CountStream2Ref ref, + Ref ref, int a, )? _createCb; @@ -674,7 +662,7 @@ final class CountStream2Provider @override CountStream2Provider $copyWithCreate( Stream Function( - CountStream2Ref ref, + Ref ref, ) create, ) { return CountStream2Provider._( @@ -688,7 +676,7 @@ final class CountStream2Provider } @override - Stream create(CountStream2Ref ref) { + Stream create(Ref ref) { final _$cb = _createCb ?? countStream2; final argument = this.argument as int; return _$cb( @@ -708,7 +696,7 @@ final class CountStream2Provider } } -String _$countStream2Hash() => r'051264dd685ebc0a57e454bb676957c93cb4ae20'; +String _$countStream2Hash() => r'96c9a0935240f1727986800c1fe6dea974b9accc'; final class CountStream2Family extends Family { const CountStream2Family._() @@ -734,7 +722,7 @@ final class CountStream2Family extends Family { /// {@macro riverpod.override_with} Override overrideWith( Stream Function( - CountStream2Ref ref, + Ref ref, int args, ) create, ) { @@ -811,7 +799,7 @@ final class CountNotifier2Provider @override CountNotifier2Provider $copyWithBuild( int Function( - Ref, + Ref, CountNotifier2, ) build, ) { @@ -883,7 +871,7 @@ final class CountNotifier2Family extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( - int Function(Ref ref, CountNotifier2 notifier, int argument) build, + int Function(Ref ref, CountNotifier2 notifier, int argument) build, ) { return $FamilyOverride( from: this, @@ -964,7 +952,7 @@ final class CountAsyncNotifier2Provider @override CountAsyncNotifier2Provider $copyWithBuild( FutureOr Function( - Ref>, + Ref, CountAsyncNotifier2, ) build, ) { @@ -1037,8 +1025,7 @@ final class CountAsyncNotifier2Family extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( - FutureOr Function(Ref> ref, - CountAsyncNotifier2 notifier, int argument) + FutureOr Function(Ref ref, CountAsyncNotifier2 notifier, int argument) build, ) { return $FamilyOverride( @@ -1121,7 +1108,7 @@ final class CountStreamNotifier2Provider @override CountStreamNotifier2Provider $copyWithBuild( Stream Function( - Ref>, + Ref, CountStreamNotifier2, ) build, ) { @@ -1194,8 +1181,7 @@ final class CountStreamNotifier2Family extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( - Stream Function(Ref> ref, - CountStreamNotifier2 notifier, int argument) + Stream Function(Ref ref, CountStreamNotifier2 notifier, int argument) build, ) { return $FamilyOverride( @@ -1228,4 +1214,4 @@ abstract class _$CountStreamNotifier2 extends $StreamNotifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/packages/riverpod_generator/lib/src/riverpod_generator.dart b/packages/riverpod_generator/lib/src/riverpod_generator.dart index fda577fb0..d3e1e6108 100644 --- a/packages/riverpod_generator/lib/src/riverpod_generator.dart +++ b/packages/riverpod_generator/lib/src/riverpod_generator.dart @@ -16,7 +16,6 @@ import 'templates/notifier.dart'; import 'templates/parameters.dart'; import 'templates/provider.dart'; import 'templates/provider_variable.dart'; -import 'templates/ref.dart'; import 'type.dart'; String providerDocFor(Element element) { @@ -107,7 +106,7 @@ class RiverpodGenerator extends ParserGenerator { if (buffer.isNotEmpty) { buffer.write(''' // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 '''); } } @@ -150,7 +149,6 @@ class _RiverpodGeneratorVisitor { List? _computeAllTransitiveDependencies( GeneratorProviderDeclaration provider, ) { - // TODO throw if a dependency is not accessible in the current library. final dependencies = provider.annotation.dependencyList?.values; if (dependencies == null) return null; @@ -209,7 +207,6 @@ class _RiverpodGeneratorVisitor { void visitFunctionalProviderDeclaration( FunctionalProviderDeclaration provider, ) { - RefTemplate(provider).run(buffer); visitGeneratorProviderDeclaration(provider); } } @@ -229,10 +226,6 @@ extension ProviderElementNames on GeneratorProviderDeclarationElement { } String get providerTypeName => '${name.titled}Provider'; - String get refImplName => switch (this) { - ClassBasedProviderDeclarationElement() => 'Ref', - FunctionalProviderDeclarationElement() => '${name.titled}Ref' - }; String get familyTypeName => '${name.titled}Family'; @@ -285,7 +278,6 @@ extension ProviderNames on GeneratorProviderDeclaration { } String get providerTypeName => providerElement.providerTypeName; - String get refImplName => providerElement.refImplName; String get familyTypeName => providerElement.familyTypeName; @@ -355,13 +347,6 @@ extension ProviderNames on GeneratorProviderDeclaration { String genericsDefinition() => _genericDefinitionDisplayString(typeParameters); - String get refWithGenerics { - return switch (this) { - FunctionalProviderDeclaration() => '$refImplName${generics()}', - ClassBasedProviderDeclaration() => 'Ref<$exposedTypeDisplayString>', - }; - } - String notifierBuildType({ bool withGenericDefinition = false, bool withArguments = false, @@ -377,7 +362,7 @@ extension ProviderNames on GeneratorProviderDeclaration { ) : ''; - return '$createdTypeDisplayString Function$genericsDefinition($refWithGenerics, $notifierType, $parameters)'; + return '$createdTypeDisplayString Function$genericsDefinition(Ref, $notifierType, $parameters)'; } String createType({ @@ -398,8 +383,7 @@ extension ProviderNames on GeneratorProviderDeclaration { ) : ''; - final refType = '${provider.refImplName}$generics'; - return '${provider.createdTypeDisplayString} Function$genericsDefinition($refType ref, $params)'; + return '${provider.createdTypeDisplayString} Function$genericsDefinition(Ref ref, $params)'; case ClassBasedProviderDeclaration(): return '${provider.name}$generics Function$genericsDefinition()'; } diff --git a/packages/riverpod_generator/lib/src/templates/family.dart b/packages/riverpod_generator/lib/src/templates/family.dart index bab9edc40..14145855d 100644 --- a/packages/riverpod_generator/lib/src/templates/family.dart +++ b/packages/riverpod_generator/lib/src/templates/family.dart @@ -93,9 +93,9 @@ ${provider.doc} final class ${provider.familyTypeName} extends Family { }) { final createType = switch (provider) { FunctionalProviderDeclaration(parameters: [_, ...]) => - '${provider.createdTypeDisplayString} Function$_genericsDefinition(${provider.refWithGenerics} ref, $_argumentRecordType args,)', + '${provider.createdTypeDisplayString} Function$_genericsDefinition(Ref ref, $_argumentRecordType args,)', FunctionalProviderDeclaration(parameters: []) => - '${provider.createdTypeDisplayString} Function$_genericsDefinition(${provider.refWithGenerics} ref)', + '${provider.createdTypeDisplayString} Function$_genericsDefinition(Ref ref)', ClassBasedProviderDeclaration(parameters: [_, ...]) => '$_notifierType Function$_genericsDefinition($_argumentRecordType args,)', ClassBasedProviderDeclaration() => @@ -172,7 +172,7 @@ Override overrideWith($createType create,) { }) { final runNotifierBuildType = ''' ${provider.createdTypeDisplayString} Function$_genericsDefinition( - ${provider.refWithGenerics} ref, + Ref ref, $_notifierType notifier ${switch (provider.parameters) { [] => '', diff --git a/packages/riverpod_generator/lib/src/templates/provider.dart b/packages/riverpod_generator/lib/src/templates/provider.dart index 150f772ce..3c0b49614 100644 --- a/packages/riverpod_generator/lib/src/templates/provider.dart +++ b/packages/riverpod_generator/lib/src/templates/provider.dart @@ -22,8 +22,6 @@ class ProviderTemplate extends Template { late final _generics = provider.generics(); late final _genericsDefinition = provider.genericsDefinition(); - late final _refType = provider.refWithGenerics; - @override void run(StringBuffer buffer) { final provider = this.provider; @@ -41,15 +39,15 @@ class ProviderTemplate extends Template { case SupportedCreatedType.future: modifiers = [ '\$FutureModifier<$valueType>', - '\$FutureProvider<$valueType, $_refType>', + '\$FutureProvider<$valueType>', ]; case SupportedCreatedType.stream: modifiers = [ '\$FutureModifier<$valueType>', - '\$StreamProvider<$valueType, $_refType>', + '\$StreamProvider<$valueType>', ]; case SupportedCreatedType.value: - modifiers = ['\$Provider<$valueType, $_refType>']; + modifiers = ['\$Provider<$valueType>']; } final mixins = modifiers.isEmpty ? '' : ' with ${modifiers.join(', ')}'; @@ -270,7 +268,7 @@ ${provider.doc} final class $name$_genericsDefinition void _writeFunctionalCreate(StringBuffer buffer) { buffer.write(''' @override - ${provider.createdTypeDisplayString} create(${provider.refImplName}$_generics ref) { + ${provider.createdTypeDisplayString} create(Ref ref) { final _\$cb = _createCb ?? ${provider.name}$_generics; '''); diff --git a/packages/riverpod_generator/lib/src/templates/ref.dart b/packages/riverpod_generator/lib/src/templates/ref.dart deleted file mode 100644 index 88aaa9ae0..000000000 --- a/packages/riverpod_generator/lib/src/templates/ref.dart +++ /dev/null @@ -1,19 +0,0 @@ -import 'package:riverpod_analyzer_utils/riverpod_analyzer_utils.dart'; - -import '../riverpod_generator.dart'; -import 'template.dart'; - -class RefTemplate extends Template { - RefTemplate(this.provider); - - final FunctionalProviderDeclaration provider; - - @override - void run(StringBuffer buffer) { - final typeParametersDefinition = provider.genericsDefinition(); - - buffer.writeln(''' -${provider.doc} typedef ${provider.refImplName}$typeParametersDefinition = Ref<${provider.exposedTypeDisplayString}>; -'''); - } -} diff --git a/packages/riverpod_generator/pubspec.yaml b/packages/riverpod_generator/pubspec.yaml index 8879f886b..f406faa3d 100644 --- a/packages/riverpod_generator/pubspec.yaml +++ b/packages/riverpod_generator/pubspec.yaml @@ -10,7 +10,7 @@ environment: sdk: ">=3.0.0 <4.0.0" dependencies: - analyzer: ^6.5.0 + analyzer: ^6.7.0 build: ^2.0.0 build_config: ^1.0.0 collection: ^1.15.0 diff --git a/packages/riverpod_generator/test/doc_test.dart b/packages/riverpod_generator/test/doc_test.dart index 0930cf9e4..e1b357b03 100644 --- a/packages/riverpod_generator/test/doc_test.dart +++ b/packages/riverpod_generator/test/doc_test.dart @@ -25,12 +25,6 @@ void main() async { expect(doc, '/// Hello world\n// Foo\n'); }); - test('Doc on generated ref', () async { - final doc = topLevelDeclarations.findNamed('FamilyRef').doc; - - expect(doc, '/// Hello world\n// Foo\n'); - }); - test('Doc on generated family', () async { final family = topLevelDeclarations.findNamed('FamilyFamily') as ClassDeclaration; diff --git a/packages/riverpod_generator/test/integration/annotated.dart b/packages/riverpod_generator/test/integration/annotated.dart index 21bcee88f..76dfa1100 100644 --- a/packages/riverpod_generator/test/integration/annotated.dart +++ b/packages/riverpod_generator/test/integration/annotated.dart @@ -7,8 +7,7 @@ part 'annotated.g.dart'; @Deprecated('Deprecation message') @visibleForTesting @protected -String functional(FunctionalRef ref, @Deprecated('field') int id) => - 'functional'; +String functional(Ref ref, @Deprecated('field') int id) => 'functional'; @riverpod @Deprecated('Deprecation message') @@ -23,11 +22,11 @@ class ClassBased extends _$ClassBased { @Deprecated('Deprecation message') @visibleForTesting @protected -String family(FamilyRef ref, int id) => 'family $id'; +String family(Ref ref, int id) => 'family $id'; @riverpod @doNotStore -String notCopiedFunctional(NotCopiedFunctionalRef ref) => 'notCopiedFunctional'; +String notCopiedFunctional(Ref ref) => 'notCopiedFunctional'; @riverpod @doNotStore @@ -38,4 +37,4 @@ class NotCopiedClassBased extends _$NotCopiedClassBased { @riverpod @doNotStore -String notCopiedFamily(NotCopiedFamilyRef ref, int id) => 'notCopiedFamily $id'; +String notCopiedFamily(Ref ref, int id) => 'notCopiedFamily $id'; diff --git a/packages/riverpod_generator/test/integration/annotated.g.dart b/packages/riverpod_generator/test/integration/annotated.g.dart index ebfa3f779..f8f5a688a 100644 --- a/packages/riverpod_generator/test/integration/annotated.g.dart +++ b/packages/riverpod_generator/test/integration/annotated.g.dart @@ -6,8 +6,6 @@ part of 'annotated.dart'; // RiverpodGenerator // ************************************************************************** -typedef FunctionalRef = Ref; - @ProviderFor(functional) @Deprecated('Deprecation message') @visibleForTesting @@ -15,12 +13,12 @@ typedef FunctionalRef = Ref; const functionalProvider = FunctionalFamily._(); final class FunctionalProvider extends $FunctionalProvider - with $Provider { + with $Provider { const FunctionalProvider._( {required FunctionalFamily super.from, required int super.argument, String Function( - FunctionalRef ref, + Ref ref, @Deprecated('field') int id, )? create}) : _createCb = create, @@ -33,7 +31,7 @@ final class FunctionalProvider extends $FunctionalProvider ); final String Function( - FunctionalRef ref, + Ref ref, @Deprecated('field') int id, )? _createCb; @@ -63,7 +61,7 @@ final class FunctionalProvider extends $FunctionalProvider @override FunctionalProvider $copyWithCreate( String Function( - FunctionalRef ref, + Ref ref, ) create, ) { return FunctionalProvider._( @@ -77,7 +75,7 @@ final class FunctionalProvider extends $FunctionalProvider } @override - String create(FunctionalRef ref) { + String create(Ref ref) { final _$cb = _createCb ?? functional; final argument = this.argument as int; return _$cb( @@ -97,7 +95,7 @@ final class FunctionalProvider extends $FunctionalProvider } } -String _$functionalHash() => r'288107f94c896141a9b3999f606e4ccdf078f15e'; +String _$functionalHash() => r'ba8606cd0526e2dde0f775eb8f4c9d8b5b6fdf2c'; final class FunctionalFamily extends Family { const FunctionalFamily._() @@ -123,7 +121,7 @@ final class FunctionalFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( String Function( - FunctionalRef ref, + Ref ref, int args, ) create, ) { @@ -202,7 +200,7 @@ final class ClassBasedProvider extends $NotifierProvider { @override ClassBasedProvider $copyWithBuild( String Function( - Ref, + Ref, ClassBased, ) build, ) { @@ -274,7 +272,7 @@ final class ClassBasedFamily extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( - String Function(Ref ref, ClassBased notifier, int argument) build, + String Function(Ref ref, ClassBased notifier, int argument) build, ) { return $FamilyOverride( from: this, @@ -306,8 +304,6 @@ abstract class _$ClassBased extends $Notifier { ); } -typedef FamilyRef = Ref; - @ProviderFor(family) @Deprecated('Deprecation message') @visibleForTesting @@ -315,12 +311,12 @@ typedef FamilyRef = Ref; const familyProvider = FamilyFamily._(); final class FamilyProvider extends $FunctionalProvider - with $Provider { + with $Provider { const FamilyProvider._( {required FamilyFamily super.from, required int super.argument, String Function( - FamilyRef ref, + Ref ref, int id, )? create}) : _createCb = create, @@ -333,7 +329,7 @@ final class FamilyProvider extends $FunctionalProvider ); final String Function( - FamilyRef ref, + Ref ref, int id, )? _createCb; @@ -363,7 +359,7 @@ final class FamilyProvider extends $FunctionalProvider @override FamilyProvider $copyWithCreate( String Function( - FamilyRef ref, + Ref ref, ) create, ) { return FamilyProvider._( @@ -377,7 +373,7 @@ final class FamilyProvider extends $FunctionalProvider } @override - String create(FamilyRef ref) { + String create(Ref ref) { final _$cb = _createCb ?? family; final argument = this.argument as int; return _$cb( @@ -397,7 +393,7 @@ final class FamilyProvider extends $FunctionalProvider } } -String _$familyHash() => r'd70685b83be840bfd9e79c11fb84c905d19d6e10'; +String _$familyHash() => r'14b97009aec20a0332208f8a60bc177b44c9d1d4'; final class FamilyFamily extends Family { const FamilyFamily._() @@ -423,7 +419,7 @@ final class FamilyFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( String Function( - FamilyRef ref, + Ref ref, int args, ) create, ) { @@ -442,17 +438,14 @@ final class FamilyFamily extends Family { } } -typedef NotCopiedFunctionalRef = Ref; - @ProviderFor(notCopiedFunctional) const notCopiedFunctionalProvider = NotCopiedFunctionalProvider._(); final class NotCopiedFunctionalProvider - extends $FunctionalProvider - with $Provider { + extends $FunctionalProvider with $Provider { const NotCopiedFunctionalProvider._( {String Function( - NotCopiedFunctionalRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -466,7 +459,7 @@ final class NotCopiedFunctionalProvider ); final String Function( - NotCopiedFunctionalRef ref, + Ref ref, )? _createCb; @override @@ -488,21 +481,21 @@ final class NotCopiedFunctionalProvider @override NotCopiedFunctionalProvider $copyWithCreate( String Function( - NotCopiedFunctionalRef ref, + Ref ref, ) create, ) { return NotCopiedFunctionalProvider._(create: create); } @override - String create(NotCopiedFunctionalRef ref) { + String create(Ref ref) { final _$cb = _createCb ?? notCopiedFunctional; return _$cb(ref); } } String _$notCopiedFunctionalHash() => - r'30587ee9ceb75d5c8562015ad4a67ec0b107c1f6'; + r'7b2cd9abef57493eebc1c05b1d2b4e2743ddbea2'; @ProviderFor(NotCopiedClassBased) const notCopiedClassBasedProvider = NotCopiedClassBasedProvider._(); @@ -551,7 +544,7 @@ final class NotCopiedClassBasedProvider @override NotCopiedClassBasedProvider $copyWithBuild( String Function( - Ref, + Ref, NotCopiedClassBased, ) build, ) { @@ -575,18 +568,16 @@ abstract class _$NotCopiedClassBased extends $Notifier { String runBuild() => build(); } -typedef NotCopiedFamilyRef = Ref; - @ProviderFor(notCopiedFamily) const notCopiedFamilyProvider = NotCopiedFamilyFamily._(); final class NotCopiedFamilyProvider extends $FunctionalProvider - with $Provider { + with $Provider { const NotCopiedFamilyProvider._( {required NotCopiedFamilyFamily super.from, required int super.argument, String Function( - NotCopiedFamilyRef ref, + Ref ref, int id, )? create}) : _createCb = create, @@ -599,7 +590,7 @@ final class NotCopiedFamilyProvider extends $FunctionalProvider ); final String Function( - NotCopiedFamilyRef ref, + Ref ref, int id, )? _createCb; @@ -629,7 +620,7 @@ final class NotCopiedFamilyProvider extends $FunctionalProvider @override NotCopiedFamilyProvider $copyWithCreate( String Function( - NotCopiedFamilyRef ref, + Ref ref, ) create, ) { return NotCopiedFamilyProvider._( @@ -643,7 +634,7 @@ final class NotCopiedFamilyProvider extends $FunctionalProvider } @override - String create(NotCopiedFamilyRef ref) { + String create(Ref ref) { final _$cb = _createCb ?? notCopiedFamily; final argument = this.argument as int; return _$cb( @@ -663,7 +654,7 @@ final class NotCopiedFamilyProvider extends $FunctionalProvider } } -String _$notCopiedFamilyHash() => r'6ef06ce6ebd73b476870bbe1af41c4f3fbe8ddb1'; +String _$notCopiedFamilyHash() => r'ea652776532e2bf993a249b25b5254fc3dfff4b9'; final class NotCopiedFamilyFamily extends Family { const NotCopiedFamilyFamily._() @@ -689,7 +680,7 @@ final class NotCopiedFamilyFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( String Function( - NotCopiedFamilyRef ref, + Ref ref, int args, ) create, ) { @@ -708,4 +699,4 @@ final class NotCopiedFamilyFamily extends Family { } } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/packages/riverpod_generator/test/integration/async.dart b/packages/riverpod_generator/test/integration/async.dart index 469608b30..0672af81a 100644 --- a/packages/riverpod_generator/test/integration/async.dart +++ b/packages/riverpod_generator/test/integration/async.dart @@ -3,7 +3,7 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'async.g.dart'; @riverpod -Future> generic(GenericRef ref) async { +Future> generic(Ref ref) async { return []; } @@ -16,25 +16,25 @@ class GenericClass extends _$GenericClass { } @riverpod -FutureOr public(PublicRef ref) { +FutureOr public(Ref ref) { return 'Hello world'; } const privateProvider = _privateProvider; @riverpod -Future _private(_PrivateRef ref) async { +Future _private(Ref ref) async { return 'Hello world'; } @riverpod -FutureOr familyOr(FamilyOrRef ref, int first) { +FutureOr familyOr(Ref ref, int first) { return '(first: $first)'; } @riverpod Future family( - FamilyRef ref, + Ref ref, int first, { String? second, required double third, diff --git a/packages/riverpod_generator/test/integration/async.g.dart b/packages/riverpod_generator/test/integration/async.g.dart index 791f59c3c..83b37b2b6 100644 --- a/packages/riverpod_generator/test/integration/async.g.dart +++ b/packages/riverpod_generator/test/integration/async.g.dart @@ -6,18 +6,16 @@ part of 'async.dart'; // RiverpodGenerator // ************************************************************************** -typedef GenericRef = Ref>>; - @ProviderFor(generic) const genericProvider = GenericFamily._(); final class GenericProvider extends $FunctionalProvider>, FutureOr>> - with $FutureModifier>, $FutureProvider, GenericRef> { + with $FutureModifier>, $FutureProvider> { const GenericProvider._( {required GenericFamily super.from, FutureOr> Function( - GenericRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -30,7 +28,7 @@ final class GenericProvider ); final FutureOr> Function( - GenericRef ref, + Ref ref, )? _createCb; @override @@ -38,7 +36,7 @@ final class GenericProvider GenericProvider _copyWithCreate( FutureOr> Function( - GenericRef ref, + Ref ref, ) create, ) { return GenericProvider._( @@ -60,14 +58,14 @@ final class GenericProvider @override GenericProvider $copyWithCreate( FutureOr> Function( - GenericRef ref, + Ref ref, ) create, ) { return GenericProvider._(from: from! as GenericFamily, create: create); } @override - FutureOr> create(GenericRef ref) { + FutureOr> create(Ref ref) { final _$cb = _createCb ?? generic; return _$cb(ref); } @@ -85,7 +83,7 @@ final class GenericProvider } } -String _$genericHash() => r'6ee5473ece745b00328c1e048f6967c160343620'; +String _$genericHash() => r'b7413a59722e9d62ae99c8a7ee0b4a24417fc3b4'; final class GenericFamily extends Family { const GenericFamily._() @@ -107,7 +105,7 @@ final class GenericFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( - FutureOr> Function(GenericRef ref) create, + FutureOr> Function(Ref ref) create, ) { return $FamilyOverride( from: this, @@ -153,7 +151,7 @@ final class GenericClassProvider GenericClassProvider _copyWithBuild( FutureOr> Function( - Ref>>, + Ref, GenericClass, ) build, ) { @@ -185,7 +183,7 @@ final class GenericClassProvider @override GenericClassProvider $copyWithBuild( FutureOr> Function( - Ref>>, + Ref, GenericClass, ) build, ) { @@ -249,8 +247,7 @@ final class GenericClassFamily extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( - FutureOr> Function( - Ref>> ref, GenericClass notifier) + FutureOr> Function(Ref ref, GenericClass notifier) build, ) { return $FamilyOverride( @@ -271,17 +268,15 @@ abstract class _$GenericClass extends $AsyncNotifier> { FutureOr> runBuild() => build(); } -typedef PublicRef = Ref>; - @ProviderFor(public) const publicProvider = PublicProvider._(); final class PublicProvider extends $FunctionalProvider, FutureOr> - with $FutureModifier, $FutureProvider { + with $FutureModifier, $FutureProvider { const PublicProvider._( {FutureOr Function( - PublicRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -295,7 +290,7 @@ final class PublicProvider ); final FutureOr Function( - PublicRef ref, + Ref ref, )? _createCb; @override @@ -309,32 +304,30 @@ final class PublicProvider @override PublicProvider $copyWithCreate( FutureOr Function( - PublicRef ref, + Ref ref, ) create, ) { return PublicProvider._(create: create); } @override - FutureOr create(PublicRef ref) { + FutureOr create(Ref ref) { final _$cb = _createCb ?? public; return _$cb(ref); } } -String _$publicHash() => r'9d99b79c013da13926d4ad89c72ebca4fc1cc257'; - -typedef _PrivateRef = Ref>; +String _$publicHash() => r'19bceccf795e4c3a26ad1e613fd6f41aad949e2b'; @ProviderFor(_private) const _privateProvider = _PrivateProvider._(); final class _PrivateProvider extends $FunctionalProvider, FutureOr> - with $FutureModifier, $FutureProvider { + with $FutureModifier, $FutureProvider { const _PrivateProvider._( {FutureOr Function( - _PrivateRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -348,7 +341,7 @@ final class _PrivateProvider ); final FutureOr Function( - _PrivateRef ref, + Ref ref, )? _createCb; @override @@ -362,34 +355,32 @@ final class _PrivateProvider @override _PrivateProvider $copyWithCreate( FutureOr Function( - _PrivateRef ref, + Ref ref, ) create, ) { return _PrivateProvider._(create: create); } @override - FutureOr create(_PrivateRef ref) { + FutureOr create(Ref ref) { final _$cb = _createCb ?? _private; return _$cb(ref); } } -String _$privateHash() => r'bc0469a9315de114a0ccd82c7db4980844d0009f'; - -typedef FamilyOrRef = Ref>; +String _$privateHash() => r'7f0d1ff55a21e520b8471bbabc4649b5336221d4'; @ProviderFor(familyOr) const familyOrProvider = FamilyOrFamily._(); final class FamilyOrProvider extends $FunctionalProvider, FutureOr> - with $FutureModifier, $FutureProvider { + with $FutureModifier, $FutureProvider { const FamilyOrProvider._( {required FamilyOrFamily super.from, required int super.argument, FutureOr Function( - FamilyOrRef ref, + Ref ref, int first, )? create}) : _createCb = create, @@ -402,7 +393,7 @@ final class FamilyOrProvider ); final FutureOr Function( - FamilyOrRef ref, + Ref ref, int first, )? _createCb; @@ -424,7 +415,7 @@ final class FamilyOrProvider @override FamilyOrProvider $copyWithCreate( FutureOr Function( - FamilyOrRef ref, + Ref ref, ) create, ) { return FamilyOrProvider._( @@ -438,7 +429,7 @@ final class FamilyOrProvider } @override - FutureOr create(FamilyOrRef ref) { + FutureOr create(Ref ref) { final _$cb = _createCb ?? familyOr; final argument = this.argument as int; return _$cb( @@ -458,7 +449,7 @@ final class FamilyOrProvider } } -String _$familyOrHash() => r'1c3217e296b0ce52c07c18769d1fffb95850f482'; +String _$familyOrHash() => r'97cce80a626e228202fa30b87c07ae8319b48023'; final class FamilyOrFamily extends Family { const FamilyOrFamily._() @@ -484,7 +475,7 @@ final class FamilyOrFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( FutureOr Function( - FamilyOrRef ref, + Ref ref, int args, ) create, ) { @@ -503,14 +494,12 @@ final class FamilyOrFamily extends Family { } } -typedef FamilyRef = Ref>; - @ProviderFor(family) const familyProvider = FamilyFamily._(); final class FamilyProvider extends $FunctionalProvider, FutureOr> - with $FutureModifier, $FutureProvider { + with $FutureModifier, $FutureProvider { const FamilyProvider._( {required FamilyFamily super.from, required ( @@ -522,7 +511,7 @@ final class FamilyProvider }) super.argument, FutureOr Function( - FamilyRef ref, + Ref ref, int first, { String? second, required double third, @@ -539,7 +528,7 @@ final class FamilyProvider ); final FutureOr Function( - FamilyRef ref, + Ref ref, int first, { String? second, required double third, @@ -565,7 +554,7 @@ final class FamilyProvider @override FamilyProvider $copyWithCreate( FutureOr Function( - FamilyRef ref, + Ref ref, ) create, ) { return FamilyProvider._( @@ -589,7 +578,7 @@ final class FamilyProvider } @override - FutureOr create(FamilyRef ref) { + FutureOr create(Ref ref) { final _$cb = _createCb ?? family; final argument = this.argument as ( int, { @@ -619,7 +608,7 @@ final class FamilyProvider } } -String _$familyHash() => r'eb6fad35a94d4238b621c2100253ee2c700bee77'; +String _$familyHash() => r'1da6c928ee85a03729a1c147f33e018521bb9c89'; final class FamilyFamily extends Family { const FamilyFamily._() @@ -655,7 +644,7 @@ final class FamilyFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( FutureOr Function( - FamilyRef ref, + Ref ref, ( int, { String? second, @@ -725,7 +714,7 @@ final class PublicClassProvider @override PublicClassProvider $copyWithBuild( FutureOr Function( - Ref>, + Ref, PublicClass, ) build, ) { @@ -787,7 +776,7 @@ final class _PrivateClassProvider @override _PrivateClassProvider $copyWithBuild( FutureOr Function( - Ref>, + Ref, _PrivateClass, ) build, ) { @@ -860,7 +849,7 @@ final class FamilyOrClassProvider @override FamilyOrClassProvider $copyWithBuild( FutureOr Function( - Ref>, + Ref, FamilyOrClass, ) build, ) { @@ -932,8 +921,7 @@ final class FamilyOrClassFamily extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( - FutureOr Function( - Ref> ref, FamilyOrClass notifier, int argument) + FutureOr Function(Ref ref, FamilyOrClass notifier, int argument) build, ) { return $FamilyOverride( @@ -1028,7 +1016,7 @@ final class FamilyClassProvider @override FamilyClassProvider $copyWithBuild( FutureOr Function( - Ref>, + Ref, FamilyClass, ) build, ) { @@ -1129,7 +1117,7 @@ final class FamilyClassFamily extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( FutureOr Function( - Ref> ref, + Ref ref, FamilyClass notifier, ( int, { @@ -1194,4 +1182,4 @@ abstract class _$FamilyClass extends $AsyncNotifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/packages/riverpod_generator/test/integration/auto_dispose.dart b/packages/riverpod_generator/test/integration/auto_dispose.dart index 9ae30399d..26c824040 100644 --- a/packages/riverpod_generator/test/integration/auto_dispose.dart +++ b/packages/riverpod_generator/test/integration/auto_dispose.dart @@ -3,33 +3,33 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'auto_dispose.g.dart'; @Riverpod(keepAlive: true) -int keepAlive(KeepAliveRef ref) { +int keepAlive(Ref ref) { return 0; } @Riverpod(keepAlive: false) -int notKeepAlive(NotKeepAliveRef ref) { +int notKeepAlive(Ref ref) { ref.keepAlive(); return 0; } @riverpod -int defaultKeepAlive(DefaultKeepAliveRef ref) { +int defaultKeepAlive(Ref ref) { return 0; } @Riverpod(keepAlive: true) -int keepAliveFamily(KeepAliveFamilyRef ref, int a) { +int keepAliveFamily(Ref ref, int a) { return 0; } @Riverpod(keepAlive: false) -int notKeepAliveFamily(NotKeepAliveFamilyRef ref, int a) { +int notKeepAliveFamily(Ref ref, int a) { ref.keepAlive(); return 0; } @riverpod -int defaultKeepAliveFamily(DefaultKeepAliveFamilyRef ref, int a) { +int defaultKeepAliveFamily(Ref ref, int a) { return 0; } diff --git a/packages/riverpod_generator/test/integration/auto_dispose.g.dart b/packages/riverpod_generator/test/integration/auto_dispose.g.dart index d4f345241..a207548e0 100644 --- a/packages/riverpod_generator/test/integration/auto_dispose.g.dart +++ b/packages/riverpod_generator/test/integration/auto_dispose.g.dart @@ -6,16 +6,14 @@ part of 'auto_dispose.dart'; // RiverpodGenerator // ************************************************************************** -typedef KeepAliveRef = Ref; - @ProviderFor(keepAlive) const keepAliveProvider = KeepAliveProvider._(); final class KeepAliveProvider extends $FunctionalProvider - with $Provider { + with $Provider { const KeepAliveProvider._( {int Function( - KeepAliveRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -29,7 +27,7 @@ final class KeepAliveProvider extends $FunctionalProvider ); final int Function( - KeepAliveRef ref, + Ref ref, )? _createCb; @override @@ -51,31 +49,29 @@ final class KeepAliveProvider extends $FunctionalProvider @override KeepAliveProvider $copyWithCreate( int Function( - KeepAliveRef ref, + Ref ref, ) create, ) { return KeepAliveProvider._(create: create); } @override - int create(KeepAliveRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? keepAlive; return _$cb(ref); } } -String _$keepAliveHash() => r'72dd192676126d487c24c7695a91d59410c62696'; - -typedef NotKeepAliveRef = Ref; +String _$keepAliveHash() => r'44af50bf7e6dcfddc61a1f32855855b534a7fe4f'; @ProviderFor(notKeepAlive) const notKeepAliveProvider = NotKeepAliveProvider._(); final class NotKeepAliveProvider extends $FunctionalProvider - with $Provider { + with $Provider { const NotKeepAliveProvider._( {int Function( - NotKeepAliveRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -89,7 +85,7 @@ final class NotKeepAliveProvider extends $FunctionalProvider ); final int Function( - NotKeepAliveRef ref, + Ref ref, )? _createCb; @override @@ -111,31 +107,29 @@ final class NotKeepAliveProvider extends $FunctionalProvider @override NotKeepAliveProvider $copyWithCreate( int Function( - NotKeepAliveRef ref, + Ref ref, ) create, ) { return NotKeepAliveProvider._(create: create); } @override - int create(NotKeepAliveRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? notKeepAlive; return _$cb(ref); } } -String _$notKeepAliveHash() => r'1ccc497d7c651f8e730ec1bcecf271ffe9615d83'; - -typedef DefaultKeepAliveRef = Ref; +String _$notKeepAliveHash() => r'e60c952d04ffd7548294908c2e1ef472614c284b'; @ProviderFor(defaultKeepAlive) const defaultKeepAliveProvider = DefaultKeepAliveProvider._(); final class DefaultKeepAliveProvider extends $FunctionalProvider - with $Provider { + with $Provider { const DefaultKeepAliveProvider._( {int Function( - DefaultKeepAliveRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -149,7 +143,7 @@ final class DefaultKeepAliveProvider extends $FunctionalProvider ); final int Function( - DefaultKeepAliveRef ref, + Ref ref, )? _createCb; @override @@ -171,33 +165,31 @@ final class DefaultKeepAliveProvider extends $FunctionalProvider @override DefaultKeepAliveProvider $copyWithCreate( int Function( - DefaultKeepAliveRef ref, + Ref ref, ) create, ) { return DefaultKeepAliveProvider._(create: create); } @override - int create(DefaultKeepAliveRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? defaultKeepAlive; return _$cb(ref); } } -String _$defaultKeepAliveHash() => r'1c236764d83a62ca442c5d5b4a83bd0d6e4548cf'; - -typedef KeepAliveFamilyRef = Ref; +String _$defaultKeepAliveHash() => r'76485c3c7574c38dcba6dda28c94a59c09b339c0'; @ProviderFor(keepAliveFamily) const keepAliveFamilyProvider = KeepAliveFamilyFamily._(); final class KeepAliveFamilyProvider extends $FunctionalProvider - with $Provider { + with $Provider { const KeepAliveFamilyProvider._( {required KeepAliveFamilyFamily super.from, required int super.argument, int Function( - KeepAliveFamilyRef ref, + Ref ref, int a, )? create}) : _createCb = create, @@ -210,7 +202,7 @@ final class KeepAliveFamilyProvider extends $FunctionalProvider ); final int Function( - KeepAliveFamilyRef ref, + Ref ref, int a, )? _createCb; @@ -240,7 +232,7 @@ final class KeepAliveFamilyProvider extends $FunctionalProvider @override KeepAliveFamilyProvider $copyWithCreate( int Function( - KeepAliveFamilyRef ref, + Ref ref, ) create, ) { return KeepAliveFamilyProvider._( @@ -254,7 +246,7 @@ final class KeepAliveFamilyProvider extends $FunctionalProvider } @override - int create(KeepAliveFamilyRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? keepAliveFamily; final argument = this.argument as int; return _$cb( @@ -274,7 +266,7 @@ final class KeepAliveFamilyProvider extends $FunctionalProvider } } -String _$keepAliveFamilyHash() => r'80d684923a104e2488ec281097bf9b5b04b4fa5a'; +String _$keepAliveFamilyHash() => r'd1eb1243ea9463617b08a6e9cc5ae6b2df499ba2'; final class KeepAliveFamilyFamily extends Family { const KeepAliveFamilyFamily._() @@ -300,7 +292,7 @@ final class KeepAliveFamilyFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( int Function( - KeepAliveFamilyRef ref, + Ref ref, int args, ) create, ) { @@ -319,18 +311,16 @@ final class KeepAliveFamilyFamily extends Family { } } -typedef NotKeepAliveFamilyRef = Ref; - @ProviderFor(notKeepAliveFamily) const notKeepAliveFamilyProvider = NotKeepAliveFamilyFamily._(); final class NotKeepAliveFamilyProvider extends $FunctionalProvider - with $Provider { + with $Provider { const NotKeepAliveFamilyProvider._( {required NotKeepAliveFamilyFamily super.from, required int super.argument, int Function( - NotKeepAliveFamilyRef ref, + Ref ref, int a, )? create}) : _createCb = create, @@ -343,7 +333,7 @@ final class NotKeepAliveFamilyProvider extends $FunctionalProvider ); final int Function( - NotKeepAliveFamilyRef ref, + Ref ref, int a, )? _createCb; @@ -373,7 +363,7 @@ final class NotKeepAliveFamilyProvider extends $FunctionalProvider @override NotKeepAliveFamilyProvider $copyWithCreate( int Function( - NotKeepAliveFamilyRef ref, + Ref ref, ) create, ) { return NotKeepAliveFamilyProvider._( @@ -387,7 +377,7 @@ final class NotKeepAliveFamilyProvider extends $FunctionalProvider } @override - int create(NotKeepAliveFamilyRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? notKeepAliveFamily; final argument = this.argument as int; return _$cb( @@ -408,7 +398,7 @@ final class NotKeepAliveFamilyProvider extends $FunctionalProvider } String _$notKeepAliveFamilyHash() => - r'9f530635a3310431aff36f0f9150f80c56348a51'; + r'a721713b026088b65be6c0f7f9beb1083a377a7c'; final class NotKeepAliveFamilyFamily extends Family { const NotKeepAliveFamilyFamily._() @@ -434,7 +424,7 @@ final class NotKeepAliveFamilyFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( int Function( - NotKeepAliveFamilyRef ref, + Ref ref, int args, ) create, ) { @@ -453,18 +443,16 @@ final class NotKeepAliveFamilyFamily extends Family { } } -typedef DefaultKeepAliveFamilyRef = Ref; - @ProviderFor(defaultKeepAliveFamily) const defaultKeepAliveFamilyProvider = DefaultKeepAliveFamilyFamily._(); final class DefaultKeepAliveFamilyProvider extends $FunctionalProvider - with $Provider { + with $Provider { const DefaultKeepAliveFamilyProvider._( {required DefaultKeepAliveFamilyFamily super.from, required int super.argument, int Function( - DefaultKeepAliveFamilyRef ref, + Ref ref, int a, )? create}) : _createCb = create, @@ -477,7 +465,7 @@ final class DefaultKeepAliveFamilyProvider extends $FunctionalProvider ); final int Function( - DefaultKeepAliveFamilyRef ref, + Ref ref, int a, )? _createCb; @@ -507,7 +495,7 @@ final class DefaultKeepAliveFamilyProvider extends $FunctionalProvider @override DefaultKeepAliveFamilyProvider $copyWithCreate( int Function( - DefaultKeepAliveFamilyRef ref, + Ref ref, ) create, ) { return DefaultKeepAliveFamilyProvider._( @@ -521,7 +509,7 @@ final class DefaultKeepAliveFamilyProvider extends $FunctionalProvider } @override - int create(DefaultKeepAliveFamilyRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? defaultKeepAliveFamily; final argument = this.argument as int; return _$cb( @@ -543,7 +531,7 @@ final class DefaultKeepAliveFamilyProvider extends $FunctionalProvider } String _$defaultKeepAliveFamilyHash() => - r'a1d9a5a40b8d43983428273ebee0660fe39250ed'; + r'e79f3d9ccd6713aade34c1701699c578f9236e9e'; final class DefaultKeepAliveFamilyFamily extends Family { const DefaultKeepAliveFamilyFamily._() @@ -569,7 +557,7 @@ final class DefaultKeepAliveFamilyFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( int Function( - DefaultKeepAliveFamilyRef ref, + Ref ref, int args, ) create, ) { @@ -588,4 +576,4 @@ final class DefaultKeepAliveFamilyFamily extends Family { } } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/packages/riverpod_generator/test/integration/dependencies.dart b/packages/riverpod_generator/test/integration/dependencies.dart index e87eb23bd..c350b1ee3 100644 --- a/packages/riverpod_generator/test/integration/dependencies.dart +++ b/packages/riverpod_generator/test/integration/dependencies.dart @@ -3,10 +3,10 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'dependencies.g.dart'; @riverpod -int dep(DepRef ref) => 0; +int dep(Ref ref) => 0; @riverpod -int family(DepRef ref, int id) => 0; +int family(Ref ref, int id) => 0; @riverpod class Dep2 extends _$Dep2 { @@ -21,10 +21,10 @@ class Family2 extends _$Family2 { } @Riverpod(dependencies: [dep, family, Dep2, Family2]) -int provider(ProviderRef ref) => 0; +int provider(Ref ref) => 0; @Riverpod(dependencies: [dep, family, Dep2, Family2]) -int provider2(Provider2Ref ref) => 0; +int provider2(Ref ref) => 0; @Riverpod(dependencies: [dep, family, Dep2, Family2]) class Provider3 extends _$Provider3 { @@ -39,13 +39,13 @@ class Provider4 extends _$Provider4 { } @Riverpod(dependencies: [provider]) -int transitiveDependencies(TransitiveDependenciesRef ref) => 0; +int transitiveDependencies(Ref ref) => 0; @Riverpod(dependencies: [dep, family, Dep2]) -int smallTransitiveDependencyCount(SmallTransitiveDependencyCountRef ref) => 0; +int smallTransitiveDependencyCount(Ref ref) => 0; @Riverpod(dependencies: []) -int emptyDependenciesFunctional(EmptyDependenciesFunctionalRef ref) => 0; +int emptyDependenciesFunctional(Ref ref) => 0; @Riverpod(dependencies: []) class EmptyDependenciesClassBased extends _$EmptyDependenciesClassBased { @@ -54,22 +54,21 @@ class EmptyDependenciesClassBased extends _$EmptyDependenciesClassBased { } @Riverpod(dependencies: [_privateDep, publicDep]) -int providerWithDependencies(ProviderWithDependenciesRef ref) { +int providerWithDependencies(Ref ref) { return 0; } @riverpod -int _privateDep(_PrivateDepRef ref) => 0; +int _privateDep(Ref ref) => 0; @riverpod -int publicDep(PublicDepRef ref) => 0; +int publicDep(Ref ref) => 0; @Riverpod(dependencies: [dep, dep, Dep2, Dep2]) -int duplicateDependencies(DuplicateDependenciesRef ref) => 0; +int duplicateDependencies(Ref ref) => 0; @Riverpod(dependencies: [family, family, Family2, Family2]) -int duplicateDependencies2(DuplicateDependencies2Ref ref) => 0; +int duplicateDependencies2(Ref ref) => 0; @Riverpod(dependencies: [duplicateDependencies, duplicateDependencies2]) -int transitiveDuplicateDependencies(TransitiveDuplicateDependenciesRef ref) => - 0; +int transitiveDuplicateDependencies(Ref ref) => 0; diff --git a/packages/riverpod_generator/test/integration/dependencies.g.dart b/packages/riverpod_generator/test/integration/dependencies.g.dart index c399d0f35..7e88c4c4c 100644 --- a/packages/riverpod_generator/test/integration/dependencies.g.dart +++ b/packages/riverpod_generator/test/integration/dependencies.g.dart @@ -6,16 +6,14 @@ part of 'dependencies.dart'; // RiverpodGenerator // ************************************************************************** -typedef DepRef = Ref; - @ProviderFor(dep) const depProvider = DepProvider._(); final class DepProvider extends $FunctionalProvider - with $Provider { + with $Provider { const DepProvider._( {int Function( - DepRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -29,7 +27,7 @@ final class DepProvider extends $FunctionalProvider ); final int Function( - DepRef ref, + Ref ref, )? _createCb; @override @@ -51,33 +49,31 @@ final class DepProvider extends $FunctionalProvider @override DepProvider $copyWithCreate( int Function( - DepRef ref, + Ref ref, ) create, ) { return DepProvider._(create: create); } @override - int create(DepRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? dep; return _$cb(ref); } } -String _$depHash() => r'2213a401e03a1a914579b4a3a7707b783de9efba'; - -typedef FamilyRef = Ref; +String _$depHash() => r'1b3ec5231cd2328602151de9ceacdcd102a1d2e2'; @ProviderFor(family) const familyProvider = FamilyFamily._(); final class FamilyProvider extends $FunctionalProvider - with $Provider { + with $Provider { const FamilyProvider._( {required FamilyFamily super.from, required int super.argument, int Function( - FamilyRef ref, + Ref ref, int id, )? create}) : _createCb = create, @@ -90,7 +86,7 @@ final class FamilyProvider extends $FunctionalProvider ); final int Function( - FamilyRef ref, + Ref ref, int id, )? _createCb; @@ -120,7 +116,7 @@ final class FamilyProvider extends $FunctionalProvider @override FamilyProvider $copyWithCreate( int Function( - FamilyRef ref, + Ref ref, ) create, ) { return FamilyProvider._( @@ -134,7 +130,7 @@ final class FamilyProvider extends $FunctionalProvider } @override - int create(FamilyRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? family; final argument = this.argument as int; return _$cb( @@ -154,7 +150,7 @@ final class FamilyProvider extends $FunctionalProvider } } -String _$familyHash() => r'8c228ff14b8c6cf1f3d4d6266232d64b5057c440'; +String _$familyHash() => r'940eb87eb11206499f73f05791a6266b38cda88a'; final class FamilyFamily extends Family { const FamilyFamily._() @@ -180,7 +176,7 @@ final class FamilyFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( int Function( - FamilyRef ref, + Ref ref, int args, ) create, ) { @@ -245,7 +241,7 @@ final class Dep2Provider extends $NotifierProvider { @override Dep2Provider $copyWithBuild( int Function( - Ref, + Ref, Dep2, ) build, ) { @@ -325,7 +321,7 @@ final class Family2Provider extends $NotifierProvider { @override Family2Provider $copyWithBuild( int Function( - Ref, + Ref, Family2, ) build, ) { @@ -397,7 +393,7 @@ final class Family2Family extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( - int Function(Ref ref, Family2 notifier, int argument) build, + int Function(Ref ref, Family2 notifier, int argument) build, ) { return $FamilyOverride( from: this, @@ -428,16 +424,14 @@ abstract class _$Family2 extends $Notifier { ); } -typedef ProviderRef = Ref; - @ProviderFor(provider) const providerProvider = ProviderProvider._(); final class ProviderProvider extends $FunctionalProvider - with $Provider { + with $Provider { const ProviderProvider._( {int Function( - ProviderRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -466,7 +460,7 @@ final class ProviderProvider extends $FunctionalProvider static const $allTransitiveDependencies3 = family2Provider; final int Function( - ProviderRef ref, + Ref ref, )? _createCb; @override @@ -488,31 +482,29 @@ final class ProviderProvider extends $FunctionalProvider @override ProviderProvider $copyWithCreate( int Function( - ProviderRef ref, + Ref ref, ) create, ) { return ProviderProvider._(create: create); } @override - int create(ProviderRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? provider; return _$cb(ref); } } -String _$providerHash() => r'6c9184ef4c6a410a2132e1ecc13a2e646e936d37'; - -typedef Provider2Ref = Ref; +String _$providerHash() => r'1be7ae7ac2100d39b949af50ec50fce48b26cdd1'; @ProviderFor(provider2) const provider2Provider = Provider2Provider._(); final class Provider2Provider extends $FunctionalProvider - with $Provider { + with $Provider { const Provider2Provider._( {int Function( - Provider2Ref ref, + Ref ref, )? create}) : _createCb = create, super( @@ -541,7 +533,7 @@ final class Provider2Provider extends $FunctionalProvider static const $allTransitiveDependencies3 = family2Provider; final int Function( - Provider2Ref ref, + Ref ref, )? _createCb; @override @@ -563,20 +555,20 @@ final class Provider2Provider extends $FunctionalProvider @override Provider2Provider $copyWithCreate( int Function( - Provider2Ref ref, + Ref ref, ) create, ) { return Provider2Provider._(create: create); } @override - int create(Provider2Ref ref) { + int create(Ref ref) { final _$cb = _createCb ?? provider2; return _$cb(ref); } } -String _$provider2Hash() => r'70d908579c5e64ce6558b42f433adfb80f4dc79b'; +String _$provider2Hash() => r'30f81430b57f0116f621a4a309c458fce0536378'; @ProviderFor(Provider3) const provider3Provider = Provider3Provider._(); @@ -639,7 +631,7 @@ final class Provider3Provider extends $NotifierProvider { @override Provider3Provider $copyWithBuild( int Function( - Ref, + Ref, Provider3, ) build, ) { @@ -724,7 +716,7 @@ final class Provider4Provider extends $NotifierProvider { @override Provider4Provider $copyWithBuild( int Function( - Ref, + Ref, Provider4, ) build, ) { @@ -806,7 +798,7 @@ final class Provider4Family extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( - int Function(Ref ref, Provider4 notifier, int argument) build, + int Function(Ref ref, Provider4 notifier, int argument) build, ) { return $FamilyOverride( from: this, @@ -837,16 +829,14 @@ abstract class _$Provider4 extends $Notifier { ); } -typedef TransitiveDependenciesRef = Ref; - @ProviderFor(transitiveDependencies) const transitiveDependenciesProvider = TransitiveDependenciesProvider._(); final class TransitiveDependenciesProvider extends $FunctionalProvider - with $Provider { + with $Provider { const TransitiveDependenciesProvider._( {int Function( - TransitiveDependenciesRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -876,7 +866,7 @@ final class TransitiveDependenciesProvider extends $FunctionalProvider ProviderProvider.$allTransitiveDependencies3; final int Function( - TransitiveDependenciesRef ref, + Ref ref, )? _createCb; @override @@ -898,34 +888,31 @@ final class TransitiveDependenciesProvider extends $FunctionalProvider @override TransitiveDependenciesProvider $copyWithCreate( int Function( - TransitiveDependenciesRef ref, + Ref ref, ) create, ) { return TransitiveDependenciesProvider._(create: create); } @override - int create(TransitiveDependenciesRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? transitiveDependencies; return _$cb(ref); } } String _$transitiveDependenciesHash() => - r'9c81823224bb28a5dc482328c04ce76293370877'; - -typedef SmallTransitiveDependencyCountRef = Ref; + r'909d45403831b521177ec15b1dd78554e261d3be'; @ProviderFor(smallTransitiveDependencyCount) const smallTransitiveDependencyCountProvider = SmallTransitiveDependencyCountProvider._(); final class SmallTransitiveDependencyCountProvider - extends $FunctionalProvider - with $Provider { + extends $FunctionalProvider with $Provider { const SmallTransitiveDependencyCountProvider._( {int Function( - SmallTransitiveDependencyCountRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -951,7 +938,7 @@ final class SmallTransitiveDependencyCountProvider static const $allTransitiveDependencies2 = dep2Provider; final int Function( - SmallTransitiveDependencyCountRef ref, + Ref ref, )? _createCb; @override @@ -973,34 +960,31 @@ final class SmallTransitiveDependencyCountProvider @override SmallTransitiveDependencyCountProvider $copyWithCreate( int Function( - SmallTransitiveDependencyCountRef ref, + Ref ref, ) create, ) { return SmallTransitiveDependencyCountProvider._(create: create); } @override - int create(SmallTransitiveDependencyCountRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? smallTransitiveDependencyCount; return _$cb(ref); } } String _$smallTransitiveDependencyCountHash() => - r'34689e1ba57e2959975cbf8ebd6c9483f4652a73'; - -typedef EmptyDependenciesFunctionalRef = Ref; + r'f67b369dd99e35a6e6211004b45c87c5ba4ac1c7'; @ProviderFor(emptyDependenciesFunctional) const emptyDependenciesFunctionalProvider = EmptyDependenciesFunctionalProvider._(); final class EmptyDependenciesFunctionalProvider - extends $FunctionalProvider - with $Provider { + extends $FunctionalProvider with $Provider { const EmptyDependenciesFunctionalProvider._( {int Function( - EmptyDependenciesFunctionalRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -1014,7 +998,7 @@ final class EmptyDependenciesFunctionalProvider ); final int Function( - EmptyDependenciesFunctionalRef ref, + Ref ref, )? _createCb; @override @@ -1036,21 +1020,21 @@ final class EmptyDependenciesFunctionalProvider @override EmptyDependenciesFunctionalProvider $copyWithCreate( int Function( - EmptyDependenciesFunctionalRef ref, + Ref ref, ) create, ) { return EmptyDependenciesFunctionalProvider._(create: create); } @override - int create(EmptyDependenciesFunctionalRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? emptyDependenciesFunctional; return _$cb(ref); } } String _$emptyDependenciesFunctionalHash() => - r'592bebd079450e2071fb12d68c3ae333d5c28359'; + r'77289071cab8a10da8f5b7b40932864510a1ee38'; @ProviderFor(EmptyDependenciesClassBased) const emptyDependenciesClassBasedProvider = @@ -1102,7 +1086,7 @@ final class EmptyDependenciesClassBasedProvider @override EmptyDependenciesClassBasedProvider $copyWithBuild( int Function( - Ref, + Ref, EmptyDependenciesClassBased, ) build, ) { @@ -1127,17 +1111,14 @@ abstract class _$EmptyDependenciesClassBased extends $Notifier { int runBuild() => build(); } -typedef ProviderWithDependenciesRef = Ref; - @ProviderFor(providerWithDependencies) const providerWithDependenciesProvider = ProviderWithDependenciesProvider._(); final class ProviderWithDependenciesProvider - extends $FunctionalProvider - with $Provider { + extends $FunctionalProvider with $Provider { const ProviderWithDependenciesProvider._( {int Function( - ProviderWithDependenciesRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -1160,7 +1141,7 @@ final class ProviderWithDependenciesProvider static const $allTransitiveDependencies1 = publicDepProvider; final int Function( - ProviderWithDependenciesRef ref, + Ref ref, )? _createCb; @override @@ -1182,32 +1163,30 @@ final class ProviderWithDependenciesProvider @override ProviderWithDependenciesProvider $copyWithCreate( int Function( - ProviderWithDependenciesRef ref, + Ref ref, ) create, ) { return ProviderWithDependenciesProvider._(create: create); } @override - int create(ProviderWithDependenciesRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? providerWithDependencies; return _$cb(ref); } } String _$providerWithDependenciesHash() => - r'beecbe7a41b647ab92367dbcc12055bcd6345af7'; - -typedef _PrivateDepRef = Ref; + r'7d40c994fc2d4ba9e6a0bb4a3d100f8da874eb5e'; @ProviderFor(_privateDep) const _privateDepProvider = _PrivateDepProvider._(); final class _PrivateDepProvider extends $FunctionalProvider - with $Provider { + with $Provider { const _PrivateDepProvider._( {int Function( - _PrivateDepRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -1221,7 +1200,7 @@ final class _PrivateDepProvider extends $FunctionalProvider ); final int Function( - _PrivateDepRef ref, + Ref ref, )? _createCb; @override @@ -1243,31 +1222,29 @@ final class _PrivateDepProvider extends $FunctionalProvider @override _PrivateDepProvider $copyWithCreate( int Function( - _PrivateDepRef ref, + Ref ref, ) create, ) { return _PrivateDepProvider._(create: create); } @override - int create(_PrivateDepRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? _privateDep; return _$cb(ref); } } -String _$privateDepHash() => r'f610d91bd39e0dcffe6ff4e74160964a291289d9'; - -typedef PublicDepRef = Ref; +String _$privateDepHash() => r'92ff5cc515ecf2455cb04773f1b49f23b17ea2e2'; @ProviderFor(publicDep) const publicDepProvider = PublicDepProvider._(); final class PublicDepProvider extends $FunctionalProvider - with $Provider { + with $Provider { const PublicDepProvider._( {int Function( - PublicDepRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -1281,7 +1258,7 @@ final class PublicDepProvider extends $FunctionalProvider ); final int Function( - PublicDepRef ref, + Ref ref, )? _createCb; @override @@ -1303,31 +1280,29 @@ final class PublicDepProvider extends $FunctionalProvider @override PublicDepProvider $copyWithCreate( int Function( - PublicDepRef ref, + Ref ref, ) create, ) { return PublicDepProvider._(create: create); } @override - int create(PublicDepRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? publicDep; return _$cb(ref); } } -String _$publicDepHash() => r'bcb69aace017c86c3c4b8eccf59fa22d010834bc'; - -typedef DuplicateDependenciesRef = Ref; +String _$publicDepHash() => r'a9c461ae174577183ab4c0ff8d8267cc7a64a2c5'; @ProviderFor(duplicateDependencies) const duplicateDependenciesProvider = DuplicateDependenciesProvider._(); final class DuplicateDependenciesProvider extends $FunctionalProvider - with $Provider { + with $Provider { const DuplicateDependenciesProvider._( {int Function( - DuplicateDependenciesRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -1347,7 +1322,7 @@ final class DuplicateDependenciesProvider extends $FunctionalProvider static const $allTransitiveDependencies1 = dep2Provider; final int Function( - DuplicateDependenciesRef ref, + Ref ref, )? _createCb; @override @@ -1369,32 +1344,30 @@ final class DuplicateDependenciesProvider extends $FunctionalProvider @override DuplicateDependenciesProvider $copyWithCreate( int Function( - DuplicateDependenciesRef ref, + Ref ref, ) create, ) { return DuplicateDependenciesProvider._(create: create); } @override - int create(DuplicateDependenciesRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? duplicateDependencies; return _$cb(ref); } } String _$duplicateDependenciesHash() => - r'8e4c4b40d7500e97e8490874d48cc960c64af712'; - -typedef DuplicateDependencies2Ref = Ref; + r'ad48ecca57899ee55c69793c84a01235d6a49834'; @ProviderFor(duplicateDependencies2) const duplicateDependencies2Provider = DuplicateDependencies2Provider._(); final class DuplicateDependencies2Provider extends $FunctionalProvider - with $Provider { + with $Provider { const DuplicateDependencies2Provider._( {int Function( - DuplicateDependencies2Ref ref, + Ref ref, )? create}) : _createCb = create, super( @@ -1417,7 +1390,7 @@ final class DuplicateDependencies2Provider extends $FunctionalProvider static const $allTransitiveDependencies1 = family2Provider; final int Function( - DuplicateDependencies2Ref ref, + Ref ref, )? _createCb; @override @@ -1439,34 +1412,31 @@ final class DuplicateDependencies2Provider extends $FunctionalProvider @override DuplicateDependencies2Provider $copyWithCreate( int Function( - DuplicateDependencies2Ref ref, + Ref ref, ) create, ) { return DuplicateDependencies2Provider._(create: create); } @override - int create(DuplicateDependencies2Ref ref) { + int create(Ref ref) { final _$cb = _createCb ?? duplicateDependencies2; return _$cb(ref); } } String _$duplicateDependencies2Hash() => - r'43a4ff16a760fc697426a5b1ebc1f8882c816cfb'; - -typedef TransitiveDuplicateDependenciesRef = Ref; + r'6e065325922dc36f408f85998cf2d7ba7a80ba56'; @ProviderFor(transitiveDuplicateDependencies) const transitiveDuplicateDependenciesProvider = TransitiveDuplicateDependenciesProvider._(); final class TransitiveDuplicateDependenciesProvider - extends $FunctionalProvider - with $Provider { + extends $FunctionalProvider with $Provider { const TransitiveDuplicateDependenciesProvider._( {int Function( - TransitiveDuplicateDependenciesRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -1501,7 +1471,7 @@ final class TransitiveDuplicateDependenciesProvider DuplicateDependencies2Provider.$allTransitiveDependencies1; final int Function( - TransitiveDuplicateDependenciesRef ref, + Ref ref, )? _createCb; @override @@ -1523,21 +1493,21 @@ final class TransitiveDuplicateDependenciesProvider @override TransitiveDuplicateDependenciesProvider $copyWithCreate( int Function( - TransitiveDuplicateDependenciesRef ref, + Ref ref, ) create, ) { return TransitiveDuplicateDependenciesProvider._(create: create); } @override - int create(TransitiveDuplicateDependenciesRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? transitiveDuplicateDependencies; return _$cb(ref); } } String _$transitiveDuplicateDependenciesHash() => - r'aba44b6c1cf82eea782ad260f2e95d9f771f12ac'; + r'be6a85098fc66be440b6b201f58a6ce1c526caf6'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/packages/riverpod_generator/test/integration/dependencies2.dart b/packages/riverpod_generator/test/integration/dependencies2.dart index 59c79f9b4..92697505e 100644 --- a/packages/riverpod_generator/test/integration/dependencies2.dart +++ b/packages/riverpod_generator/test/integration/dependencies2.dart @@ -6,12 +6,12 @@ part 'dependencies2.g.dart'; // Regression test for https://github.com/rrousselGit/riverpod/issues/2490 @Riverpod(dependencies: [providerWithDependencies, _private2, public2]) -int providerWithDependencies2(ProviderWithDependencies2Ref ref) { +int providerWithDependencies2(Ref ref) { return 0; } @Riverpod(dependencies: [providerWithDependencies, _private2, public2]) -int familyWithDependencies2(ProviderWithDependencies2Ref ref, {int? id}) { +int familyWithDependencies2(Ref ref, {int? id}) { return 0; } @@ -28,7 +28,7 @@ class NotifierFamilyWithDependencies extends _$NotifierFamilyWithDependencies { } @riverpod -int _private2(_Private2Ref ref) => 0; +int _private2(Ref ref) => 0; @riverpod -int public2(Public2Ref ref) => 0; +int public2(Ref ref) => 0; diff --git a/packages/riverpod_generator/test/integration/dependencies2.g.dart b/packages/riverpod_generator/test/integration/dependencies2.g.dart index 17bc8b5f6..175a263bf 100644 --- a/packages/riverpod_generator/test/integration/dependencies2.g.dart +++ b/packages/riverpod_generator/test/integration/dependencies2.g.dart @@ -6,17 +6,14 @@ part of 'dependencies2.dart'; // RiverpodGenerator // ************************************************************************** -typedef ProviderWithDependencies2Ref = Ref; - @ProviderFor(providerWithDependencies2) const providerWithDependencies2Provider = ProviderWithDependencies2Provider._(); final class ProviderWithDependencies2Provider - extends $FunctionalProvider - with $Provider { + extends $FunctionalProvider with $Provider { const ProviderWithDependencies2Provider._( {int Function( - ProviderWithDependencies2Ref ref, + Ref ref, )? create}) : _createCb = create, super( @@ -48,7 +45,7 @@ final class ProviderWithDependencies2Provider static const $allTransitiveDependencies4 = public2Provider; final int Function( - ProviderWithDependencies2Ref ref, + Ref ref, )? _createCb; @override @@ -70,35 +67,32 @@ final class ProviderWithDependencies2Provider @override ProviderWithDependencies2Provider $copyWithCreate( int Function( - ProviderWithDependencies2Ref ref, + Ref ref, ) create, ) { return ProviderWithDependencies2Provider._(create: create); } @override - int create(ProviderWithDependencies2Ref ref) { + int create(Ref ref) { final _$cb = _createCb ?? providerWithDependencies2; return _$cb(ref); } } String _$providerWithDependencies2Hash() => - r'90e090d5fa759369dceb59b2d2e219f67ed5f9e0'; - -typedef FamilyWithDependencies2Ref = Ref; + r'3a6100929120a9cf1ef7f1e0a5e9b8e4d4030ae2'; @ProviderFor(familyWithDependencies2) const familyWithDependencies2Provider = FamilyWithDependencies2Family._(); final class FamilyWithDependencies2Provider - extends $FunctionalProvider - with $Provider { + extends $FunctionalProvider with $Provider { const FamilyWithDependencies2Provider._( {required FamilyWithDependencies2Family super.from, required int? super.argument, int Function( - FamilyWithDependencies2Ref ref, { + Ref ref, { int? id, })? create}) : _createCb = create, @@ -119,7 +113,7 @@ final class FamilyWithDependencies2Provider static const $allTransitiveDependencies4 = public2Provider; final int Function( - FamilyWithDependencies2Ref ref, { + Ref ref, { int? id, })? _createCb; @@ -149,7 +143,7 @@ final class FamilyWithDependencies2Provider @override FamilyWithDependencies2Provider $copyWithCreate( int Function( - FamilyWithDependencies2Ref ref, + Ref ref, ) create, ) { return FamilyWithDependencies2Provider._( @@ -163,7 +157,7 @@ final class FamilyWithDependencies2Provider } @override - int create(FamilyWithDependencies2Ref ref) { + int create(Ref ref) { final _$cb = _createCb ?? familyWithDependencies2; final argument = this.argument as int?; return _$cb( @@ -185,7 +179,7 @@ final class FamilyWithDependencies2Provider } String _$familyWithDependencies2Hash() => - r'209b9e3ed4e5fad89572268d161fbe64a6ef0e87'; + r'd064c06ca5a85a62cbe2b47943e98fc2e858fb03'; final class FamilyWithDependencies2Family extends Family { const FamilyWithDependencies2Family._() @@ -221,7 +215,7 @@ final class FamilyWithDependencies2Family extends Family { /// {@macro riverpod.override_with} Override overrideWith( int Function( - FamilyWithDependencies2Ref ref, + Ref ref, int? args, ) create, ) { @@ -307,7 +301,7 @@ final class NotifierWithDependenciesProvider @override NotifierWithDependenciesProvider $copyWithBuild( int Function( - Ref, + Ref, NotifierWithDependencies, ) build, ) { @@ -399,7 +393,7 @@ final class NotifierFamilyWithDependenciesProvider @override NotifierFamilyWithDependenciesProvider $copyWithBuild( int Function( - Ref, + Ref, NotifierFamilyWithDependencies, ) build, ) { @@ -484,8 +478,8 @@ final class NotifierFamilyWithDependenciesFamily extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( - int Function(Ref ref, NotifierFamilyWithDependencies notifier, - int? argument) + int Function( + Ref ref, NotifierFamilyWithDependencies notifier, int? argument) build, ) { return $FamilyOverride( @@ -518,16 +512,14 @@ abstract class _$NotifierFamilyWithDependencies extends $Notifier { ); } -typedef _Private2Ref = Ref; - @ProviderFor(_private2) const _private2Provider = _Private2Provider._(); final class _Private2Provider extends $FunctionalProvider - with $Provider { + with $Provider { const _Private2Provider._( {int Function( - _Private2Ref ref, + Ref ref, )? create}) : _createCb = create, super( @@ -541,7 +533,7 @@ final class _Private2Provider extends $FunctionalProvider ); final int Function( - _Private2Ref ref, + Ref ref, )? _createCb; @override @@ -563,31 +555,29 @@ final class _Private2Provider extends $FunctionalProvider @override _Private2Provider $copyWithCreate( int Function( - _Private2Ref ref, + Ref ref, ) create, ) { return _Private2Provider._(create: create); } @override - int create(_Private2Ref ref) { + int create(Ref ref) { final _$cb = _createCb ?? _private2; return _$cb(ref); } } -String _$private2Hash() => r'5e0fa14ff40fb444c027ed25150a42362db3ef19'; - -typedef Public2Ref = Ref; +String _$private2Hash() => r'e420875c8fbd9bf33eff945f2b7276b585032a38'; @ProviderFor(public2) const public2Provider = Public2Provider._(); final class Public2Provider extends $FunctionalProvider - with $Provider { + with $Provider { const Public2Provider._( {int Function( - Public2Ref ref, + Ref ref, )? create}) : _createCb = create, super( @@ -601,7 +591,7 @@ final class Public2Provider extends $FunctionalProvider ); final int Function( - Public2Ref ref, + Ref ref, )? _createCb; @override @@ -623,20 +613,20 @@ final class Public2Provider extends $FunctionalProvider @override Public2Provider $copyWithCreate( int Function( - Public2Ref ref, + Ref ref, ) create, ) { return Public2Provider._(create: create); } @override - int create(Public2Ref ref) { + int create(Ref ref) { final _$cb = _createCb ?? public2; return _$cb(ref); } } -String _$public2Hash() => r'9767255f0182589fe48b29d217dd488b0a13b9d5'; +String _$public2Hash() => r'20eb4f82e5f25fafc72775e7b86021d70ebb5579'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/packages/riverpod_generator/test/integration/documented.dart b/packages/riverpod_generator/test/integration/documented.dart index ead656b6e..a395963be 100644 --- a/packages/riverpod_generator/test/integration/documented.dart +++ b/packages/riverpod_generator/test/integration/documented.dart @@ -5,7 +5,7 @@ part 'documented.g.dart'; /// Hello world // Foo @riverpod -String functional(FunctionalRef ref) => 'functional'; +String functional(Ref ref) => 'functional'; /// Hello world // Foo @@ -19,7 +19,7 @@ class ClassBased extends _$ClassBased { // Foo @riverpod String family( - FamilyRef ref, + Ref ref, /// Hello Id int id, diff --git a/packages/riverpod_generator/test/integration/documented.g.dart b/packages/riverpod_generator/test/integration/documented.g.dart index b8c36c01e..fb33e8058 100644 --- a/packages/riverpod_generator/test/integration/documented.g.dart +++ b/packages/riverpod_generator/test/integration/documented.g.dart @@ -6,10 +6,6 @@ part of 'documented.dart'; // RiverpodGenerator // ************************************************************************** -/// Hello world -// Foo -typedef FunctionalRef = Ref; - /// Hello world // Foo @ProviderFor(functional) @@ -18,12 +14,12 @@ const functionalProvider = FunctionalProvider._(); /// Hello world // Foo final class FunctionalProvider extends $FunctionalProvider - with $Provider { + with $Provider { /// Hello world // Foo const FunctionalProvider._( {String Function( - FunctionalRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -37,7 +33,7 @@ final class FunctionalProvider extends $FunctionalProvider ); final String Function( - FunctionalRef ref, + Ref ref, )? _createCb; @override @@ -59,20 +55,20 @@ final class FunctionalProvider extends $FunctionalProvider @override FunctionalProvider $copyWithCreate( String Function( - FunctionalRef ref, + Ref ref, ) create, ) { return FunctionalProvider._(create: create); } @override - String create(FunctionalRef ref) { + String create(Ref ref) { final _$cb = _createCb ?? functional; return _$cb(ref); } } -String _$functionalHash() => r'1198a9a7842513019f6a8cd1b32e72217a00ee8f'; +String _$functionalHash() => r'52eddcd28b005800da9cf6c22df77f2f040bfb34'; /// Hello world // Foo @@ -126,7 +122,7 @@ final class ClassBasedProvider extends $NotifierProvider { @override ClassBasedProvider $copyWithBuild( String Function( - Ref, + Ref, ClassBased, ) build, ) { @@ -149,10 +145,6 @@ abstract class _$ClassBased extends $Notifier { String runBuild() => build(); } -/// Hello world -// Foo -typedef FamilyRef = Ref; - /// Hello world // Foo @ProviderFor(family) @@ -161,14 +153,14 @@ const familyProvider = FamilyFamily._(); /// Hello world // Foo final class FamilyProvider extends $FunctionalProvider - with $Provider { + with $Provider { /// Hello world // Foo const FamilyProvider._( {required FamilyFamily super.from, required int super.argument, String Function( - FamilyRef ref, + Ref ref, int id, )? create}) : _createCb = create, @@ -181,7 +173,7 @@ final class FamilyProvider extends $FunctionalProvider ); final String Function( - FamilyRef ref, + Ref ref, int id, )? _createCb; @@ -211,7 +203,7 @@ final class FamilyProvider extends $FunctionalProvider @override FamilyProvider $copyWithCreate( String Function( - FamilyRef ref, + Ref ref, ) create, ) { return FamilyProvider._( @@ -225,7 +217,7 @@ final class FamilyProvider extends $FunctionalProvider } @override - String create(FamilyRef ref) { + String create(Ref ref) { final _$cb = _createCb ?? family; final argument = this.argument as int; return _$cb( @@ -245,7 +237,7 @@ final class FamilyProvider extends $FunctionalProvider } } -String _$familyHash() => r'339f0a8e0733a30bbb2220ce7ff6b9de7abe6022'; +String _$familyHash() => r'5164f4ea1f2d6c741e5c600c48a1b2ac2be7a1eb'; /// Hello world // Foo @@ -275,7 +267,7 @@ final class FamilyFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( String Function( - FamilyRef ref, + Ref ref, int args, ) create, ) { @@ -358,7 +350,7 @@ final class ClassFamilyBasedProvider @override ClassFamilyBasedProvider $copyWithBuild( String Function( - Ref, + Ref, ClassFamilyBased, ) build, ) { @@ -434,8 +426,7 @@ final class ClassFamilyBasedFamily extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( - String Function(Ref ref, ClassFamilyBased notifier, int argument) - build, + String Function(Ref ref, ClassFamilyBased notifier, int argument) build, ) { return $FamilyOverride( from: this, @@ -470,4 +461,4 @@ abstract class _$ClassFamilyBased extends $Notifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/packages/riverpod_generator/test/integration/generated.dart b/packages/riverpod_generator/test/integration/generated.dart index 0122f491d..a00374139 100644 --- a/packages/riverpod_generator/test/integration/generated.dart +++ b/packages/riverpod_generator/test/integration/generated.dart @@ -1,7 +1,6 @@ // ignore_for_file: library_private_types_in_public_api, inference_failure_on_function_return_type, always_declare_return_types, type_annotate_public_apis import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:riverpod/riverpod.dart' as r; import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'generated.freezed.dart'; @@ -13,10 +12,10 @@ class Test with _$Test { } @riverpod -_Test generated(GeneratedRef ref) => _Test(); +_Test generated(Ref ref) => _Test(); @riverpod -_Test generatedFamily(GeneratedFamilyRef ref, _Test test) => _Test(); +_Test generatedFamily(Ref ref, _Test test) => _Test(); @riverpod class GeneratedClass extends _$GeneratedClass { @@ -31,10 +30,10 @@ class GeneratedClassFamily extends _$GeneratedClassFamily { } @riverpod -$dynamic($DynamicRef ref) => _Test(); +$dynamic(Ref ref) => _Test(); @riverpod -$dynamicFamily($DynamicFamilyRef ref, test) => _Test(); +$dynamicFamily(Ref ref, test) => _Test(); @riverpod class $DynamicClass extends _$$DynamicClass { @@ -51,35 +50,35 @@ class $DynamicClassFamily extends _$$DynamicClassFamily { const dynamicProvider = _dynamicProvider; @riverpod -_dynamic(_DynamicRef ref, test) => 0; +_dynamic(Ref ref, test) => 0; @riverpod -r.AsyncValue alias(AliasRef ref) { - return const r.AsyncData(42); +AsyncValue alias(Ref ref) { + return const AsyncData(42); } @riverpod -r.AsyncValue aliasFamily( - AliasFamilyRef ref, - r.AsyncValue test, +AsyncValue aliasFamily( + Ref ref, + AsyncValue test, ) { - return const r.AsyncData(42); + return const AsyncData(42); } @riverpod class AliasClass extends _$AliasClass { @override - r.AsyncValue build() { - return const r.AsyncData(42); + AsyncValue build() { + return const AsyncData(42); } } @riverpod class AliasClassFamily extends _$AliasClassFamily { @override - r.AsyncValue build( - r.AsyncValue test, + AsyncValue build( + AsyncValue test, ) { - return const r.AsyncData(42); + return const AsyncData(42); } } diff --git a/packages/riverpod_generator/test/integration/generated.g.dart b/packages/riverpod_generator/test/integration/generated.g.dart index 26cafbcf9..e835715b7 100644 --- a/packages/riverpod_generator/test/integration/generated.g.dart +++ b/packages/riverpod_generator/test/integration/generated.g.dart @@ -6,16 +6,14 @@ part of 'generated.dart'; // RiverpodGenerator // ************************************************************************** -typedef GeneratedRef = Ref<_Test>; - @ProviderFor(generated) const generatedProvider = GeneratedProvider._(); final class GeneratedProvider extends $FunctionalProvider<_Test, _Test> - with $Provider<_Test, GeneratedRef> { + with $Provider<_Test> { const GeneratedProvider._( {_Test Function( - GeneratedRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -29,7 +27,7 @@ final class GeneratedProvider extends $FunctionalProvider<_Test, _Test> ); final _Test Function( - GeneratedRef ref, + Ref ref, )? _createCb; @override @@ -51,33 +49,31 @@ final class GeneratedProvider extends $FunctionalProvider<_Test, _Test> @override GeneratedProvider $copyWithCreate( _Test Function( - GeneratedRef ref, + Ref ref, ) create, ) { return GeneratedProvider._(create: create); } @override - _Test create(GeneratedRef ref) { + _Test create(Ref ref) { final _$cb = _createCb ?? generated; return _$cb(ref); } } -String _$generatedHash() => r'e49f3520d06ed50d34a44de613fdcd20b19f48d4'; - -typedef GeneratedFamilyRef = Ref<_Test>; +String _$generatedHash() => r'0332eb232658688654514ff241ff380edbf4dbf6'; @ProviderFor(generatedFamily) const generatedFamilyProvider = GeneratedFamilyFamily._(); final class GeneratedFamilyProvider extends $FunctionalProvider<_Test, _Test> - with $Provider<_Test, GeneratedFamilyRef> { + with $Provider<_Test> { const GeneratedFamilyProvider._( {required GeneratedFamilyFamily super.from, required _Test super.argument, _Test Function( - GeneratedFamilyRef ref, + Ref ref, _Test test, )? create}) : _createCb = create, @@ -90,7 +86,7 @@ final class GeneratedFamilyProvider extends $FunctionalProvider<_Test, _Test> ); final _Test Function( - GeneratedFamilyRef ref, + Ref ref, _Test test, )? _createCb; @@ -120,7 +116,7 @@ final class GeneratedFamilyProvider extends $FunctionalProvider<_Test, _Test> @override GeneratedFamilyProvider $copyWithCreate( _Test Function( - GeneratedFamilyRef ref, + Ref ref, ) create, ) { return GeneratedFamilyProvider._( @@ -134,7 +130,7 @@ final class GeneratedFamilyProvider extends $FunctionalProvider<_Test, _Test> } @override - _Test create(GeneratedFamilyRef ref) { + _Test create(Ref ref) { final _$cb = _createCb ?? generatedFamily; final argument = this.argument as _Test; return _$cb( @@ -154,7 +150,7 @@ final class GeneratedFamilyProvider extends $FunctionalProvider<_Test, _Test> } } -String _$generatedFamilyHash() => r'ed284f58926c87acc81dab9168882d5d1c2cddf8'; +String _$generatedFamilyHash() => r'8ac3b633763cb8dbad6e0686a732df3a081a0d64'; final class GeneratedFamilyFamily extends Family { const GeneratedFamilyFamily._() @@ -180,7 +176,7 @@ final class GeneratedFamilyFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( _Test Function( - GeneratedFamilyRef ref, + Ref ref, _Test args, ) create, ) { @@ -246,7 +242,7 @@ final class GeneratedClassProvider @override GeneratedClassProvider $copyWithBuild( _Test Function( - Ref<_Test>, + Ref, GeneratedClass, ) build, ) { @@ -327,7 +323,7 @@ final class GeneratedClassFamilyProvider @override GeneratedClassFamilyProvider $copyWithBuild( _Test Function( - Ref<_Test>, + Ref, GeneratedClassFamily, ) build, ) { @@ -400,8 +396,7 @@ final class GeneratedClassFamilyFamily extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( - _Test Function( - Ref<_Test> ref, GeneratedClassFamily notifier, _Test argument) + _Test Function(Ref ref, GeneratedClassFamily notifier, _Test argument) build, ) { return $FamilyOverride( @@ -433,16 +428,14 @@ abstract class _$GeneratedClassFamily extends $Notifier<_Test> { ); } -typedef $DynamicRef = Ref; - @ProviderFor($dynamic) const $dynamicProvider = $DynamicProvider._(); final class $DynamicProvider extends $FunctionalProvider - with $Provider { + with $Provider { const $DynamicProvider._( {Object? Function( - $DynamicRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -456,7 +449,7 @@ final class $DynamicProvider extends $FunctionalProvider ); final Object? Function( - $DynamicRef ref, + Ref ref, )? _createCb; @override @@ -478,33 +471,31 @@ final class $DynamicProvider extends $FunctionalProvider @override $DynamicProvider $copyWithCreate( Object? Function( - $DynamicRef ref, + Ref ref, ) create, ) { return $DynamicProvider._(create: create); } @override - Object? create($DynamicRef ref) { + Object? create(Ref ref) { final _$cb = _createCb ?? $dynamic; return _$cb(ref); } } -String _$$dynamicHash() => r'f62d63d9340f30b253e687f76deacd8205fed0e7'; - -typedef $DynamicFamilyRef = Ref; +String _$$dynamicHash() => r'17c8e140446da2e3c026ebb51c4b074d2894b7ff'; @ProviderFor($dynamicFamily) const $dynamicFamilyProvider = $DynamicFamilyFamily._(); final class $DynamicFamilyProvider extends $FunctionalProvider - with $Provider { + with $Provider { const $DynamicFamilyProvider._( {required $DynamicFamilyFamily super.from, required dynamic super.argument, Object? Function( - $DynamicFamilyRef ref, + Ref ref, dynamic test, )? create}) : _createCb = create, @@ -517,7 +508,7 @@ final class $DynamicFamilyProvider extends $FunctionalProvider ); final Object? Function( - $DynamicFamilyRef ref, + Ref ref, dynamic test, )? _createCb; @@ -547,7 +538,7 @@ final class $DynamicFamilyProvider extends $FunctionalProvider @override $DynamicFamilyProvider $copyWithCreate( Object? Function( - $DynamicFamilyRef ref, + Ref ref, ) create, ) { return $DynamicFamilyProvider._( @@ -561,7 +552,7 @@ final class $DynamicFamilyProvider extends $FunctionalProvider } @override - Object? create($DynamicFamilyRef ref) { + Object? create(Ref ref) { final _$cb = _createCb ?? $dynamicFamily; final argument = this.argument as dynamic; return _$cb( @@ -581,7 +572,7 @@ final class $DynamicFamilyProvider extends $FunctionalProvider } } -String _$$dynamicFamilyHash() => r'b764133af8837b8321b08814892f198d4bc1aa18'; +String _$$dynamicFamilyHash() => r'6897846251c8b4b5b2fa72d8d3e14ae3381c0c0f'; final class $DynamicFamilyFamily extends Family { const $DynamicFamilyFamily._() @@ -607,7 +598,7 @@ final class $DynamicFamilyFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( Object? Function( - $DynamicFamilyRef ref, + Ref ref, dynamic args, ) create, ) { @@ -673,7 +664,7 @@ final class $DynamicClassProvider @override $DynamicClassProvider $copyWithBuild( Object? Function( - Ref, + Ref, $DynamicClass, ) build, ) { @@ -754,7 +745,7 @@ final class $DynamicClassFamilyProvider @override $DynamicClassFamilyProvider $copyWithBuild( Object? Function( - Ref, + Ref, $DynamicClassFamily, ) build, ) { @@ -827,8 +818,7 @@ final class $DynamicClassFamilyFamily extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( - Object? Function( - Ref ref, $DynamicClassFamily notifier, dynamic argument) + Object? Function(Ref ref, $DynamicClassFamily notifier, dynamic argument) build, ) { return $FamilyOverride( @@ -860,18 +850,16 @@ abstract class _$$DynamicClassFamily extends $Notifier { ); } -typedef _DynamicRef = Ref; - @ProviderFor(_dynamic) const _dynamicProvider = _DynamicFamily._(); final class _DynamicProvider extends $FunctionalProvider - with $Provider { + with $Provider { const _DynamicProvider._( {required _DynamicFamily super.from, required dynamic super.argument, Object? Function( - _DynamicRef ref, + Ref ref, dynamic test, )? create}) : _createCb = create, @@ -884,7 +872,7 @@ final class _DynamicProvider extends $FunctionalProvider ); final Object? Function( - _DynamicRef ref, + Ref ref, dynamic test, )? _createCb; @@ -914,7 +902,7 @@ final class _DynamicProvider extends $FunctionalProvider @override _DynamicProvider $copyWithCreate( Object? Function( - _DynamicRef ref, + Ref ref, ) create, ) { return _DynamicProvider._( @@ -928,7 +916,7 @@ final class _DynamicProvider extends $FunctionalProvider } @override - Object? create(_DynamicRef ref) { + Object? create(Ref ref) { final _$cb = _createCb ?? _dynamic; final argument = this.argument as dynamic; return _$cb( @@ -948,7 +936,7 @@ final class _DynamicProvider extends $FunctionalProvider } } -String _$dynamicHash() => r'da9dc07960139fff2cf5fe584dca5c524e4f2308'; +String _$dynamicHash() => r'e08bd08481e4ea0d3da2ab7c38f940c34e96ba7f'; final class _DynamicFamily extends Family { const _DynamicFamily._() @@ -974,7 +962,7 @@ final class _DynamicFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( Object? Function( - _DynamicRef ref, + Ref ref, dynamic args, ) create, ) { @@ -993,17 +981,15 @@ final class _DynamicFamily extends Family { } } -typedef AliasRef = Ref>; - @ProviderFor(alias) const aliasProvider = AliasProvider._(); final class AliasProvider - extends $FunctionalProvider, r.AsyncValue> - with $Provider, AliasRef> { + extends $FunctionalProvider, AsyncValue> + with $Provider> { const AliasProvider._( - {r.AsyncValue Function( - AliasRef ref, + {AsyncValue Function( + Ref ref, )? create}) : _createCb = create, super( @@ -1016,59 +1002,56 @@ final class AliasProvider allTransitiveDependencies: null, ); - final r.AsyncValue Function( - AliasRef ref, + final AsyncValue Function( + Ref ref, )? _createCb; @override String debugGetCreateSourceHash() => _$aliasHash(); /// {@macro riverpod.override_with_value} - Override overrideWithValue(r.AsyncValue value) { + Override overrideWithValue(AsyncValue value) { return $ProviderOverride( origin: this, - providerOverride: $ValueProvider>(value), + providerOverride: $ValueProvider>(value), ); } @$internal @override - $ProviderElement> $createElement( - $ProviderPointer pointer) => + $ProviderElement> $createElement($ProviderPointer pointer) => $ProviderElement(this, pointer); @override AliasProvider $copyWithCreate( - r.AsyncValue Function( - AliasRef ref, + AsyncValue Function( + Ref ref, ) create, ) { return AliasProvider._(create: create); } @override - r.AsyncValue create(AliasRef ref) { + AsyncValue create(Ref ref) { final _$cb = _createCb ?? alias; return _$cb(ref); } } -String _$aliasHash() => r'cc08ec4cc5ec0dc98bdb7f4dcbc035021b09bcf3'; - -typedef AliasFamilyRef = Ref>; +String _$aliasHash() => r'3feb548aa9a314142b5c5e3c9c7664a316a10d11'; @ProviderFor(aliasFamily) const aliasFamilyProvider = AliasFamilyFamily._(); final class AliasFamilyProvider - extends $FunctionalProvider, r.AsyncValue> - with $Provider, AliasFamilyRef> { + extends $FunctionalProvider, AsyncValue> + with $Provider> { const AliasFamilyProvider._( {required AliasFamilyFamily super.from, - required r.AsyncValue super.argument, - r.AsyncValue Function( - AliasFamilyRef ref, - r.AsyncValue test, + required AsyncValue super.argument, + AsyncValue Function( + Ref ref, + AsyncValue test, )? create}) : _createCb = create, super( @@ -1079,9 +1062,9 @@ final class AliasFamilyProvider allTransitiveDependencies: null, ); - final r.AsyncValue Function( - AliasFamilyRef ref, - r.AsyncValue test, + final AsyncValue Function( + Ref ref, + AsyncValue test, )? _createCb; @override @@ -1095,39 +1078,38 @@ final class AliasFamilyProvider } /// {@macro riverpod.override_with_value} - Override overrideWithValue(r.AsyncValue value) { + Override overrideWithValue(AsyncValue value) { return $ProviderOverride( origin: this, - providerOverride: $ValueProvider>(value), + providerOverride: $ValueProvider>(value), ); } @$internal @override - $ProviderElement> $createElement( - $ProviderPointer pointer) => + $ProviderElement> $createElement($ProviderPointer pointer) => $ProviderElement(this, pointer); @override AliasFamilyProvider $copyWithCreate( - r.AsyncValue Function( - AliasFamilyRef ref, + AsyncValue Function( + Ref ref, ) create, ) { return AliasFamilyProvider._( - argument: argument as r.AsyncValue, + argument: argument as AsyncValue, from: from! as AliasFamilyFamily, create: ( ref, - r.AsyncValue test, + AsyncValue test, ) => create(ref)); } @override - r.AsyncValue create(AliasFamilyRef ref) { + AsyncValue create(Ref ref) { final _$cb = _createCb ?? aliasFamily; - final argument = this.argument as r.AsyncValue; + final argument = this.argument as AsyncValue; return _$cb( ref, argument, @@ -1145,7 +1127,7 @@ final class AliasFamilyProvider } } -String _$aliasFamilyHash() => r'f345937d5750132f629aef41646b119a301f750b'; +String _$aliasFamilyHash() => r'6afe0afc21cfd2f0f26862e9d8c1095eca5f6e42'; final class AliasFamilyFamily extends Family { const AliasFamilyFamily._() @@ -1158,7 +1140,7 @@ final class AliasFamilyFamily extends Family { ); AliasFamilyProvider call( - r.AsyncValue test, + AsyncValue test, ) => AliasFamilyProvider._(argument: test, from: this); @@ -1170,9 +1152,9 @@ final class AliasFamilyFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( - r.AsyncValue Function( - AliasFamilyRef ref, - r.AsyncValue args, + AsyncValue Function( + Ref ref, + AsyncValue args, ) create, ) { return $FamilyOverride( @@ -1180,7 +1162,7 @@ final class AliasFamilyFamily extends Family { createElement: (pointer) { final provider = pointer.origin as AliasFamilyProvider; - final argument = provider.argument as r.AsyncValue; + final argument = provider.argument as AsyncValue; return provider .$copyWithCreate((ref) => create(ref, argument)) @@ -1194,7 +1176,7 @@ final class AliasFamilyFamily extends Family { const aliasClassProvider = AliasClassProvider._(); final class AliasClassProvider - extends $NotifierProvider> { + extends $NotifierProvider> { const AliasClassProvider._( {super.runNotifierBuildOverride, AliasClass Function()? create}) : _createCb = create, @@ -1214,10 +1196,10 @@ final class AliasClassProvider String debugGetCreateSourceHash() => _$aliasClassHash(); /// {@macro riverpod.override_with_value} - Override overrideWithValue(r.AsyncValue value) { + Override overrideWithValue(AsyncValue value) { return $ProviderOverride( origin: this, - providerOverride: $ValueProvider>(value), + providerOverride: $ValueProvider>(value), ); } @@ -1236,8 +1218,8 @@ final class AliasClassProvider @$internal @override AliasClassProvider $copyWithBuild( - r.AsyncValue Function( - Ref>, + AsyncValue Function( + Ref, AliasClass, ) build, ) { @@ -1246,28 +1228,28 @@ final class AliasClassProvider @$internal @override - $NotifierProviderElement> $createElement( + $NotifierProviderElement> $createElement( $ProviderPointer pointer) => $NotifierProviderElement(this, pointer); } -String _$aliasClassHash() => r'a6c6d7594ebd09ba728e42d79b12af560d09c379'; +String _$aliasClassHash() => r'aac83936c14520c015f0fe8a0120d353c0baf602'; -abstract class _$AliasClass extends $Notifier> { - r.AsyncValue build(); +abstract class _$AliasClass extends $Notifier> { + AsyncValue build(); @$internal @override - r.AsyncValue runBuild() => build(); + AsyncValue runBuild() => build(); } @ProviderFor(AliasClassFamily) const aliasClassFamilyProvider = AliasClassFamilyFamily._(); final class AliasClassFamilyProvider - extends $NotifierProvider> { + extends $NotifierProvider> { const AliasClassFamilyProvider._( {required AliasClassFamilyFamily super.from, - required r.AsyncValue super.argument, + required AsyncValue super.argument, super.runNotifierBuildOverride, AliasClassFamily Function()? create}) : _createCb = create, @@ -1292,10 +1274,10 @@ final class AliasClassFamilyProvider } /// {@macro riverpod.override_with_value} - Override overrideWithValue(r.AsyncValue value) { + Override overrideWithValue(AsyncValue value) { return $ProviderOverride( origin: this, - providerOverride: $ValueProvider>(value), + providerOverride: $ValueProvider>(value), ); } @@ -1309,7 +1291,7 @@ final class AliasClassFamilyProvider AliasClassFamily Function() create, ) { return AliasClassFamilyProvider._( - argument: argument as r.AsyncValue, + argument: argument as AsyncValue, from: from! as AliasClassFamilyFamily, create: create); } @@ -1317,20 +1299,20 @@ final class AliasClassFamilyProvider @$internal @override AliasClassFamilyProvider $copyWithBuild( - r.AsyncValue Function( - Ref>, + AsyncValue Function( + Ref, AliasClassFamily, ) build, ) { return AliasClassFamilyProvider._( - argument: argument as r.AsyncValue, + argument: argument as AsyncValue, from: from! as AliasClassFamilyFamily, runNotifierBuildOverride: build); } @$internal @override - $NotifierProviderElement> $createElement( + $NotifierProviderElement> $createElement( $ProviderPointer pointer) => $NotifierProviderElement(this, pointer); @@ -1345,7 +1327,7 @@ final class AliasClassFamilyProvider } } -String _$aliasClassFamilyHash() => r'3f348beb95dae3a9890b4a4d0ce01481316fc66d'; +String _$aliasClassFamilyHash() => r'd4374c0ffbbca9d65fb967255129b3ceddaa764e'; final class AliasClassFamilyFamily extends Family { const AliasClassFamilyFamily._() @@ -1358,7 +1340,7 @@ final class AliasClassFamilyFamily extends Family { ); AliasClassFamilyProvider call( - r.AsyncValue test, + AsyncValue test, ) => AliasClassFamilyProvider._(argument: test, from: this); @@ -1371,7 +1353,7 @@ final class AliasClassFamilyFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( AliasClassFamily Function( - r.AsyncValue args, + AsyncValue args, ) create, ) { return $FamilyOverride( @@ -1379,7 +1361,7 @@ final class AliasClassFamilyFamily extends Family { createElement: (pointer) { final provider = pointer.origin as AliasClassFamilyProvider; - final argument = provider.argument as r.AsyncValue; + final argument = provider.argument as AsyncValue; return provider .$copyWithCreate(() => create(argument)) @@ -1390,8 +1372,8 @@ final class AliasClassFamilyFamily extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( - r.AsyncValue Function(Ref> ref, - AliasClassFamily notifier, r.AsyncValue argument) + AsyncValue Function( + Ref ref, AliasClassFamily notifier, AsyncValue argument) build, ) { return $FamilyOverride( @@ -1399,7 +1381,7 @@ final class AliasClassFamilyFamily extends Family { createElement: (pointer) { final provider = pointer.origin as AliasClassFamilyProvider; - final argument = provider.argument as r.AsyncValue; + final argument = provider.argument as AsyncValue; return provider .$copyWithBuild((ref, notifier) => build(ref, notifier, argument)) @@ -1409,19 +1391,19 @@ final class AliasClassFamilyFamily extends Family { } } -abstract class _$AliasClassFamily extends $Notifier> { - late final _$args = ref.$arg as r.AsyncValue; - r.AsyncValue get test => _$args; +abstract class _$AliasClassFamily extends $Notifier> { + late final _$args = ref.$arg as AsyncValue; + AsyncValue get test => _$args; - r.AsyncValue build( - r.AsyncValue test, + AsyncValue build( + AsyncValue test, ); @$internal @override - r.AsyncValue runBuild() => build( + AsyncValue runBuild() => build( _$args, ); } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/packages/riverpod_generator/test/integration/hash/hash1.dart b/packages/riverpod_generator/test/integration/hash/hash1.dart index a299a420e..67fb2e74a 100644 --- a/packages/riverpod_generator/test/integration/hash/hash1.dart +++ b/packages/riverpod_generator/test/integration/hash/hash1.dart @@ -3,12 +3,12 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'hash1.g.dart'; @riverpod -String simple(SimpleRef ref) { +String simple(Ref ref) { return 'Hello world'; } @riverpod -String simple2(Simple2Ref ref) { +String simple2(Ref ref) { return 'Hello world2'; } diff --git a/packages/riverpod_generator/test/integration/hash/hash1.g.dart b/packages/riverpod_generator/test/integration/hash/hash1.g.dart index 3b01e9aa9..9842eb755 100644 --- a/packages/riverpod_generator/test/integration/hash/hash1.g.dart +++ b/packages/riverpod_generator/test/integration/hash/hash1.g.dart @@ -6,16 +6,14 @@ part of 'hash1.dart'; // RiverpodGenerator // ************************************************************************** -typedef SimpleRef = Ref; - @ProviderFor(simple) const simpleProvider = SimpleProvider._(); final class SimpleProvider extends $FunctionalProvider - with $Provider { + with $Provider { const SimpleProvider._( {String Function( - SimpleRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -29,7 +27,7 @@ final class SimpleProvider extends $FunctionalProvider ); final String Function( - SimpleRef ref, + Ref ref, )? _createCb; @override @@ -51,31 +49,29 @@ final class SimpleProvider extends $FunctionalProvider @override SimpleProvider $copyWithCreate( String Function( - SimpleRef ref, + Ref ref, ) create, ) { return SimpleProvider._(create: create); } @override - String create(SimpleRef ref) { + String create(Ref ref) { final _$cb = _createCb ?? simple; return _$cb(ref); } } -String _$simpleHash() => r'ff9f7451526aef5b3af6646814631a502ad76a5f'; - -typedef Simple2Ref = Ref; +String _$simpleHash() => r'f916b37e39d654e9acfc9c2bd7a244902197b306'; @ProviderFor(simple2) const simple2Provider = Simple2Provider._(); final class Simple2Provider extends $FunctionalProvider - with $Provider { + with $Provider { const Simple2Provider._( {String Function( - Simple2Ref ref, + Ref ref, )? create}) : _createCb = create, super( @@ -89,7 +85,7 @@ final class Simple2Provider extends $FunctionalProvider ); final String Function( - Simple2Ref ref, + Ref ref, )? _createCb; @override @@ -111,20 +107,20 @@ final class Simple2Provider extends $FunctionalProvider @override Simple2Provider $copyWithCreate( String Function( - Simple2Ref ref, + Ref ref, ) create, ) { return Simple2Provider._(create: create); } @override - String create(Simple2Ref ref) { + String create(Ref ref) { final _$cb = _createCb ?? simple2; return _$cb(ref); } } -String _$simple2Hash() => r'06327442776394c5c9cbb33b048d7a42e709e7fd'; +String _$simple2Hash() => r'a60a8496fc391f5adf7ad45a12d0723f14f3127c'; @ProviderFor(SimpleClass) const simpleClassProvider = SimpleClassProvider._(); @@ -172,7 +168,7 @@ final class SimpleClassProvider extends $NotifierProvider { @override SimpleClassProvider $copyWithBuild( String Function( - Ref, + Ref, SimpleClass, ) build, ) { @@ -196,4 +192,4 @@ abstract class _$SimpleClass extends $Notifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/packages/riverpod_generator/test/integration/hash/retry.dart b/packages/riverpod_generator/test/integration/hash/retry.dart index 6aadf62ba..77b2d08af 100644 --- a/packages/riverpod_generator/test/integration/hash/retry.dart +++ b/packages/riverpod_generator/test/integration/hash/retry.dart @@ -3,10 +3,10 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'retry.g.dart'; @Riverpod(retry: myRetry) -String a(ARef ref) => throw UnimplementedError(); +String a(Ref ref) => throw UnimplementedError(); Duration? myRetry(int retryCount, Object error) => null; Duration? myRetry2(int retryCount, Object error) => null; @Riverpod(retry: myRetry2) -String b(ARef ref, int arg) => throw UnimplementedError(); +String b(Ref ref, int arg) => throw UnimplementedError(); diff --git a/packages/riverpod_generator/test/integration/hash/retry.g.dart b/packages/riverpod_generator/test/integration/hash/retry.g.dart index a49dc5d2d..97c31e493 100644 --- a/packages/riverpod_generator/test/integration/hash/retry.g.dart +++ b/packages/riverpod_generator/test/integration/hash/retry.g.dart @@ -6,16 +6,14 @@ part of 'retry.dart'; // RiverpodGenerator // ************************************************************************** -typedef ARef = Ref; - @ProviderFor(a) const aProvider = AProvider._(); final class AProvider extends $FunctionalProvider - with $Provider { + with $Provider { const AProvider._( {String Function( - ARef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -29,7 +27,7 @@ final class AProvider extends $FunctionalProvider ); final String Function( - ARef ref, + Ref ref, )? _createCb; @override @@ -51,33 +49,31 @@ final class AProvider extends $FunctionalProvider @override AProvider $copyWithCreate( String Function( - ARef ref, + Ref ref, ) create, ) { return AProvider._(create: create); } @override - String create(ARef ref) { + String create(Ref ref) { final _$cb = _createCb ?? a; return _$cb(ref); } } -String _$aHash() => r'3500a02140f277a66793d8118c15e09150ae67cd'; - -typedef BRef = Ref; +String _$aHash() => r'83a9516d10f85dc72ca773837e042bfc6e36c1f1'; @ProviderFor(b) const bProvider = BFamily._(); final class BProvider extends $FunctionalProvider - with $Provider { + with $Provider { const BProvider._( {required BFamily super.from, required int super.argument, String Function( - BRef ref, + Ref ref, int arg, )? create}) : _createCb = create, @@ -90,7 +86,7 @@ final class BProvider extends $FunctionalProvider ); final String Function( - BRef ref, + Ref ref, int arg, )? _createCb; @@ -120,7 +116,7 @@ final class BProvider extends $FunctionalProvider @override BProvider $copyWithCreate( String Function( - BRef ref, + Ref ref, ) create, ) { return BProvider._( @@ -134,7 +130,7 @@ final class BProvider extends $FunctionalProvider } @override - String create(BRef ref) { + String create(Ref ref) { final _$cb = _createCb ?? b; final argument = this.argument as int; return _$cb( @@ -154,7 +150,7 @@ final class BProvider extends $FunctionalProvider } } -String _$bHash() => r'0af37d2fa472b9730e1aa01841787d964b9f193b'; +String _$bHash() => r'95798a157250c86a901bca5701b487f508f8a5a4'; final class BFamily extends Family { const BFamily._() @@ -180,7 +176,7 @@ final class BFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( String Function( - BRef ref, + Ref ref, int args, ) create, ) { @@ -199,4 +195,4 @@ final class BFamily extends Family { } } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/packages/riverpod_generator/test/integration/scopes.g.dart b/packages/riverpod_generator/test/integration/scopes.g.dart index fc6837210..a719f7459 100644 --- a/packages/riverpod_generator/test/integration/scopes.g.dart +++ b/packages/riverpod_generator/test/integration/scopes.g.dart @@ -52,7 +52,7 @@ final class ScopedClassProvider extends $NotifierProvider { @override ScopedClassProvider $copyWithBuild( int Function( - Ref, + Ref, ScopedClass, ) build, ) { @@ -133,7 +133,7 @@ final class ScopedClassFamilyProvider @override ScopedClassFamilyProvider $copyWithBuild( int Function( - Ref, + Ref, ScopedClassFamily, ) build, ) { @@ -205,7 +205,7 @@ final class ScopedClassFamilyFamily extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( - int Function(Ref ref, ScopedClassFamily notifier, int argument) build, + int Function(Ref ref, ScopedClassFamily notifier, int argument) build, ) { return $FamilyOverride( from: this, @@ -238,4 +238,4 @@ abstract class _$ScopedClassFamily extends $Notifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/packages/riverpod_generator/test/integration/split.dart b/packages/riverpod_generator/test/integration/split.dart index 543f7e6fc..c5e4755a7 100644 --- a/packages/riverpod_generator/test/integration/split.dart +++ b/packages/riverpod_generator/test/integration/split.dart @@ -1,8 +1,8 @@ -// Regression test for https://github.com/rrousselGit/riverpod/issues/2175 +// Regresion test for https://github.com/rrousselGit/riverpod/issues/2175 import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'split2.dart'; part 'split.g.dart'; @riverpod -int counter2(Counter2Ref ref) => 0; +int counter2(Ref ref) => 0; diff --git a/packages/riverpod_generator/test/integration/split.g.dart b/packages/riverpod_generator/test/integration/split.g.dart index d9b6e97f3..a3eb0f24a 100644 --- a/packages/riverpod_generator/test/integration/split.g.dart +++ b/packages/riverpod_generator/test/integration/split.g.dart @@ -6,16 +6,14 @@ part of 'split.dart'; // RiverpodGenerator // ************************************************************************** -typedef Counter2Ref = Ref; - @ProviderFor(counter2) const counter2Provider = Counter2Provider._(); final class Counter2Provider extends $FunctionalProvider - with $Provider { + with $Provider { const Counter2Provider._( {int Function( - Counter2Ref ref, + Ref ref, )? create}) : _createCb = create, super( @@ -29,7 +27,7 @@ final class Counter2Provider extends $FunctionalProvider ); final int Function( - Counter2Ref ref, + Ref ref, )? _createCb; @override @@ -51,31 +49,29 @@ final class Counter2Provider extends $FunctionalProvider @override Counter2Provider $copyWithCreate( int Function( - Counter2Ref ref, + Ref ref, ) create, ) { return Counter2Provider._(create: create); } @override - int create(Counter2Ref ref) { + int create(Ref ref) { final _$cb = _createCb ?? counter2; return _$cb(ref); } } -String _$counter2Hash() => r'9328919066a683f85226fc59201bb7c54f107a7d'; - -typedef CounterRef = Ref; +String _$counter2Hash() => r'ab7bef7da79217c780c76761a5ae0c0172ca097e'; @ProviderFor(counter) const counterProvider = CounterProvider._(); final class CounterProvider extends $FunctionalProvider - with $Provider { + with $Provider { const CounterProvider._( {int Function( - CounterRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -89,7 +85,7 @@ final class CounterProvider extends $FunctionalProvider ); final int Function( - CounterRef ref, + Ref ref, )? _createCb; @override @@ -111,20 +107,20 @@ final class CounterProvider extends $FunctionalProvider @override CounterProvider $copyWithCreate( int Function( - CounterRef ref, + Ref ref, ) create, ) { return CounterProvider._(create: create); } @override - int create(CounterRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? counter; return _$cb(ref); } } -String _$counterHash() => r'9b0db44ecc47057e79891e5ecd92d34b08637679'; +String _$counterHash() => r'784ece48cb20fcfdec1553774ecfbd381d1e081f'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/packages/riverpod_generator/test/integration/split2.dart b/packages/riverpod_generator/test/integration/split2.dart index 8dc266ec0..2edb0f174 100644 --- a/packages/riverpod_generator/test/integration/split2.dart +++ b/packages/riverpod_generator/test/integration/split2.dart @@ -1,4 +1,4 @@ part of 'split.dart'; @riverpod -int counter(CounterRef ref) => 0; +int counter(Ref ref) => 0; diff --git a/packages/riverpod_generator/test/integration/stream.dart b/packages/riverpod_generator/test/integration/stream.dart index 00f919624..d6454068a 100644 --- a/packages/riverpod_generator/test/integration/stream.dart +++ b/packages/riverpod_generator/test/integration/stream.dart @@ -3,7 +3,7 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'stream.g.dart'; @riverpod -Stream> generic(GenericRef ref) async* { +Stream> generic(Ref ref) async* { yield []; } @@ -16,20 +16,20 @@ class GenericClass extends _$GenericClass { } @riverpod -Stream public(PublicRef ref) { +Stream public(Ref ref) { return Stream.value('Hello world'); } const privateProvider = _privateProvider; @riverpod -Stream _private(_PrivateRef ref) { +Stream _private(Ref ref) { return Stream.value('Hello world'); } @riverpod Stream family( - FamilyRef ref, + Ref ref, int first, { String? second, required double third, diff --git a/packages/riverpod_generator/test/integration/stream.g.dart b/packages/riverpod_generator/test/integration/stream.g.dart index 2d3f0c39e..77864bf8f 100644 --- a/packages/riverpod_generator/test/integration/stream.g.dart +++ b/packages/riverpod_generator/test/integration/stream.g.dart @@ -6,18 +6,16 @@ part of 'stream.dart'; // RiverpodGenerator // ************************************************************************** -typedef GenericRef = Ref>>; - @ProviderFor(generic) const genericProvider = GenericFamily._(); final class GenericProvider extends $FunctionalProvider>, Stream>> - with $FutureModifier>, $StreamProvider, GenericRef> { + with $FutureModifier>, $StreamProvider> { const GenericProvider._( {required GenericFamily super.from, Stream> Function( - GenericRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -30,7 +28,7 @@ final class GenericProvider ); final Stream> Function( - GenericRef ref, + Ref ref, )? _createCb; @override @@ -38,7 +36,7 @@ final class GenericProvider GenericProvider _copyWithCreate( Stream> Function( - GenericRef ref, + Ref ref, ) create, ) { return GenericProvider._( @@ -60,14 +58,14 @@ final class GenericProvider @override GenericProvider $copyWithCreate( Stream> Function( - GenericRef ref, + Ref ref, ) create, ) { return GenericProvider._(from: from! as GenericFamily, create: create); } @override - Stream> create(GenericRef ref) { + Stream> create(Ref ref) { final _$cb = _createCb ?? generic; return _$cb(ref); } @@ -85,7 +83,7 @@ final class GenericProvider } } -String _$genericHash() => r'c1122edf55163d47de8d871ed5d15e0a7edddc05'; +String _$genericHash() => r'eaaf15c08df1aba30b6d6e70d67622d669df977f'; final class GenericFamily extends Family { const GenericFamily._() @@ -107,7 +105,7 @@ final class GenericFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( - Stream> Function(GenericRef ref) create, + Stream> Function(Ref ref) create, ) { return $FamilyOverride( from: this, @@ -153,7 +151,7 @@ final class GenericClassProvider GenericClassProvider _copyWithBuild( Stream> Function( - Ref>>, + Ref, GenericClass, ) build, ) { @@ -185,7 +183,7 @@ final class GenericClassProvider @override GenericClassProvider $copyWithBuild( Stream> Function( - Ref>>, + Ref, GenericClass, ) build, ) { @@ -249,8 +247,7 @@ final class GenericClassFamily extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( - Stream> Function( - Ref>> ref, GenericClass notifier) + Stream> Function(Ref ref, GenericClass notifier) build, ) { return $FamilyOverride( @@ -271,17 +268,15 @@ abstract class _$GenericClass extends $StreamNotifier> { Stream> runBuild() => build(); } -typedef PublicRef = Ref>; - @ProviderFor(public) const publicProvider = PublicProvider._(); final class PublicProvider extends $FunctionalProvider, Stream> - with $FutureModifier, $StreamProvider { + with $FutureModifier, $StreamProvider { const PublicProvider._( {Stream Function( - PublicRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -295,7 +290,7 @@ final class PublicProvider ); final Stream Function( - PublicRef ref, + Ref ref, )? _createCb; @override @@ -309,32 +304,30 @@ final class PublicProvider @override PublicProvider $copyWithCreate( Stream Function( - PublicRef ref, + Ref ref, ) create, ) { return PublicProvider._(create: create); } @override - Stream create(PublicRef ref) { + Stream create(Ref ref) { final _$cb = _createCb ?? public; return _$cb(ref); } } -String _$publicHash() => r'c5cc0eac434371901cf6ab159a81bba49c58da12'; - -typedef _PrivateRef = Ref>; +String _$publicHash() => r'ed93527425175c4a2475e83a3f44223a2aa604d7'; @ProviderFor(_private) const _privateProvider = _PrivateProvider._(); final class _PrivateProvider extends $FunctionalProvider, Stream> - with $FutureModifier, $StreamProvider { + with $FutureModifier, $StreamProvider { const _PrivateProvider._( {Stream Function( - _PrivateRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -348,7 +341,7 @@ final class _PrivateProvider ); final Stream Function( - _PrivateRef ref, + Ref ref, )? _createCb; @override @@ -362,29 +355,27 @@ final class _PrivateProvider @override _PrivateProvider $copyWithCreate( Stream Function( - _PrivateRef ref, + Ref ref, ) create, ) { return _PrivateProvider._(create: create); } @override - Stream create(_PrivateRef ref) { + Stream create(Ref ref) { final _$cb = _createCb ?? _private; return _$cb(ref); } } -String _$privateHash() => r'bbee0c7e27bda81346b5f52c96b23b2e48f83077'; - -typedef FamilyRef = Ref>; +String _$privateHash() => r'7915ccdd16751e7dc6274bb024d1b273d78dc78b'; @ProviderFor(family) const familyProvider = FamilyFamily._(); final class FamilyProvider extends $FunctionalProvider, Stream> - with $FutureModifier, $StreamProvider { + with $FutureModifier, $StreamProvider { const FamilyProvider._( {required FamilyFamily super.from, required ( @@ -396,7 +387,7 @@ final class FamilyProvider }) super.argument, Stream Function( - FamilyRef ref, + Ref ref, int first, { String? second, required double third, @@ -413,7 +404,7 @@ final class FamilyProvider ); final Stream Function( - FamilyRef ref, + Ref ref, int first, { String? second, required double third, @@ -439,7 +430,7 @@ final class FamilyProvider @override FamilyProvider $copyWithCreate( Stream Function( - FamilyRef ref, + Ref ref, ) create, ) { return FamilyProvider._( @@ -463,7 +454,7 @@ final class FamilyProvider } @override - Stream create(FamilyRef ref) { + Stream create(Ref ref) { final _$cb = _createCb ?? family; final argument = this.argument as ( int, { @@ -493,7 +484,7 @@ final class FamilyProvider } } -String _$familyHash() => r'6896fac2f6e3ccd7c38ecaa0d538cbd3577936b2'; +String _$familyHash() => r'ba1df8eab0af0f3f71ae29d23ccb7a491d8e2825'; final class FamilyFamily extends Family { const FamilyFamily._() @@ -529,7 +520,7 @@ final class FamilyFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( Stream Function( - FamilyRef ref, + Ref ref, ( int, { String? second, @@ -599,7 +590,7 @@ final class PublicClassProvider @override PublicClassProvider $copyWithBuild( Stream Function( - Ref>, + Ref, PublicClass, ) build, ) { @@ -661,7 +652,7 @@ final class _PrivateClassProvider @override _PrivateClassProvider $copyWithBuild( Stream Function( - Ref>, + Ref, _PrivateClass, ) build, ) { @@ -747,7 +738,7 @@ final class FamilyClassProvider @override FamilyClassProvider $copyWithBuild( Stream Function( - Ref>, + Ref, FamilyClass, ) build, ) { @@ -848,7 +839,7 @@ final class FamilyClassFamily extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( Stream Function( - Ref> ref, + Ref ref, FamilyClass notifier, ( int, { @@ -913,4 +904,4 @@ abstract class _$FamilyClass extends $StreamNotifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/packages/riverpod_generator/test/integration/sync.dart b/packages/riverpod_generator/test/integration/sync.dart index 20c87bbea..1f0460bfe 100644 --- a/packages/riverpod_generator/test/integration/sync.dart +++ b/packages/riverpod_generator/test/integration/sync.dart @@ -1,10 +1,10 @@ -import 'package:riverpod/riverpod.dart' as r; +import 'package:riverpod/riverpod.dart'; import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'sync.g.dart'; @riverpod -List generic(GenericRef ref) { +List generic(Ref ref) { return [ 'Hello world', 42, @@ -14,7 +14,7 @@ List generic(GenericRef ref) { @riverpod List complexGeneric( - ComplexGenericRef ref, { + Ref ref, { required T param, Foo? otherParam, }) { @@ -31,12 +31,12 @@ class GenericClass extends _$GenericClass } @riverpod -Raw> rawFuture(RawFutureRef ref) async { +Raw> rawFuture(Ref ref) async { return 'Hello world'; } @riverpod -Raw> rawStream(RawStreamRef ref) async* { +Raw> rawStream(Ref ref) async* { yield 'Hello world'; } @@ -57,12 +57,12 @@ class RawStreamClass extends _$RawStreamClass { } @riverpod -Raw> rawFamilyFuture(RawFamilyFutureRef ref, int id) async { +Raw> rawFamilyFuture(Ref ref, int id) async { return 'Hello world'; } @riverpod -Raw> rawFamilyStream(RawFamilyStreamRef ref, int id) async* { +Raw> rawFamilyStream(Ref ref, int id) async* { yield 'Hello world'; } @@ -84,19 +84,19 @@ class RawFamilyStreamClass extends _$RawFamilyStreamClass { /// This is some documentation @riverpod -String public(PublicRef ref) { +String public(Ref ref) { return 'Hello world'; } @riverpod -String supports$inNames(Supports$inNamesRef ref) { +String supports$inNames(Ref ref) { return 'Hello world'; } /// This is some documentation @riverpod String family( - FamilyRef ref, + Ref ref, int first, { String? second, required double third, @@ -109,11 +109,11 @@ String family( const privateProvider = _privateProvider; @riverpod -String _private(_PrivateRef ref) { +String _private(Ref ref) { return 'Hello world'; } -mixin MyMixin on r.NotifierBase {} +mixin MyMixin on NotifierBase {} /// This is some documentation @riverpod @@ -158,7 +158,7 @@ class FamilyClass extends _$FamilyClass with MyMixin { } @riverpod -String supports$InFnName(Supports$InFnNameRef ref) { +String supports$InFnName(Ref ref) { return 'Hello world'; } @@ -166,7 +166,7 @@ const default$value = ''; @riverpod String supports$InFnNameFamily( - Supports$InFnNameFamilyRef ref, + Ref ref, And$InT positional$arg, { required And$InT named$arg, String defaultArg = default$value, @@ -197,11 +197,11 @@ class Supports$InClassFamilyName } @riverpod -String generated(GeneratedRef ref) { +String generated(Ref ref) { return 'Just a simple normal generated provider'; } -r.Provider someProvider() => r.Provider((ref) => 'hello'); +Provider someProvider() => Provider((ref) => 'hello'); // Regression test for https://github.com/rrousselGit/riverpod/issues/2299 final _someProvider = someProvider(); @@ -212,7 +212,7 @@ final _other = _someProvider; // Regression test for now casting `as Object?` when not needed @riverpod -String unnecessaryCast(GeneratedRef ref, Object? arg) { +String unnecessaryCast(Ref ref, Object? arg) { return 'Just a simple normal generated provider'; } @@ -229,6 +229,6 @@ class ManyProviderData {} @riverpod Stream> manyDataStream( - ManyDataStreamRef ref, + Ref ref, ManyProviderData pData, ) async* {} diff --git a/packages/riverpod_generator/test/integration/sync.g.dart b/packages/riverpod_generator/test/integration/sync.g.dart index 00c358cd1..fa219a7a7 100644 --- a/packages/riverpod_generator/test/integration/sync.g.dart +++ b/packages/riverpod_generator/test/integration/sync.g.dart @@ -6,18 +6,15 @@ part of 'sync.dart'; // RiverpodGenerator // ************************************************************************** -typedef GenericRef = Ref>; - @ProviderFor(generic) const genericProvider = GenericFamily._(); final class GenericProvider - extends $FunctionalProvider, List> - with $Provider, GenericRef> { + extends $FunctionalProvider, List> with $Provider> { const GenericProvider._( {required GenericFamily super.from, List Function( - GenericRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -30,7 +27,7 @@ final class GenericProvider ); final List Function( - GenericRef ref, + Ref ref, )? _createCb; @override @@ -38,7 +35,7 @@ final class GenericProvider GenericProvider _copyWithCreate( List Function( - GenericRef ref, + Ref ref, ) create, ) { return GenericProvider._( @@ -68,14 +65,14 @@ final class GenericProvider @override GenericProvider $copyWithCreate( List Function( - GenericRef ref, + Ref ref, ) create, ) { return GenericProvider._(from: from! as GenericFamily, create: create); } @override - List create(GenericRef ref) { + List create(Ref ref) { final _$cb = _createCb ?? generic; return _$cb(ref); } @@ -93,7 +90,7 @@ final class GenericProvider } } -String _$genericHash() => r'0fda19dd377694315cdffd7414d53f98569c655c'; +String _$genericHash() => r'4a2a38e246fc4ef25c46d93477010b66de01ff30'; final class GenericFamily extends Family { const GenericFamily._() @@ -115,7 +112,7 @@ final class GenericFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( - List Function(GenericRef ref) create, + List Function(Ref ref) create, ) { return $FamilyOverride( from: this, @@ -128,14 +125,11 @@ final class GenericFamily extends Family { } } -typedef ComplexGenericRef = Ref>; - @ProviderFor(complexGeneric) const complexGenericProvider = ComplexGenericFamily._(); final class ComplexGenericProvider - extends $FunctionalProvider, List> - with $Provider, ComplexGenericRef> { + extends $FunctionalProvider, List> with $Provider> { const ComplexGenericProvider._( {required ComplexGenericFamily super.from, required ({ @@ -144,7 +138,7 @@ final class ComplexGenericProvider }) super.argument, List Function( - ComplexGenericRef ref, { + Ref ref, { required T param, Foo? otherParam, })? create}) @@ -158,7 +152,7 @@ final class ComplexGenericProvider ); final List Function( - ComplexGenericRef ref, { + Ref ref, { required T param, Foo? otherParam, })? _createCb; @@ -168,7 +162,7 @@ final class ComplexGenericProvider ComplexGenericProvider _copyWithCreate( List Function( - ComplexGenericRef ref, { + Ref ref, { required T param, Foo? otherParam, }) create, @@ -205,7 +199,7 @@ final class ComplexGenericProvider @override ComplexGenericProvider $copyWithCreate( List Function( - ComplexGenericRef ref, + Ref ref, ) create, ) { return ComplexGenericProvider._( @@ -223,7 +217,7 @@ final class ComplexGenericProvider } @override - List create(ComplexGenericRef ref) { + List create(Ref ref) { final _$cb = _createCb ?? complexGeneric; final argument = this.argument as ({ T param, @@ -249,7 +243,7 @@ final class ComplexGenericProvider } } -String _$complexGenericHash() => r'a5254e5552cd61bb8d65c018539ff2d8edfd5822'; +String _$complexGenericHash() => r'bc3433c913396a238e833722a2dc3a78bdf844a4'; final class ComplexGenericFamily extends Family { const ComplexGenericFamily._() @@ -279,7 +273,7 @@ final class ComplexGenericFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( List Function( - ComplexGenericRef ref, + Ref ref, ({ T param, Foo? otherParam, @@ -339,7 +333,7 @@ final class GenericClassProvider GenericClassProvider _copyWithBuild( List Function( - Ref>, + Ref, GenericClass, ) build, ) { @@ -379,7 +373,7 @@ final class GenericClassProvider @override GenericClassProvider $copyWithBuild( List Function( - Ref>, + Ref, GenericClass, ) build, ) { @@ -443,8 +437,7 @@ final class GenericClassFamily extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( - List Function(Ref> ref, GenericClass notifier) - build, + List Function(Ref ref, GenericClass notifier) build, ) { return $FamilyOverride( from: this, @@ -464,17 +457,15 @@ abstract class _$GenericClass extends $Notifier> { List runBuild() => build(); } -typedef RawFutureRef = Ref>>; - @ProviderFor(rawFuture) const rawFutureProvider = RawFutureProvider._(); final class RawFutureProvider extends $FunctionalProvider>, Raw>> - with $Provider>, RawFutureRef> { + with $Provider>> { const RawFutureProvider._( {Raw> Function( - RawFutureRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -488,7 +479,7 @@ final class RawFutureProvider ); final Raw> Function( - RawFutureRef ref, + Ref ref, )? _createCb; @override @@ -511,32 +502,30 @@ final class RawFutureProvider @override RawFutureProvider $copyWithCreate( Raw> Function( - RawFutureRef ref, + Ref ref, ) create, ) { return RawFutureProvider._(create: create); } @override - Raw> create(RawFutureRef ref) { + Raw> create(Ref ref) { final _$cb = _createCb ?? rawFuture; return _$cb(ref); } } -String _$rawFutureHash() => r'5203a56065b768023770326281618e3229ccb530'; - -typedef RawStreamRef = Ref>>; +String _$rawFutureHash() => r'9d397f4c0a578a2741610f9ca6f17438ee8e5a34'; @ProviderFor(rawStream) const rawStreamProvider = RawStreamProvider._(); final class RawStreamProvider extends $FunctionalProvider>, Raw>> - with $Provider>, RawStreamRef> { + with $Provider>> { const RawStreamProvider._( {Raw> Function( - RawStreamRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -550,7 +539,7 @@ final class RawStreamProvider ); final Raw> Function( - RawStreamRef ref, + Ref ref, )? _createCb; @override @@ -573,20 +562,20 @@ final class RawStreamProvider @override RawStreamProvider $copyWithCreate( Raw> Function( - RawStreamRef ref, + Ref ref, ) create, ) { return RawStreamProvider._(create: create); } @override - Raw> create(RawStreamRef ref) { + Raw> create(Ref ref) { final _$cb = _createCb ?? rawStream; return _$cb(ref); } } -String _$rawStreamHash() => r'2b764189753a8b74f47ba557a79416f00ef5cebd'; +String _$rawStreamHash() => r'c7d6cd22f1f325827c866c3ec757d08315fd9858'; @ProviderFor(RawFutureClass) const rawFutureClassProvider = RawFutureClassProvider._(); @@ -635,7 +624,7 @@ final class RawFutureClassProvider @override RawFutureClassProvider $copyWithBuild( Raw> Function( - Ref>>, + Ref, RawFutureClass, ) build, ) { @@ -705,7 +694,7 @@ final class RawStreamClassProvider @override RawStreamClassProvider $copyWithBuild( Raw> Function( - Ref>>, + Ref, RawStreamClass, ) build, ) { @@ -728,19 +717,17 @@ abstract class _$RawStreamClass extends $Notifier>> { Raw> runBuild() => build(); } -typedef RawFamilyFutureRef = Ref>>; - @ProviderFor(rawFamilyFuture) const rawFamilyFutureProvider = RawFamilyFutureFamily._(); final class RawFamilyFutureProvider extends $FunctionalProvider>, Raw>> - with $Provider>, RawFamilyFutureRef> { + with $Provider>> { const RawFamilyFutureProvider._( {required RawFamilyFutureFamily super.from, required int super.argument, Raw> Function( - RawFamilyFutureRef ref, + Ref ref, int id, )? create}) : _createCb = create, @@ -753,7 +740,7 @@ final class RawFamilyFutureProvider ); final Raw> Function( - RawFamilyFutureRef ref, + Ref ref, int id, )? _createCb; @@ -784,7 +771,7 @@ final class RawFamilyFutureProvider @override RawFamilyFutureProvider $copyWithCreate( Raw> Function( - RawFamilyFutureRef ref, + Ref ref, ) create, ) { return RawFamilyFutureProvider._( @@ -798,7 +785,7 @@ final class RawFamilyFutureProvider } @override - Raw> create(RawFamilyFutureRef ref) { + Raw> create(Ref ref) { final _$cb = _createCb ?? rawFamilyFuture; final argument = this.argument as int; return _$cb( @@ -818,7 +805,7 @@ final class RawFamilyFutureProvider } } -String _$rawFamilyFutureHash() => r'485f59512081852e51279658facc015309743864'; +String _$rawFamilyFutureHash() => r'0ac70d7a2133691f1a9a38cedaeeb6b3bc667ade'; final class RawFamilyFutureFamily extends Family { const RawFamilyFutureFamily._() @@ -844,7 +831,7 @@ final class RawFamilyFutureFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( Raw> Function( - RawFamilyFutureRef ref, + Ref ref, int args, ) create, ) { @@ -863,19 +850,17 @@ final class RawFamilyFutureFamily extends Family { } } -typedef RawFamilyStreamRef = Ref>>; - @ProviderFor(rawFamilyStream) const rawFamilyStreamProvider = RawFamilyStreamFamily._(); final class RawFamilyStreamProvider extends $FunctionalProvider>, Raw>> - with $Provider>, RawFamilyStreamRef> { + with $Provider>> { const RawFamilyStreamProvider._( {required RawFamilyStreamFamily super.from, required int super.argument, Raw> Function( - RawFamilyStreamRef ref, + Ref ref, int id, )? create}) : _createCb = create, @@ -888,7 +873,7 @@ final class RawFamilyStreamProvider ); final Raw> Function( - RawFamilyStreamRef ref, + Ref ref, int id, )? _createCb; @@ -919,7 +904,7 @@ final class RawFamilyStreamProvider @override RawFamilyStreamProvider $copyWithCreate( Raw> Function( - RawFamilyStreamRef ref, + Ref ref, ) create, ) { return RawFamilyStreamProvider._( @@ -933,7 +918,7 @@ final class RawFamilyStreamProvider } @override - Raw> create(RawFamilyStreamRef ref) { + Raw> create(Ref ref) { final _$cb = _createCb ?? rawFamilyStream; final argument = this.argument as int; return _$cb( @@ -953,7 +938,7 @@ final class RawFamilyStreamProvider } } -String _$rawFamilyStreamHash() => r'e778e5cfcb8ab381e2412f5c73213aaa03b93012'; +String _$rawFamilyStreamHash() => r'6eacfa3a3576d884099c08c298751a3d395271be'; final class RawFamilyStreamFamily extends Family { const RawFamilyStreamFamily._() @@ -979,7 +964,7 @@ final class RawFamilyStreamFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( Raw> Function( - RawFamilyStreamRef ref, + Ref ref, int args, ) create, ) { @@ -1056,7 +1041,7 @@ final class RawFamilyFutureClassProvider @override RawFamilyFutureClassProvider $copyWithBuild( Raw> Function( - Ref>>, + Ref, RawFamilyFutureClass, ) build, ) { @@ -1129,8 +1114,8 @@ final class RawFamilyFutureClassFamily extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( - Raw> Function(Ref>> ref, - RawFamilyFutureClass notifier, int argument) + Raw> Function( + Ref ref, RawFamilyFutureClass notifier, int argument) build, ) { return $FamilyOverride( @@ -1220,7 +1205,7 @@ final class RawFamilyStreamClassProvider @override RawFamilyStreamClassProvider $copyWithBuild( Raw> Function( - Ref>>, + Ref, RawFamilyStreamClass, ) build, ) { @@ -1293,8 +1278,8 @@ final class RawFamilyStreamClassFamily extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( - Raw> Function(Ref>> ref, - RawFamilyStreamClass notifier, int argument) + Raw> Function( + Ref ref, RawFamilyStreamClass notifier, int argument) build, ) { return $FamilyOverride( @@ -1326,20 +1311,17 @@ abstract class _$RawFamilyStreamClass extends $Notifier>> { ); } -/// This is some documentation -typedef PublicRef = Ref; - /// This is some documentation @ProviderFor(public) const publicProvider = PublicProvider._(); /// This is some documentation final class PublicProvider extends $FunctionalProvider - with $Provider { + with $Provider { /// This is some documentation const PublicProvider._( {String Function( - PublicRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -1353,7 +1335,7 @@ final class PublicProvider extends $FunctionalProvider ); final String Function( - PublicRef ref, + Ref ref, )? _createCb; @override @@ -1375,31 +1357,29 @@ final class PublicProvider extends $FunctionalProvider @override PublicProvider $copyWithCreate( String Function( - PublicRef ref, + Ref ref, ) create, ) { return PublicProvider._(create: create); } @override - String create(PublicRef ref) { + String create(Ref ref) { final _$cb = _createCb ?? public; return _$cb(ref); } } -String _$publicHash() => r'138be35943899793ab085e711fe3f3d22696a3ba'; - -typedef Supports$inNamesRef = Ref; +String _$publicHash() => r'94bee36125844f9fe521363bb228632b9f3bfbc7'; @ProviderFor(supports$inNames) const supports$inNamesProvider = Supports$inNamesProvider._(); final class Supports$inNamesProvider extends $FunctionalProvider - with $Provider { + with $Provider { const Supports$inNamesProvider._( {String Function( - Supports$inNamesRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -1413,7 +1393,7 @@ final class Supports$inNamesProvider extends $FunctionalProvider ); final String Function( - Supports$inNamesRef ref, + Ref ref, )? _createCb; @override @@ -1435,23 +1415,20 @@ final class Supports$inNamesProvider extends $FunctionalProvider @override Supports$inNamesProvider $copyWithCreate( String Function( - Supports$inNamesRef ref, + Ref ref, ) create, ) { return Supports$inNamesProvider._(create: create); } @override - String create(Supports$inNamesRef ref) { + String create(Ref ref) { final _$cb = _createCb ?? supports$inNames; return _$cb(ref); } } -String _$supports$inNamesHash() => r'cbf929802fcbd0aa949ad72743d096fb3ef5f28f'; - -/// This is some documentation -typedef FamilyRef = Ref; +String _$supports$inNamesHash() => r'8da1f9329f302ce75e38d03c96595de3260b4d2d'; /// This is some documentation @ProviderFor(family) @@ -1459,7 +1436,7 @@ const familyProvider = FamilyFamily._(); /// This is some documentation final class FamilyProvider extends $FunctionalProvider - with $Provider { + with $Provider { /// This is some documentation const FamilyProvider._( {required FamilyFamily super.from, @@ -1472,7 +1449,7 @@ final class FamilyProvider extends $FunctionalProvider }) super.argument, String Function( - FamilyRef ref, + Ref ref, int first, { String? second, required double third, @@ -1489,7 +1466,7 @@ final class FamilyProvider extends $FunctionalProvider ); final String Function( - FamilyRef ref, + Ref ref, int first, { String? second, required double third, @@ -1523,7 +1500,7 @@ final class FamilyProvider extends $FunctionalProvider @override FamilyProvider $copyWithCreate( String Function( - FamilyRef ref, + Ref ref, ) create, ) { return FamilyProvider._( @@ -1547,7 +1524,7 @@ final class FamilyProvider extends $FunctionalProvider } @override - String create(FamilyRef ref) { + String create(Ref ref) { final _$cb = _createCb ?? family; final argument = this.argument as ( int, { @@ -1577,7 +1554,7 @@ final class FamilyProvider extends $FunctionalProvider } } -String _$familyHash() => r'14d1ee238ca608d547630d0e222ef4c5866e9e61'; +String _$familyHash() => r'f58149448f80f10ec054f2f8a6f37bae61e38f49'; /// This is some documentation final class FamilyFamily extends Family { @@ -1615,7 +1592,7 @@ final class FamilyFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( String Function( - FamilyRef ref, + Ref ref, ( int, { String? second, @@ -1646,16 +1623,14 @@ final class FamilyFamily extends Family { } } -typedef _PrivateRef = Ref; - @ProviderFor(_private) const _privateProvider = _PrivateProvider._(); final class _PrivateProvider extends $FunctionalProvider - with $Provider { + with $Provider { const _PrivateProvider._( {String Function( - _PrivateRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -1669,7 +1644,7 @@ final class _PrivateProvider extends $FunctionalProvider ); final String Function( - _PrivateRef ref, + Ref ref, )? _createCb; @override @@ -1691,20 +1666,20 @@ final class _PrivateProvider extends $FunctionalProvider @override _PrivateProvider $copyWithCreate( String Function( - _PrivateRef ref, + Ref ref, ) create, ) { return _PrivateProvider._(create: create); } @override - String create(_PrivateRef ref) { + String create(Ref ref) { final _$cb = _createCb ?? _private; return _$cb(ref); } } -String _$privateHash() => r'519561bc7e88e394d7f75ca2102a5c0acc832c66'; +String _$privateHash() => r'834affaed42662bf46ce7f6203ac2495e1e8974b'; /// This is some documentation @ProviderFor(PublicClass) @@ -1755,7 +1730,7 @@ final class PublicClassProvider extends $NotifierProvider { @override PublicClassProvider $copyWithBuild( String Function( - Ref, + Ref, PublicClass, ) build, ) { @@ -1825,7 +1800,7 @@ final class _PrivateClassProvider @override _PrivateClassProvider $copyWithBuild( String Function( - Ref, + Ref, _PrivateClass, ) build, ) { @@ -1921,7 +1896,7 @@ final class FamilyClassProvider extends $NotifierProvider { @override FamilyClassProvider $copyWithBuild( String Function( - Ref, + Ref, FamilyClass, ) build, ) { @@ -2024,7 +1999,7 @@ final class FamilyClassFamily extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( String Function( - Ref ref, + Ref ref, FamilyClass notifier, ( int, { @@ -2088,18 +2063,15 @@ abstract class _$FamilyClass extends $Notifier { ); } -typedef Supports$InFnNameRef = Ref; - @ProviderFor(supports$InFnName) const supports$InFnNameProvider = Supports$InFnNameFamily._(); final class Supports$InFnNameProvider - extends $FunctionalProvider - with $Provider> { + extends $FunctionalProvider with $Provider { const Supports$InFnNameProvider._( {required Supports$InFnNameFamily super.from, String Function( - Supports$InFnNameRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -2112,7 +2084,7 @@ final class Supports$InFnNameProvider ); final String Function( - Supports$InFnNameRef ref, + Ref ref, )? _createCb; @override @@ -2120,7 +2092,7 @@ final class Supports$InFnNameProvider Supports$InFnNameProvider _copyWithCreate( String Function( - Supports$InFnNameRef ref, + Ref ref, ) create, ) { return Supports$InFnNameProvider._( @@ -2150,7 +2122,7 @@ final class Supports$InFnNameProvider @override Supports$InFnNameProvider $copyWithCreate( String Function( - Supports$InFnNameRef ref, + Ref ref, ) create, ) { return Supports$InFnNameProvider._( @@ -2158,7 +2130,7 @@ final class Supports$InFnNameProvider } @override - String create(Supports$InFnNameRef ref) { + String create(Ref ref) { final _$cb = _createCb ?? supports$InFnName; return _$cb(ref); } @@ -2176,7 +2148,7 @@ final class Supports$InFnNameProvider } } -String _$supports$InFnNameHash() => r'fec3daca655669a46760cc54921f098b9cbaac3d'; +String _$supports$InFnNameHash() => r'09636911da6a98293c260aad55b89bea5296136b'; final class Supports$InFnNameFamily extends Family { const Supports$InFnNameFamily._() @@ -2199,7 +2171,7 @@ final class Supports$InFnNameFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( - String Function(Supports$InFnNameRef ref) create, + String Function(Ref ref) create, ) { return $FamilyOverride( from: this, @@ -2212,14 +2184,11 @@ final class Supports$InFnNameFamily extends Family { } } -typedef Supports$InFnNameFamilyRef = Ref; - @ProviderFor(supports$InFnNameFamily) const supports$InFnNameFamilyProvider = Supports$InFnNameFamilyFamily._(); final class Supports$InFnNameFamilyProvider - extends $FunctionalProvider - with $Provider> { + extends $FunctionalProvider with $Provider { const Supports$InFnNameFamilyProvider._( {required Supports$InFnNameFamilyFamily super.from, required ( @@ -2229,7 +2198,7 @@ final class Supports$InFnNameFamilyProvider }) super.argument, String Function( - Supports$InFnNameFamilyRef ref, + Ref ref, And$InT positional$arg, { required And$InT named$arg, String defaultArg, @@ -2244,7 +2213,7 @@ final class Supports$InFnNameFamilyProvider ); final String Function( - Supports$InFnNameFamilyRef ref, + Ref ref, And$InT positional$arg, { required And$InT named$arg, String defaultArg, @@ -2255,7 +2224,7 @@ final class Supports$InFnNameFamilyProvider Supports$InFnNameFamilyProvider _copyWithCreate( String Function( - Supports$InFnNameFamilyRef ref, + Ref ref, And$InT positional$arg, { required And$InT named$arg, String defaultArg, @@ -2294,7 +2263,7 @@ final class Supports$InFnNameFamilyProvider @override Supports$InFnNameFamilyProvider $copyWithCreate( String Function( - Supports$InFnNameFamilyRef ref, + Ref ref, ) create, ) { return Supports$InFnNameFamilyProvider._( @@ -2314,7 +2283,7 @@ final class Supports$InFnNameFamilyProvider } @override - String create(Supports$InFnNameFamilyRef ref) { + String create(Ref ref) { final _$cb = _createCb ?? supports$InFnNameFamily; final argument = this.argument as ( And$InT, { @@ -2343,7 +2312,7 @@ final class Supports$InFnNameFamilyProvider } String _$supports$InFnNameFamilyHash() => - r'1daa434fa2ad9ff37deade29ba3ca8155833df1b'; + r'3124634e8535d4db655d6384b0827f0f195a75ef'; final class Supports$InFnNameFamilyFamily extends Family { const Supports$InFnNameFamilyFamily._() @@ -2375,7 +2344,7 @@ final class Supports$InFnNameFamilyFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( String Function( - Supports$InFnNameFamilyRef ref, + Ref ref, ( And$InT, { And$InT named$arg, @@ -2438,7 +2407,7 @@ final class Supports$InClassNameProvider Supports$InClassNameProvider _copyWithBuild( String Function( - Ref, + Ref, Supports$InClassName, ) build, ) { @@ -2480,7 +2449,7 @@ final class Supports$InClassNameProvider @override Supports$InClassNameProvider $copyWithBuild( String Function( - Ref, + Ref, Supports$InClassName, ) build, ) { @@ -2546,8 +2515,7 @@ final class Supports$InClassNameFamily extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( - String Function( - Ref ref, Supports$InClassName notifier) + String Function(Ref ref, Supports$InClassName notifier) build, ) { return $FamilyOverride( @@ -2612,7 +2580,7 @@ final class Supports$InClassFamilyNameProvider Supports$InClassFamilyNameProvider _copyWithBuild( String Function( - Ref, + Ref, Supports$InClassFamilyName, ) build, ) { @@ -2665,7 +2633,7 @@ final class Supports$InClassFamilyNameProvider @override Supports$InClassFamilyNameProvider $copyWithBuild( String Function( - Ref, + Ref, Supports$InClassFamilyName, ) build, ) { @@ -2759,7 +2727,7 @@ final class Supports$InClassFamilyNameFamily extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( String Function( - Ref ref, + Ref ref, Supports$InClassFamilyName notifier, ( And$InT, { @@ -2811,16 +2779,14 @@ abstract class _$Supports$InClassFamilyName extends $Notifier { ); } -typedef GeneratedRef = Ref; - @ProviderFor(generated) const generatedProvider = GeneratedProvider._(); final class GeneratedProvider extends $FunctionalProvider - with $Provider { + with $Provider { const GeneratedProvider._( {String Function( - GeneratedRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -2834,7 +2800,7 @@ final class GeneratedProvider extends $FunctionalProvider ); final String Function( - GeneratedRef ref, + Ref ref, )? _createCb; @override @@ -2856,33 +2822,31 @@ final class GeneratedProvider extends $FunctionalProvider @override GeneratedProvider $copyWithCreate( String Function( - GeneratedRef ref, + Ref ref, ) create, ) { return GeneratedProvider._(create: create); } @override - String create(GeneratedRef ref) { + String create(Ref ref) { final _$cb = _createCb ?? generated; return _$cb(ref); } } -String _$generatedHash() => r'fecbc1d5d9a05fc996b452a57fd1975ff368af91'; - -typedef UnnecessaryCastRef = Ref; +String _$generatedHash() => r'24bfb5df4dc529258ab568372e90a1cbfc2d8c24'; @ProviderFor(unnecessaryCast) const unnecessaryCastProvider = UnnecessaryCastFamily._(); final class UnnecessaryCastProvider extends $FunctionalProvider - with $Provider { + with $Provider { const UnnecessaryCastProvider._( {required UnnecessaryCastFamily super.from, required Object? super.argument, String Function( - UnnecessaryCastRef ref, + Ref ref, Object? arg, )? create}) : _createCb = create, @@ -2895,7 +2859,7 @@ final class UnnecessaryCastProvider extends $FunctionalProvider ); final String Function( - UnnecessaryCastRef ref, + Ref ref, Object? arg, )? _createCb; @@ -2925,7 +2889,7 @@ final class UnnecessaryCastProvider extends $FunctionalProvider @override UnnecessaryCastProvider $copyWithCreate( String Function( - UnnecessaryCastRef ref, + Ref ref, ) create, ) { return UnnecessaryCastProvider._( @@ -2939,7 +2903,7 @@ final class UnnecessaryCastProvider extends $FunctionalProvider } @override - String create(UnnecessaryCastRef ref) { + String create(Ref ref) { final _$cb = _createCb ?? unnecessaryCast; final argument = this.argument; return _$cb( @@ -2959,7 +2923,7 @@ final class UnnecessaryCastProvider extends $FunctionalProvider } } -String _$unnecessaryCastHash() => r'282c11ef4f55267c3e6ed70af1a260cd1c2163e6'; +String _$unnecessaryCastHash() => r'c64330124f4b03a3e6757e787f62966a32bf83ad'; final class UnnecessaryCastFamily extends Family { const UnnecessaryCastFamily._() @@ -2985,7 +2949,7 @@ final class UnnecessaryCastFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( String Function( - UnnecessaryCastRef ref, + Ref ref, Object? args, ) create, ) { @@ -3062,7 +3026,7 @@ final class UnnecessaryCastClassProvider @override UnnecessaryCastClassProvider $copyWithBuild( String Function( - Ref, + Ref, UnnecessaryCastClass, ) build, ) { @@ -3135,8 +3099,7 @@ final class UnnecessaryCastClassFamily extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( - String Function( - Ref ref, UnnecessaryCastClass notifier, Object? argument) + String Function(Ref ref, UnnecessaryCastClass notifier, Object? argument) build, ) { return $FamilyOverride( @@ -3168,22 +3131,17 @@ abstract class _$UnnecessaryCastClass extends $Notifier { ); } -typedef ManyDataStreamRef - = Ref>>; - @ProviderFor(manyDataStream) const manyDataStreamProvider = ManyDataStreamFamily._(); final class ManyDataStreamProvider extends $FunctionalProvider>, Stream>> - with - $FutureModifier>, - $StreamProvider, ManyDataStreamRef> { + with $FutureModifier>, $StreamProvider> { const ManyDataStreamProvider._( {required ManyDataStreamFamily super.from, required ManyProviderData super.argument, Stream> Function( - ManyDataStreamRef ref, + Ref ref, ManyProviderData pData, )? create}) : _createCb = create, @@ -3196,7 +3154,7 @@ final class ManyDataStreamProvider ); final Stream> Function( - ManyDataStreamRef ref, + Ref ref, ManyProviderData pData, )? _createCb; @@ -3205,7 +3163,7 @@ final class ManyDataStreamProvider ManyDataStreamProvider _copyWithCreate( Stream> Function( - ManyDataStreamRef ref, + Ref ref, ManyProviderData pData, ) create, ) { @@ -3230,7 +3188,7 @@ final class ManyDataStreamProvider @override ManyDataStreamProvider $copyWithCreate( Stream> Function( - ManyDataStreamRef ref, + Ref ref, ) create, ) { return ManyDataStreamProvider._( @@ -3244,7 +3202,7 @@ final class ManyDataStreamProvider } @override - Stream> create(ManyDataStreamRef ref) { + Stream> create(Ref ref) { final _$cb = _createCb ?? manyDataStream; final argument = this.argument as ManyProviderData; return _$cb( @@ -3266,7 +3224,7 @@ final class ManyDataStreamProvider } } -String _$manyDataStreamHash() => r'965270e9e187c17b8c78c03ded79136a4073ff04'; +String _$manyDataStreamHash() => r'5f389757cba176868a47b89b14b1f96afe20d728'; final class ManyDataStreamFamily extends Family { const ManyDataStreamFamily._() @@ -3292,7 +3250,7 @@ final class ManyDataStreamFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( Stream> Function( - ManyDataStreamRef ref, + Ref ref, ManyProviderData args, ) create, ) { @@ -3312,4 +3270,4 @@ final class ManyDataStreamFamily extends Family { } } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/packages/riverpod_generator/test/stream_test.dart b/packages/riverpod_generator/test/stream_test.dart index c6d1f1e20..729ccc569 100644 --- a/packages/riverpod_generator/test/stream_test.dart +++ b/packages/riverpod_generator/test/stream_test.dart @@ -127,30 +127,34 @@ void main() { ); }); - test('can overrideWith', () { + test('can overrideWith', () async { final container = ProviderContainer.test( overrides: [ - publicProvider.overrideWith((ref) { - ref.state = const AsyncData('test'); - return const Stream.empty(); - }), + publicProvider.overrideWith((ref) => Stream.value('test')), publicClassProvider.overrideWith(() => PublicClass(42)), familyProvider.overrideWith( (ref, args) { - ref.state = AsyncData( + return Stream.value( 'test (first: ${args.$1}, second: ${args.second}, third: ${args.third}, fourth: ${args.fourth}, fifth: ${args.fifth})', ); - return const Stream.empty(); }, ), familyClassProvider.overrideWith(FamilyClass.new), ], ); - expect(container.read(publicProvider).requireValue, 'test'); + expect( + await container.listen(publicProvider.future, (a, b) {}).read(), + 'test', + ); expect(container.read(publicClassProvider.notifier).param, 42); expect( - container.read(familyProvider(42, second: '42', third: .42)).requireValue, + await container + .listen( + familyProvider(42, second: '42', third: .42).future, + (a, b) {}, + ) + .read(), 'test (first: 42, second: 42, third: 0.42, fourth: true, fifth: null)', ); expect( diff --git a/packages/riverpod_graph/lib/src/analyze.dart b/packages/riverpod_graph/lib/src/analyze.dart index b65d298e7..85ccd68b2 100644 --- a/packages/riverpod_graph/lib/src/analyze.dart +++ b/packages/riverpod_graph/lib/src/analyze.dart @@ -683,7 +683,10 @@ class _ProviderName { /// Returns the name of the provider. _ProviderName _displayNameForProvider(VariableElement provider) { final providerName = provider.name; - final enclosingElementName = provider.enclosingElement3?.displayName; + final enclosingElementName = provider + // ignore: deprecated_member_use, necessary to support older versions of analyzer + .enclosingElement + ?.displayName; return _ProviderName( providerName: providerName, enclosingElementName: enclosingElementName ?? '', diff --git a/packages/riverpod_graph/pubspec.yaml b/packages/riverpod_graph/pubspec.yaml index def4dcf16..609a75006 100644 --- a/packages/riverpod_graph/pubspec.yaml +++ b/packages/riverpod_graph/pubspec.yaml @@ -11,7 +11,7 @@ environment: sdk: ">=3.0.0<4.0.0" dependencies: - analyzer: "6.9.0" + analyzer: ^6.7.0 args: ^2.4.0 collection: ^1.0.0 path: ^1.8.2 diff --git a/packages/riverpod_graph/test/integration/addition/golden/lib/constructor_providers.dart b/packages/riverpod_graph/test/integration/addition/golden/lib/constructor_providers.dart index e77743866..c6988e5f2 100644 --- a/packages/riverpod_graph/test/integration/addition/golden/lib/constructor_providers.dart +++ b/packages/riverpod_graph/test/integration/addition/golden/lib/constructor_providers.dart @@ -17,7 +17,7 @@ class MarvelRepository { }) : _getCurrentTimestamp = getCurrentTimestamp ?? (() => DateTime.now().millisecondsSinceEpoch); - final Ref ref; + final Ref ref; final int Function() _getCurrentTimestamp; } diff --git a/packages/riverpod_graph/test/integration/generated/golden/lib/sync.dart b/packages/riverpod_graph/test/integration/generated/golden/lib/sync.dart index df024ab3f..228a0eff2 100644 --- a/packages/riverpod_graph/test/integration/generated/golden/lib/sync.dart +++ b/packages/riverpod_graph/test/integration/generated/golden/lib/sync.dart @@ -4,20 +4,20 @@ part 'sync.g.dart'; /// A public generated provider. @riverpod -String public(PublicRef ref) { +String public(Ref ref) { return 'Hello world'; } /// A generated provider with a '$' in its name. @riverpod -String supports$inNames(Supports$inNamesRef ref) { +String supports$inNames(Ref ref) { return ref.watch(publicProvider); } /// A generated family provider. @riverpod String family( - FamilyRef ref, + Ref ref, int first, { String? second, required double third, @@ -32,7 +32,7 @@ String family( const privateProvider = _privateProvider; @riverpod -String _private(_PrivateRef ref) { +String _private(Ref ref) { return ref.watch(publicProvider); } diff --git a/packages/riverpod_graph/test/integration/generated/golden/lib/sync.g.dart b/packages/riverpod_graph/test/integration/generated/golden/lib/sync.g.dart index caa66850a..5eff2951a 100644 --- a/packages/riverpod_graph/test/integration/generated/golden/lib/sync.g.dart +++ b/packages/riverpod_graph/test/integration/generated/golden/lib/sync.g.dart @@ -6,20 +6,17 @@ part of 'sync.dart'; // RiverpodGenerator // ************************************************************************** -/// A public generated provider. -typedef PublicRef = Ref; - /// A public generated provider. @ProviderFor(public) const publicProvider = PublicProvider._(); /// A public generated provider. final class PublicProvider extends $FunctionalProvider - with $Provider { + with $Provider { /// A public generated provider. const PublicProvider._( {String Function( - PublicRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -33,7 +30,7 @@ final class PublicProvider extends $FunctionalProvider ); final String Function( - PublicRef ref, + Ref ref, )? _createCb; @override @@ -55,23 +52,20 @@ final class PublicProvider extends $FunctionalProvider @override PublicProvider $copyWithCreate( String Function( - PublicRef ref, + Ref ref, ) create, ) { return PublicProvider._(create: create); } @override - String create(PublicRef ref) { + String create(Ref ref) { final _$cb = _createCb ?? public; return _$cb(ref); } } -String _$publicHash() => r'138be35943899793ab085e711fe3f3d22696a3ba'; - -/// A generated provider with a '$' in its name. -typedef Supports$inNamesRef = Ref; +String _$publicHash() => r'94bee36125844f9fe521363bb228632b9f3bfbc7'; /// A generated provider with a '$' in its name. @ProviderFor(supports$inNames) @@ -79,11 +73,11 @@ const supports$inNamesProvider = Supports$inNamesProvider._(); /// A generated provider with a '$' in its name. final class Supports$inNamesProvider extends $FunctionalProvider - with $Provider { + with $Provider { /// A generated provider with a '$' in its name. const Supports$inNamesProvider._( {String Function( - Supports$inNamesRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -97,7 +91,7 @@ final class Supports$inNamesProvider extends $FunctionalProvider ); final String Function( - Supports$inNamesRef ref, + Ref ref, )? _createCb; @override @@ -119,23 +113,20 @@ final class Supports$inNamesProvider extends $FunctionalProvider @override Supports$inNamesProvider $copyWithCreate( String Function( - Supports$inNamesRef ref, + Ref ref, ) create, ) { return Supports$inNamesProvider._(create: create); } @override - String create(Supports$inNamesRef ref) { + String create(Ref ref) { final _$cb = _createCb ?? supports$inNames; return _$cb(ref); } } -String _$supports$inNamesHash() => r'baacdb7b92917860b02aba1fa7010c7056da4a67'; - -/// A generated family provider. -typedef FamilyRef = Ref; +String _$supports$inNamesHash() => r'a883450ddca90a227631fe54d1d9ae305bc558d9'; /// A generated family provider. @ProviderFor(family) @@ -143,7 +134,7 @@ const familyProvider = FamilyFamily._(); /// A generated family provider. final class FamilyProvider extends $FunctionalProvider - with $Provider { + with $Provider { /// A generated family provider. const FamilyProvider._( {required FamilyFamily super.from, @@ -156,7 +147,7 @@ final class FamilyProvider extends $FunctionalProvider }) super.argument, String Function( - FamilyRef ref, + Ref ref, int first, { String? second, required double third, @@ -173,7 +164,7 @@ final class FamilyProvider extends $FunctionalProvider ); final String Function( - FamilyRef ref, + Ref ref, int first, { String? second, required double third, @@ -207,7 +198,7 @@ final class FamilyProvider extends $FunctionalProvider @override FamilyProvider $copyWithCreate( String Function( - FamilyRef ref, + Ref ref, ) create, ) { return FamilyProvider._( @@ -231,7 +222,7 @@ final class FamilyProvider extends $FunctionalProvider } @override - String create(FamilyRef ref) { + String create(Ref ref) { final _$cb = _createCb ?? family; final argument = this.argument as ( int, { @@ -261,7 +252,7 @@ final class FamilyProvider extends $FunctionalProvider } } -String _$familyHash() => r'ebf082969854dcc358b9870a2e5e9b922423e59b'; +String _$familyHash() => r'062561e0cad8585939dc9adc23de6452be2c9788'; /// A generated family provider. final class FamilyFamily extends Family { @@ -299,7 +290,7 @@ final class FamilyFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( String Function( - FamilyRef ref, + Ref ref, ( int, { String? second, @@ -330,16 +321,14 @@ final class FamilyFamily extends Family { } } -typedef _PrivateRef = Ref; - @ProviderFor(_private) const _privateProvider = _PrivateProvider._(); final class _PrivateProvider extends $FunctionalProvider - with $Provider { + with $Provider { const _PrivateProvider._( {String Function( - _PrivateRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -353,7 +342,7 @@ final class _PrivateProvider extends $FunctionalProvider ); final String Function( - _PrivateRef ref, + Ref ref, )? _createCb; @override @@ -375,20 +364,20 @@ final class _PrivateProvider extends $FunctionalProvider @override _PrivateProvider $copyWithCreate( String Function( - _PrivateRef ref, + Ref ref, ) create, ) { return _PrivateProvider._(create: create); } @override - String create(_PrivateRef ref) { + String create(Ref ref) { final _$cb = _createCb ?? _private; return _$cb(ref); } } -String _$privateHash() => r'9a87ed0765ad8448525fa1290b34760c79e7402b'; +String _$privateHash() => r'4f7b825ffa8a674f01dc8453cb480060a6a7bf5f'; /// A generated public provider from a class @ProviderFor(PublicClass) @@ -439,7 +428,7 @@ final class PublicClassProvider extends $NotifierProvider { @override PublicClassProvider $copyWithBuild( String Function( - Ref, + Ref, PublicClass, ) build, ) { @@ -509,7 +498,7 @@ final class _PrivateClassProvider @override _PrivateClassProvider $copyWithBuild( String Function( - Ref, + Ref, _PrivateClass, ) build, ) { @@ -605,7 +594,7 @@ final class FamilyClassProvider extends $NotifierProvider { @override FamilyClassProvider $copyWithBuild( String Function( - Ref, + Ref, FamilyClass, ) build, ) { @@ -708,7 +697,7 @@ final class FamilyClassFamily extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( String Function( - Ref ref, + Ref ref, FamilyClass notifier, ( int, { @@ -822,7 +811,7 @@ final class Supports$InClassNameProvider @override Supports$InClassNameProvider $copyWithBuild( String Function( - Ref, + Ref, Supports$InClassName, ) build, ) { @@ -847,4 +836,4 @@ abstract class _$Supports$InClassName extends $Notifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/packages/riverpod_lint/CHANGELOG.md b/packages/riverpod_lint/CHANGELOG.md index c9002713f..9fa55e203 100644 --- a/packages/riverpod_lint/CHANGELOG.md +++ b/packages/riverpod_lint/CHANGELOG.md @@ -42,7 +42,24 @@ Various lints had their severity changed: - `riverpod` upgraded to `3.0.0-dev.0` -## Unreleased patch +## 2.6.2 - 2024-10-27 + +- Support latest custom_lint + +## 2.6.1 - 2024-10-22 + +- Support analyzer >=6.7.0 <7.0.0 + This should make it compatible with Flutter's stable channel. + +## 2.4.0 - 2024-10-20 + +- `functional_ref` and its quick-fix now expect: + ```dart + @riverpod + Model foo(Ref ref) => .. + ``` + +## 2.3.14 - 2024-10-12 Bump analyzer to ^6.9.0 diff --git a/packages/riverpod_lint/README.md b/packages/riverpod_lint/README.md index 8dc42fc2d..3a23b0dbb 100644 --- a/packages/riverpod_lint/README.md +++ b/packages/riverpod_lint/README.md @@ -202,11 +202,11 @@ Consider the following providers: ```dart // A non-scoped provider @riverpod -int root(RootRef ref) => 0; +int root(Ref ref) => 0; // A possibly scoped provider @Riverpod(dependencies: []) -int scoped(ScopedRef ref) => 0; +int scoped(Ref ref) => 0; ``` **Good**: @@ -214,21 +214,21 @@ int scoped(ScopedRef ref) => 0; ```dart // No dependencies used, no need to specify "dependencies" @riverpod -int example(ExampleRef ref) => 0; +int example(Ref ref) => 0; // We can specify an empty "dependencies" list if we wish to. // This marks the provider as "scoped". @Riverpod(dependencies: []) -int example(ExampleRef ref) => 0; +int example(Ref ref) => 0; @riverpod -void example(ExampleRef ref) { +void example(Ref ref) { // rootProvider is not scoped, no need to specify it as "dependencies" ref.watch(rootProvider); } @Riverpod(dependencies: [scoped]) -void example(ExampleRef ref) { +void example(Ref ref) { // scopedProvider is scoped and as such specifying "dependencies" is required. ref.watch(scopedProvider); } @@ -261,16 +261,16 @@ ProviderScope( ```dart // scopedProvider isn't used and should therefore not be listed @Riverpod(dependencies: [scoped]) -int example(ExampleRef ref) => 0; +int example(Ref ref) => 0; @Riverpod(dependencies: []) -void example(ExampleRef ref) { +void example(Ref ref) { // scopedProvider is used but not present in the list of dependencies ref.watch(scopedProvider); } @Riverpod(dependencies: [root]) -void example(ExampleRef ref) { +void example(Ref ref) { // rootProvider is not a scoped provider. As such it shouldn't be listed in "dependencies" ref.watch(rootProvider); } @@ -294,10 +294,10 @@ Consider the following providers: ```dart @Riverpod(dependencies: []) -int scoped(ScopedRef ref) => 0; +int scoped(Ref ref) => 0; @riverpod -int root(RootRef ref) => 0; +int root(Ref ref) => 0; ``` (Providers defined without `riverpod_generator` are not supported) @@ -362,10 +362,10 @@ Failing to do so would break the [provider_dependencies](#provider_dependencies- ```dart @riverpod -int dep(DepRef ref) => 0; +int dep(Ref ref) => 0; @riverpod -void example(ExampleRef ref) { +void example(Ref ref) { /// Generated providers can depend on other generated providers ref.watch(depProvider); } @@ -377,7 +377,7 @@ void example(ExampleRef ref) { final depProvider = Provider((ref) => 0); @riverpod -void example(ExampleRef ref) { +void example(Ref ref) { // Generated providers should not depend on non-generated providers ref.watch(depProvider); } @@ -391,7 +391,7 @@ Providers should not interact with `BuildContext`. ```dart @riverpod -int fn(FnRef ref) => 0; +int fn(Ref ref) => 0; @riverpod class MyNotifier extends _$MyNotifier { @@ -405,7 +405,7 @@ class MyNotifier extends _$MyNotifier { ```dart // Providers should not receive a BuildContext as a parameter. -int fn(FnRef ref, BuildContext context) => 0; +int fn(Ref ref, BuildContext context) => 0; @riverpod class MyNotifier extends _$MyNotifier { @@ -518,7 +518,7 @@ In that scenario, you may explicitly wrap the value in `Raw`: ```dart @riverpod -int integer(IntegerRef ref) => 0; +int integer(Ref ref) => 0; @riverpod class IntegerNotifier extends _$IntegerNotifier { @@ -529,7 +529,7 @@ class IntegerNotifier extends _$IntegerNotifier { // By using "Raw", we can explicitly return a ChangeNotifier in a provider // without triggering `unsupported_provider_value`. @riverpod -Raw myRouter(MyRouterRef ref) { +Raw myRouter(Ref ref) { final router = GoRouter(...); // Riverpod won't dispose the ChangeNotifier for you in this case. Don't forget // to do it on your own! @@ -544,7 +544,7 @@ Raw myRouter(MyRouterRef ref) { // KO: riverpod_generator does not support creating StateNotifier/ChangeNotifiers/... // Instead annotate a class with @riverpod. @riverpod -MyStateNotifier stateNotifier(StateNotifierRef ref) => MyStateNotifier(); +MyStateNotifier stateNotifier(Ref ref) => MyStateNotifier(); class MyStateNotifier extends StateNotifier { MyStateNotifier(): super(0); @@ -559,7 +559,7 @@ Functional providers must receive a ref matching the provider name as their firs ```dart @riverpod -int myProvider(MyProviderRef ref) => 0; +int myProvider(Ref ref) => 0; ``` **Bad**: @@ -569,7 +569,7 @@ int myProvider(MyProviderRef ref) => 0; @riverpod int myProvider() => 0; -// The ref parameter is not correctly typed (int -> MyProviderRef) +// The ref parameter is not correctly typed (int -> Ref) @riverpod int myProvider(int ref) => 0; ``` @@ -633,10 +633,10 @@ to behave as a `keepAlive`, even though it isn't marked as such. ```dart @riverpod -int nonKeepAlive(NonKeepAliveRef ref) => 0; +int nonKeepAlive(Ref ref) => 0; @Riverpod(keepAlive: true) -int fn(FnRef ref) { +int fn(Ref ref) { // `keepAlive` providers should only depend on keepAlive providers. ref.watch(nonKeepAliveProvider); } diff --git a/packages/riverpod_lint/lib/src/assists/convert_to_stateful_base_widget.dart b/packages/riverpod_lint/lib/src/assists/convert_to_stateful_base_widget.dart index 013dfc526..05d2623a5 100644 --- a/packages/riverpod_lint/lib/src/assists/convert_to_stateful_base_widget.dart +++ b/packages/riverpod_lint/lib/src/assists/convert_to_stateful_base_widget.dart @@ -287,7 +287,10 @@ class _ReplacementEditBuilder extends RecursiveAstVisitor { } final element = node.staticElement; if (element is ExecutableElement && - element.enclosingElement3 == widgetClassElement && + element + // ignore: deprecated_member_use, necessary to support older versions of analyzer + .enclosingElement == + widgetClassElement && !elementsToMove.contains(element)) { final offset = node.offset; final qualifier = diff --git a/packages/riverpod_lint/lib/src/assists/convert_to_stateless_base_widget.dart b/packages/riverpod_lint/lib/src/assists/convert_to_stateless_base_widget.dart index 3e654764a..1d1398c49 100644 --- a/packages/riverpod_lint/lib/src/assists/convert_to_stateless_base_widget.dart +++ b/packages/riverpod_lint/lib/src/assists/convert_to_stateless_base_widget.dart @@ -329,7 +329,10 @@ class _ReplacementEditBuilder extends RecursiveAstVisitor { } final element = node.staticElement; if (element is ExecutableElement && - element.enclosingElement3 == widgetClassElement && + element + // ignore: deprecated_member_use, necessary to support older versions of analyzer + .enclosingElement == + widgetClassElement && !elementsToMove.contains(element)) { final parent = node.parent; if (parent is PrefixedIdentifier) { diff --git a/packages/riverpod_lint/lib/src/lints/async_value_nullable_pattern.dart b/packages/riverpod_lint/lib/src/lints/async_value_nullable_pattern.dart index b5fd70cea..af3c385da 100644 --- a/packages/riverpod_lint/lib/src/lints/async_value_nullable_pattern.dart +++ b/packages/riverpod_lint/lib/src/lints/async_value_nullable_pattern.dart @@ -1,7 +1,10 @@ import 'package:analyzer/dart/ast/ast.dart'; import 'package:analyzer/dart/element/nullability_suffix.dart'; import 'package:analyzer/dart/element/type.dart'; -import 'package:analyzer/error/error.dart' hide LintCode; +import 'package:analyzer/error/error.dart' + hide + // ignore: undefined_hidden_name, necessary to support lower analyzer version + LintCode; import 'package:analyzer/error/listener.dart'; import 'package:custom_lint_builder/custom_lint_builder.dart'; import 'package:riverpod_analyzer_utils/riverpod_analyzer_utils.dart'; diff --git a/packages/riverpod_lint/lib/src/lints/avoid_ref_inside_state_dispose.dart b/packages/riverpod_lint/lib/src/lints/avoid_ref_inside_state_dispose.dart index 0515ae04d..c85f2a5dc 100644 --- a/packages/riverpod_lint/lib/src/lints/avoid_ref_inside_state_dispose.dart +++ b/packages/riverpod_lint/lib/src/lints/avoid_ref_inside_state_dispose.dart @@ -1,5 +1,8 @@ import 'package:analyzer/dart/ast/ast.dart'; -import 'package:analyzer/error/error.dart' hide LintCode; +import 'package:analyzer/error/error.dart' + hide + // ignore: undefined_hidden_name, necessary to support broad analyzer versions + LintCode; import 'package:analyzer/error/listener.dart'; import 'package:custom_lint_builder/custom_lint_builder.dart'; import 'package:riverpod_analyzer_utils/riverpod_analyzer_utils.dart'; diff --git a/packages/riverpod_lint/lib/src/lints/functional_ref.dart b/packages/riverpod_lint/lib/src/lints/functional_ref.dart index 4dd11ea1e..a5c804a5e 100644 --- a/packages/riverpod_lint/lib/src/lints/functional_ref.dart +++ b/packages/riverpod_lint/lib/src/lints/functional_ref.dart @@ -1,11 +1,16 @@ import 'package:analyzer/dart/ast/ast.dart'; -import 'package:analyzer/error/error.dart' hide LintCode; +import 'package:analyzer/dart/element/element.dart'; +import 'package:analyzer/error/error.dart' + hide + // ignore: undefined_hidden_name, necessary to support lower analyzer version + LintCode; import 'package:analyzer/error/listener.dart'; +import 'package:analyzer_plugin/utilities/change_builder/change_builder_dart.dart'; import 'package:collection/collection.dart'; import 'package:custom_lint_builder/custom_lint_builder.dart'; +import 'package:meta/meta.dart'; import '../riverpod_custom_lint.dart'; -import 'notifier_extends.dart'; class FunctionalRef extends RiverpodLintRule { const FunctionalRef() : super(code: _code); @@ -52,31 +57,11 @@ class FunctionalRef extends RiverpodLintRule { if (refNodeType.beginToken.lexeme != expectedRefName) { reporter.atNode(refNodeType, _code); } - - final expectedTypeArguments = - declaration.node.functionExpression.typeParameters?.typeParameters ?? - const []; - - final currentRefType = refNode.type; - if (currentRefType is! NamedType) { - reporter.atNode(refNodeType, _code); - return; - } - final actualTypeArguments = - currentRefType.typeArguments?.arguments ?? const []; - - if (!areGenericTypeArgumentsMatching( - expectedTypeArguments, - actualTypeArguments, - )) { - reporter.atNode(refNodeType, _code); - return; - } }); } @override - List getFixes() => [FunctionalRefFix()]; + List getFixes() => [FunctionalRefFix()]; } class FunctionalRefFix extends RiverpodFix { @@ -94,14 +79,9 @@ class FunctionalRefFix extends RiverpodFix { return; } - final expectedGenerics = genericsDisplayStringFor( - declaration.node.functionExpression.typeParameters, - ); - final expectedRefType = '${refNameFor(declaration)}$expectedGenerics'; - final refNode = declaration .node.functionExpression.parameters!.parameters.firstOrNull; - if (refNode == null) { + if (refNode == null || refNode.isNamed) { // No ref parameter, adding one final changeBuilder = reporter.createChangeBuilder( message: 'Add ref parameter', @@ -109,9 +89,14 @@ class FunctionalRefFix extends RiverpodFix { ); changeBuilder.addDartFileEdit((builder) { + var toInsert = 'Ref ref'; + if (refNode != null) { + toInsert = '$toInsert, '; + } + builder.addSimpleInsertion( declaration.node.functionExpression.parameters!.leftParenthesis.end, - '$expectedRefType ref', + toInsert, ); }); return; @@ -121,24 +106,75 @@ class FunctionalRefFix extends RiverpodFix { // No type specified, adding it. final changeBuilder = reporter.createChangeBuilder( - message: 'Type as $expectedRefType', + message: 'Type as Ref', priority: 90, ); changeBuilder.addDartFileEdit((builder) { if (!refNode.isExplicitlyTyped) { - builder.addSimpleInsertion(refNode.name!.offset, '$expectedRefType '); + builder.addSimpleInsertion(refNode.name!.offset, 'Ref '); return; } + final type = typeAnnotationFor(refNode); builder.addSimpleReplacement( sourceRangeFrom( - start: refNode.type!.offset, + start: type.offset, end: refNode.name!.offset, ), - '$expectedRefType ', + 'Ref ', ); }); }); } } + +extension LibraryForNode on AstNode { + LibraryElement get library => (root as CompilationUnit).library; +} + +extension ImportFix on DartFileEditBuilder { + @useResult + String importRef() { + return _importWithPrefix('Ref'); + } + + @useResult + String _importWithPrefix(String name) { + final hooksRiverpodUri = + Uri(scheme: 'package', path: 'hooks_riverpod/hooks_riverpod.dart'); + final flutterRiverpodUri = + Uri(scheme: 'package', path: 'flutter_riverpod/flutter_riverpod.dart'); + final riverpodUri = Uri(scheme: 'package', path: 'riverpod/riverpod.dart'); + + if (importsLibrary(hooksRiverpodUri)) { + return _buildImport(hooksRiverpodUri, name); + } + + if (importsLibrary(flutterRiverpodUri)) { + return _buildImport(flutterRiverpodUri, name); + } + + return _buildImport(riverpodUri, name); + } + + String _buildImport(Uri uri, String name) { + final import = importLibraryElement(uri); + + final prefix = import.prefix; + if (prefix != null) return '$prefix.$name'; + + return name; + } +} + +TypeAnnotation typeAnnotationFor(FormalParameter param) { + if (param is DefaultFormalParameter) { + return typeAnnotationFor(param.parameter); + } + if (param is SimpleFormalParameter) { + return param.type!; + } + + throw UnimplementedError('Unknown parameter type: $param'); +} diff --git a/packages/riverpod_lint/lib/src/lints/missing_provider_scope.dart b/packages/riverpod_lint/lib/src/lints/missing_provider_scope.dart index d3b40ca55..76270b87b 100644 --- a/packages/riverpod_lint/lib/src/lints/missing_provider_scope.dart +++ b/packages/riverpod_lint/lib/src/lints/missing_provider_scope.dart @@ -1,6 +1,9 @@ import 'package:analyzer/dart/ast/ast.dart'; import 'package:analyzer/dart/element/element.dart'; -import 'package:analyzer/error/error.dart' hide LintCode; +import 'package:analyzer/error/error.dart' + hide + // ignore: undefined_hidden_name, necessary to support lower analyzer version + LintCode; import 'package:analyzer/error/listener.dart'; import 'package:collection/collection.dart'; import 'package:custom_lint_builder/custom_lint_builder.dart'; diff --git a/packages/riverpod_lint/lib/src/lints/notifier_build.dart b/packages/riverpod_lint/lib/src/lints/notifier_build.dart index 702a0ef93..e233f229e 100644 --- a/packages/riverpod_lint/lib/src/lints/notifier_build.dart +++ b/packages/riverpod_lint/lib/src/lints/notifier_build.dart @@ -1,5 +1,8 @@ import 'package:analyzer/dart/element/element.dart'; -import 'package:analyzer/error/error.dart' hide LintCode; +import 'package:analyzer/error/error.dart' + hide + // ignore: undefined_hidden_name, necessary to support lower analyzer version + LintCode; import 'package:analyzer/error/listener.dart'; import 'package:custom_lint_builder/custom_lint_builder.dart'; import 'package:riverpod_analyzer_utils/riverpod_analyzer_utils.dart'; @@ -30,7 +33,9 @@ class NotifierBuild extends RiverpodLintRule { final annotationElement = element.element; if (annotationElement == null || - annotationElement is! ExecutableElement) return false; + annotationElement is! ExecutableElement) { + return false; + } return riverpodType.isExactlyType(annotationElement.returnType); }, diff --git a/packages/riverpod_lint/lib/src/lints/notifier_extends.dart b/packages/riverpod_lint/lib/src/lints/notifier_extends.dart index 7da27e271..0a8bcf156 100644 --- a/packages/riverpod_lint/lib/src/lints/notifier_extends.dart +++ b/packages/riverpod_lint/lib/src/lints/notifier_extends.dart @@ -1,5 +1,8 @@ import 'package:analyzer/dart/ast/ast.dart'; -import 'package:analyzer/error/error.dart' hide LintCode; +import 'package:analyzer/error/error.dart' + hide + // ignore: undefined_hidden_name, necessary to support broad analyzer versions + LintCode; import 'package:analyzer/error/listener.dart'; import 'package:custom_lint_builder/custom_lint_builder.dart'; import 'package:riverpod_analyzer_utils/riverpod_analyzer_utils.dart'; diff --git a/packages/riverpod_lint/lib/src/lints/only_use_keep_alive_inside_keep_alive.dart b/packages/riverpod_lint/lib/src/lints/only_use_keep_alive_inside_keep_alive.dart index 5285dcaf6..eb60dc017 100644 --- a/packages/riverpod_lint/lib/src/lints/only_use_keep_alive_inside_keep_alive.dart +++ b/packages/riverpod_lint/lib/src/lints/only_use_keep_alive_inside_keep_alive.dart @@ -1,5 +1,8 @@ import 'package:analyzer/dart/ast/ast.dart'; -import 'package:analyzer/error/error.dart' hide LintCode; +import 'package:analyzer/error/error.dart' + hide + // ignore: undefined_hidden_name, necessary to support broad analyzer versions + LintCode; import 'package:analyzer/error/listener.dart'; import 'package:custom_lint_builder/custom_lint_builder.dart'; import 'package:riverpod_analyzer_utils/riverpod_analyzer_utils.dart'; diff --git a/packages/riverpod_lint/lib/src/lints/provider_dependencies.dart b/packages/riverpod_lint/lib/src/lints/provider_dependencies.dart index 9672380db..a7054907e 100644 --- a/packages/riverpod_lint/lib/src/lints/provider_dependencies.dart +++ b/packages/riverpod_lint/lib/src/lints/provider_dependencies.dart @@ -1,6 +1,9 @@ import 'package:analyzer/dart/ast/ast.dart'; import 'package:analyzer/diagnostic/diagnostic.dart'; -import 'package:analyzer/error/error.dart' hide LintCode; +import 'package:analyzer/error/error.dart' + hide + // ignore: undefined_hidden_name, necessary to support broad analyzer versions + LintCode; import 'package:analyzer/error/listener.dart'; import 'package:analyzer_plugin/utilities/change_builder/change_builder_dart.dart'; import 'package:analyzer_plugin/utilities/range_factory.dart'; diff --git a/packages/riverpod_lint/lib/src/lints/provider_parameters.dart b/packages/riverpod_lint/lib/src/lints/provider_parameters.dart index a177c3985..bd40e6d43 100644 --- a/packages/riverpod_lint/lib/src/lints/provider_parameters.dart +++ b/packages/riverpod_lint/lib/src/lints/provider_parameters.dart @@ -1,6 +1,9 @@ import 'package:analyzer/dart/ast/ast.dart'; import 'package:analyzer/dart/element/element.dart'; -import 'package:analyzer/error/error.dart' hide LintCode; +import 'package:analyzer/error/error.dart' + hide + // ignore: undefined_hidden_name, necessary to support broad analyzer versions + LintCode; import 'package:analyzer/error/listener.dart'; import 'package:custom_lint_builder/custom_lint_builder.dart'; import 'package:riverpod_analyzer_utils/riverpod_analyzer_utils.dart'; @@ -42,20 +45,22 @@ class ProviderParameters extends RiverpodLintRule { if (value is TypedLiteral && !value.isConst) { // Non-const literals always return a new instance and don't override == - reporter.atNode(value, code); + reporter.atNode(value, _code); } else if (value is FunctionExpression) { // provider(() => 42) is bad because a new function will always be created - reporter.atNode(value, code); + reporter.atNode(value, _code); } else if (value is InstanceCreationExpression && !value.isConst) { final instantiatedObject = value.constructorName.staticElement ?.applyRedirectedConstructors(); - final operatorEqual = - instantiatedObject?.enclosingElement3.recursiveGetMethod('=='); + final operatorEqual = instantiatedObject + // ignore: deprecated_member_use, necessary to support older versions of analyzer + ?.enclosingElement + .recursiveGetMethod('=='); if (operatorEqual == null) { // Doing `provider(new Class())` is bad if the class does not override == - reporter.atNode(value, code); + reporter.atNode(value, _code); } } } diff --git a/packages/riverpod_lint/lib/src/lints/riverpod_syntax_error.dart b/packages/riverpod_lint/lib/src/lints/riverpod_syntax_error.dart index 922ab1325..ca5f279cf 100644 --- a/packages/riverpod_lint/lib/src/lints/riverpod_syntax_error.dart +++ b/packages/riverpod_lint/lib/src/lints/riverpod_syntax_error.dart @@ -1,4 +1,7 @@ -import 'package:analyzer/error/error.dart' hide LintCode; +import 'package:analyzer/error/error.dart' + hide + // ignore: undefined_hidden_name, necessary to support broad analyzer versions + LintCode; import 'package:analyzer/error/listener.dart'; import 'package:analyzer/source/source_range.dart'; import 'package:custom_lint_builder/custom_lint_builder.dart'; diff --git a/packages/riverpod_lint/lib/src/lints/scoped_providers_should_specify_dependencies.dart b/packages/riverpod_lint/lib/src/lints/scoped_providers_should_specify_dependencies.dart index b6f688a3c..4eb8868bf 100644 --- a/packages/riverpod_lint/lib/src/lints/scoped_providers_should_specify_dependencies.dart +++ b/packages/riverpod_lint/lib/src/lints/scoped_providers_should_specify_dependencies.dart @@ -1,5 +1,8 @@ import 'package:analyzer/dart/ast/ast.dart'; -import 'package:analyzer/error/error.dart' hide LintCode; +import 'package:analyzer/error/error.dart' + hide + // ignore: undefined_hidden_name, necessary to support broad analyzer versions + LintCode; import 'package:analyzer/error/listener.dart'; import 'package:custom_lint_builder/custom_lint_builder.dart'; import 'package:riverpod_analyzer_utils/riverpod_analyzer_utils.dart'; diff --git a/packages/riverpod_lint/lib/src/lints/unknown_scoped_usage.dart b/packages/riverpod_lint/lib/src/lints/unknown_scoped_usage.dart index fb312d515..5ec9fa083 100644 --- a/packages/riverpod_lint/lib/src/lints/unknown_scoped_usage.dart +++ b/packages/riverpod_lint/lib/src/lints/unknown_scoped_usage.dart @@ -1,6 +1,9 @@ import 'package:analyzer/dart/ast/ast.dart'; import 'package:analyzer/dart/element/element.dart'; -import 'package:analyzer/error/error.dart' hide LintCode; +import 'package:analyzer/error/error.dart' + hide + // ignore: undefined_hidden_name, necessary to support broad analyzer versions + LintCode; import 'package:analyzer/error/listener.dart'; import 'package:custom_lint_builder/custom_lint_builder.dart'; import 'package:riverpod_analyzer_utils/riverpod_analyzer_utils.dart'; @@ -43,7 +46,9 @@ class UnknownScopedUsage extends RiverpodLintRule { // then it's fine. // This is to reject cases like `ref.watch(something(provider))`. if (refInvocation?.listenable.provider == identifier || - widgetRefInvocation?.listenable.provider == identifier) return; + widgetRefInvocation?.listenable.provider == identifier) { + return; + } // .parent is used because providers count as overrides. // We don't want to count "provider" as an override, and want to focus @@ -55,12 +60,17 @@ class UnknownScopedUsage extends RiverpodLintRule { if (override?.provider == identifier) return; final enclosingConstructorType = identifier - .node.staticParameterElement?.enclosingElement3 + .node + .staticParameterElement + // ignore: deprecated_member_use, required to support lower versions of analyzer + ?.enclosingElement .safeCast() ?.returnType; // Silence the warning if passed to a widget constructor. if (enclosingConstructorType != null && - widgetType.isAssignableFromType(enclosingConstructorType)) return; + widgetType.isAssignableFromType(enclosingConstructorType)) { + return; + } reporter.atNode( identifier.node, diff --git a/packages/riverpod_lint/lib/src/migration/missing_legacy_import.dart b/packages/riverpod_lint/lib/src/migration/missing_legacy_import.dart index cdcad2161..e0be586d6 100644 --- a/packages/riverpod_lint/lib/src/migration/missing_legacy_import.dart +++ b/packages/riverpod_lint/lib/src/migration/missing_legacy_import.dart @@ -1,6 +1,9 @@ import 'package:analyzer/dart/ast/ast.dart'; import 'package:analyzer/dart/element/type.dart'; -import 'package:analyzer/error/error.dart' hide LintCode; +import 'package:analyzer/error/error.dart' + hide + // ignore: undefined_hidden_name, necessary to support broad analyzer versions + LintCode; import 'package:analyzer/error/listener.dart'; import 'package:custom_lint_builder/custom_lint_builder.dart'; diff --git a/packages/riverpod_lint/lib/src/riverpod_custom_lint.dart b/packages/riverpod_lint/lib/src/riverpod_custom_lint.dart index c41924e57..892770e75 100644 --- a/packages/riverpod_lint/lib/src/riverpod_custom_lint.dart +++ b/packages/riverpod_lint/lib/src/riverpod_custom_lint.dart @@ -6,9 +6,7 @@ SourceRange sourceRangeFrom({required int start, required int end}) { return SourceRange(start, end - start); } -String refNameFor(ProviderDeclaration provider) { - return '${provider.name.lexeme.titled}Ref'; -} +String refNameFor(ProviderDeclaration provider) => 'Ref'; String classNameFor(ProviderDeclaration provider) { return provider.name.lexeme.titled; diff --git a/packages/riverpod_lint/pubspec.yaml b/packages/riverpod_lint/pubspec.yaml index 34af0db08..c66c1675d 100644 --- a/packages/riverpod_lint/pubspec.yaml +++ b/packages/riverpod_lint/pubspec.yaml @@ -11,14 +11,14 @@ environment: sdk: ">=3.0.0<4.0.0" dependencies: - analyzer: ^6.9.0 + analyzer: ^6.7.0 analyzer_plugin: ^0.11.2 collection: ^1.16.0 - custom_lint_builder: ^0.6.5 + custom_lint_builder: ^0.7.0 meta: ^1.7.0 path: ^1.8.1 - riverpod: ^3.0.0-dev.3 - riverpod_analyzer_utils: ^1.0.0-dev.1 + riverpod: 3.0.0-dev.3 + riverpod_analyzer_utils: 1.0.0-dev.1 source_span: ^1.8.0 yaml: ^3.1.1 diff --git a/packages/riverpod_lint/pubspec_overrides.yaml b/packages/riverpod_lint/pubspec_overrides.yaml index d711ada23..06c1d5f2b 100644 --- a/packages/riverpod_lint/pubspec_overrides.yaml +++ b/packages/riverpod_lint/pubspec_overrides.yaml @@ -2,7 +2,5 @@ dependency_overrides: riverpod_analyzer_utils: path: ../riverpod_analyzer_utils - # necessary due to outdated mockito dependency - analyzer: ^6.0.0 riverpod: path: ../riverpod diff --git a/packages/riverpod_lint_flutter_test/analysis_options.yaml b/packages/riverpod_lint_flutter_test/analysis_options.yaml index 69961a146..b3d19c02e 100644 --- a/packages/riverpod_lint_flutter_test/analysis_options.yaml +++ b/packages/riverpod_lint_flutter_test/analysis_options.yaml @@ -3,8 +3,10 @@ analyzer: - custom_lint exclude: # Files with errors on purpose - - test/lints/notifier_extends.g.dart - - test/lints/functional_ref.g.dart + - test/lints/notifier_extends/notifier_extends.g.dart + - test/lints/functional_ref/functional_ref.g.dart + - test/lints/functional_ref/fix/auto_import.g.dart + - test/lints/functional_ref/fix/use_prefix.g.dart custom_lint: - debug: true \ No newline at end of file + debug: true diff --git a/packages/riverpod_lint_flutter_test/build.yaml b/packages/riverpod_lint_flutter_test/build.yaml index aee239ff4..43ef69596 100644 --- a/packages/riverpod_lint_flutter_test/build.yaml +++ b/packages/riverpod_lint_flutter_test/build.yaml @@ -8,3 +8,4 @@ targets: - test/lints/notifier_build.dart - test/lints/riverpod_syntax_error.dart - test/lints/functional_ref/failing_functional_ref.dart + - test/lints/notifier_extends/failing_notifier_extends.dart \ No newline at end of file diff --git a/packages/riverpod_lint_flutter_test/pubspec.yaml b/packages/riverpod_lint_flutter_test/pubspec.yaml index 7222d92a0..a56d18125 100644 --- a/packages/riverpod_lint_flutter_test/pubspec.yaml +++ b/packages/riverpod_lint_flutter_test/pubspec.yaml @@ -12,11 +12,12 @@ dependencies: sdk: flutter freezed_annotation: ^2.2.0 json_annotation: ^4.8.0 + pubspec_parse: ^1.3.0 dev_dependencies: build_runner: ^2.4.6 - custom_lint: ^0.6.5 - custom_lint_core: ^0.6.5 + custom_lint: ^0.7.0 + custom_lint_core: ^0.7.0 freezed: ^2.3.2 json_serializable: ^6.6.1 riverpod_lint: diff --git a/packages/riverpod_lint_flutter_test/test/assists/convert_class_based_provider_to_functional/convert_class_based_provider_to_functional.g.dart b/packages/riverpod_lint_flutter_test/test/assists/convert_class_based_provider_to_functional/convert_class_based_provider_to_functional.g.dart index ef5b84bf4..5c978d16b 100644 --- a/packages/riverpod_lint_flutter_test/test/assists/convert_class_based_provider_to_functional/convert_class_based_provider_to_functional.g.dart +++ b/packages/riverpod_lint_flutter_test/test/assists/convert_class_based_provider_to_functional/convert_class_based_provider_to_functional.g.dart @@ -55,7 +55,7 @@ final class ExampleProvider extends $NotifierProvider { @override ExampleProvider $copyWithBuild( int Function( - Ref, + Ref, Example, ) build, ) { @@ -146,7 +146,7 @@ final class ExampleFamilyProvider @override ExampleFamilyProvider $copyWithBuild( int Function( - Ref, + Ref, ExampleFamily, ) build, ) { @@ -234,7 +234,7 @@ final class ExampleFamilyFamily extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( int Function( - Ref ref, + Ref ref, ExampleFamily notifier, ({ int a, @@ -313,7 +313,7 @@ final class GenericProvider GenericProvider _copyWithBuild( int Function( - Ref, + Ref, Generic, ) build, ) { @@ -353,7 +353,7 @@ final class GenericProvider @override GenericProvider $copyWithBuild( int Function( - Ref, + Ref, Generic, ) build, ) { @@ -416,7 +416,7 @@ final class GenericFamily extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( - int Function(Ref ref, Generic notifier) build, + int Function(Ref ref, Generic notifier) build, ) { return $FamilyOverride( from: this, @@ -437,4 +437,4 @@ abstract class _$Generic extends $Notifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/packages/riverpod_lint_flutter_test/test/assists/convert_class_based_provider_to_functional/convert_class_based_provider_to_functional_test.dart b/packages/riverpod_lint_flutter_test/test/assists/convert_class_based_provider_to_functional/convert_class_based_provider_to_functional_test.dart index fe2af3181..049d20692 100644 --- a/packages/riverpod_lint_flutter_test/test/assists/convert_class_based_provider_to_functional/convert_class_based_provider_to_functional_test.dart +++ b/packages/riverpod_lint_flutter_test/test/assists/convert_class_based_provider_to_functional/convert_class_based_provider_to_functional_test.dart @@ -1,5 +1,4 @@ import 'package:riverpod_lint/src/assists/class_based_to_functional_provider.dart'; -import 'package:analyzer/source/source_range.dart'; import '../../test_lint.dart'; @@ -9,19 +8,24 @@ void main() { 'test/assists/goldens/convert_class_based_provider_to_functional/convert_class_based_provider_to_functional.diff', sourcePath: 'test/assists/convert_class_based_provider_to_functional/convert_class_based_provider_to_functional.dart', - (result) async { + (result, helper) async { final assist = ClassBasedToFunctionalProvider(); - return [ - ...await assist.testRun(result, const SourceRange(145, 0)), - ...await assist.testRun(result, const SourceRange(149, 0)), - ...await assist.testRun(result, const SourceRange(156, 0)), - ...await assist.testRun(result, const SourceRange(165, 0)), - ...await assist.testRun(result, const SourceRange(174, 0)), - ...await assist.testRun(result, const SourceRange(190, 0)), - ...await assist.testRun(result, const SourceRange(258, 0)), - ...await assist.testRun(result, const SourceRange(412, 0)), - ]; + final cursors = helper.rangesForString(r''' +@rive<>rpod<> +class <>Example e<>xtends _$<>Example { + @ove<>rride + int build() => 0; +} + +/// Some comment +@riverpod +class Exampl<>eFamily extends _$ExampleFamily { +'''); + + final cursors2 = helper.rangesForString('class Gen<>eric'); + + return helper.runAssist(assist, result, [...cursors, ...cursors2]); }, ); } diff --git a/packages/riverpod_lint_flutter_test/test/assists/convert_functional_provider_to_class_based/convert_functional_provider_to_class_based.dart b/packages/riverpod_lint_flutter_test/test/assists/convert_functional_provider_to_class_based/convert_functional_provider_to_class_based.dart index a2ad96cb8..f7f660062 100644 --- a/packages/riverpod_lint_flutter_test/test/assists/convert_functional_provider_to_class_based/convert_functional_provider_to_class_based.dart +++ b/packages/riverpod_lint_flutter_test/test/assists/convert_functional_provider_to_class_based/convert_functional_provider_to_class_based.dart @@ -4,11 +4,11 @@ part 'convert_functional_provider_to_class_based.g.dart'; /// Some comment @riverpod -int example(ExampleRef ref) => 0; +int example(Ref ref) => 0; /// Some comment @riverpod -int exampleFamily(ExampleFamilyRef ref, {required int a, String b = '42'}) { +int exampleFamily(Ref ref, {required int a, String b = '42'}) { // Hello world return 0; } diff --git a/packages/riverpod_lint_flutter_test/test/assists/convert_functional_provider_to_class_based/convert_functional_provider_to_class_based.g.dart b/packages/riverpod_lint_flutter_test/test/assists/convert_functional_provider_to_class_based/convert_functional_provider_to_class_based.g.dart index bc2b97022..0190818a7 100644 --- a/packages/riverpod_lint_flutter_test/test/assists/convert_functional_provider_to_class_based/convert_functional_provider_to_class_based.g.dart +++ b/packages/riverpod_lint_flutter_test/test/assists/convert_functional_provider_to_class_based/convert_functional_provider_to_class_based.g.dart @@ -6,20 +6,17 @@ part of 'convert_functional_provider_to_class_based.dart'; // RiverpodGenerator // ************************************************************************** -/// Some comment -typedef ExampleRef = Ref; - /// Some comment @ProviderFor(example) const exampleProvider = ExampleProvider._(); /// Some comment final class ExampleProvider extends $FunctionalProvider - with $Provider { + with $Provider { /// Some comment const ExampleProvider._( {int Function( - ExampleRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -33,7 +30,7 @@ final class ExampleProvider extends $FunctionalProvider ); final int Function( - ExampleRef ref, + Ref ref, )? _createCb; @override @@ -55,23 +52,20 @@ final class ExampleProvider extends $FunctionalProvider @override ExampleProvider $copyWithCreate( int Function( - ExampleRef ref, + Ref ref, ) create, ) { return ExampleProvider._(create: create); } @override - int create(ExampleRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? example; return _$cb(ref); } } -String _$exampleHash() => r'638d7db2be22eaad0f51ea0b3ae38e0483d43725'; - -/// Some comment -typedef ExampleFamilyRef = Ref; +String _$exampleHash() => r'67898608b444d39a000852f647ca6d3326740c98'; /// Some comment @ProviderFor(exampleFamily) @@ -79,7 +73,7 @@ const exampleFamilyProvider = ExampleFamilyFamily._(); /// Some comment final class ExampleFamilyProvider extends $FunctionalProvider - with $Provider { + with $Provider { /// Some comment const ExampleFamilyProvider._( {required ExampleFamilyFamily super.from, @@ -89,7 +83,7 @@ final class ExampleFamilyProvider extends $FunctionalProvider }) super.argument, int Function( - ExampleFamilyRef ref, { + Ref ref, { required int a, String b, })? create}) @@ -103,7 +97,7 @@ final class ExampleFamilyProvider extends $FunctionalProvider ); final int Function( - ExampleFamilyRef ref, { + Ref ref, { required int a, String b, })? _createCb; @@ -134,7 +128,7 @@ final class ExampleFamilyProvider extends $FunctionalProvider @override ExampleFamilyProvider $copyWithCreate( int Function( - ExampleFamilyRef ref, + Ref ref, ) create, ) { return ExampleFamilyProvider._( @@ -152,7 +146,7 @@ final class ExampleFamilyProvider extends $FunctionalProvider } @override - int create(ExampleFamilyRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? exampleFamily; final argument = this.argument as ({ int a, @@ -176,7 +170,7 @@ final class ExampleFamilyProvider extends $FunctionalProvider } } -String _$exampleFamilyHash() => r'f5547d3d88c42b135db5efea7dfaa542b3db9cc1'; +String _$exampleFamilyHash() => r'70dfc6f4b2d7d251edbc3a66c3ac0f2c56aebf8b'; /// Some comment final class ExampleFamilyFamily extends Family { @@ -208,7 +202,7 @@ final class ExampleFamilyFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( int Function( - ExampleFamilyRef ref, + Ref ref, ({ int a, String b, @@ -233,4 +227,4 @@ final class ExampleFamilyFamily extends Family { } } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/packages/riverpod_lint_flutter_test/test/assists/convert_functional_provider_to_class_based/convert_functional_provider_to_class_based_test.dart b/packages/riverpod_lint_flutter_test/test/assists/convert_functional_provider_to_class_based/convert_functional_provider_to_class_based_test.dart index f0e59e0be..bbc09b52c 100644 --- a/packages/riverpod_lint_flutter_test/test/assists/convert_functional_provider_to_class_based/convert_functional_provider_to_class_based_test.dart +++ b/packages/riverpod_lint_flutter_test/test/assists/convert_functional_provider_to_class_based/convert_functional_provider_to_class_based_test.dart @@ -1,26 +1,24 @@ import 'package:riverpod_lint/src/assists/functional_to_class_based_provider.dart'; -import 'package:analyzer/source/source_range.dart'; import '../../test_lint.dart'; void main() { - testGolden( - 'Convert functional providers to class-based providers', - 'test/assists/goldens/convert_functional_provider_to_class_based/convert_functional_provider_to_class_based.diff', - sourcePath: - 'test/assists/convert_functional_provider_to_class_based/convert_functional_provider_to_class_based.dart', - (result) async { - final assist = FunctionalToClassBasedProvider(); + testGolden('Convert functional providers to class-based providers', + 'test/assists/goldens/convert_functional_provider_to_class_based/convert_functional_provider_to_class_based.diff', + sourcePath: + 'test/assists/convert_functional_provider_to_class_based/convert_functional_provider_to_class_based.dart', + (result, helper) async { + final assist = FunctionalToClassBasedProvider(); - return [ - ...await assist.testRun(result, const SourceRange(145, 0)), - ...await assist.testRun(result, const SourceRange(148, 0)), - ...await assist.testRun(result, const SourceRange(156, 0)), - ...await assist.testRun(result, const SourceRange(167, 0)), - ...await assist.testRun(result, const SourceRange(180, 0)), - ...await assist.testRun(result, const SourceRange(224, 0)), - ...await assist.testRun(result, const SourceRange(342, 0)), - ]; - }, - ); + final cursors = helper.rangesForString(''' +@rive<>rpo<>d +int ex<>ample(R<>ef ref) =><> 0; + +/// Some comment +@riverpod +int exampleF<>amily(Ref ref, {required int a, String b = '42'}) { +'''); + + return helper.runAssist(assist, result, cursors); + }); } diff --git a/packages/riverpod_lint_flutter_test/test/assists/convert_to_widget/convert_to_widget_test.dart b/packages/riverpod_lint_flutter_test/test/assists/convert_to_widget/convert_to_widget_test.dart index 099e03afa..16a12986a 100644 --- a/packages/riverpod_lint_flutter_test/test/assists/convert_to_widget/convert_to_widget_test.dart +++ b/packages/riverpod_lint_flutter_test/test/assists/convert_to_widget/convert_to_widget_test.dart @@ -1,4 +1,3 @@ -import 'package:analyzer/source/source_range.dart'; import 'package:pubspec_parse/pubspec_parse.dart'; import 'package:riverpod_lint/src/assists/convert_to_stateful_base_widget.dart'; import 'package:riverpod_lint/src/assists/convert_to_stateless_base_widget.dart'; @@ -176,70 +175,71 @@ void _runGoldenTest( description, goldenFilePath, sourcePath: 'test/assists/convert_to_widget/convert_to_widget.dart', - (result) async { - final changes = [ - // Stateless - ...await assist.testRun(result, const SourceRange(163, 0), - pubspec: pubspec), - ...await assist.testRun(result, const SourceRange(174, 0), - pubspec: pubspec), - ...await assist.testRun(result, const SourceRange(185, 0), - pubspec: pubspec), - - // StatelessWithComma - ...await assist.testRun(result, const SourceRange(350, 0), - pubspec: pubspec), - - // Hook - ...await assist.testRun(result, const SourceRange(524, 0), - pubspec: pubspec), - - // HookConsumer - ...await assist.testRun(result, const SourceRange(690, 0), - pubspec: pubspec), - - // Stateful - ...await assist.testRun(result, const SourceRange(884, 0), - pubspec: pubspec), - - // ExplicitCreateState - ...await assist.testRun(result, const SourceRange(1208, 0), - pubspec: pubspec), - - // HookStateful - ...await assist.testRun(result, const SourceRange(1553, 0), - pubspec: pubspec), - - // ConsumerStateful - ...await assist.testRun(result, const SourceRange(1863, 0), - pubspec: pubspec), - - // HookConsumerStateful - ...await assist.testRun(result, const SourceRange(2214, 0), - pubspec: pubspec), - - // ConsumerWidget - ...await assist.testRun(result, const SourceRange(2582, 0), - pubspec: pubspec), - - // StatelessWithField - ...await assist.testRun(result, const SourceRange(2784, 0), - pubspec: pubspec), - - // HookConsumerWithField - ...await assist.testRun(result, const SourceRange(3139, 0), - pubspec: pubspec), - - // ConsumerStatefulWithField - ...await assist.testRun(result, const SourceRange(3571, 0), - pubspec: pubspec), + (result, helper) async { + final cursors = [ + ...helper.rangesForString(''' +class Stateless ext<>ends Statel<>essWidget {<> + const Stateless({super.key}); +'''), + ...helper.rangesForString(''' +class StatelessWithComma extends Stateles<>sWidget { + const StatelessWithComma({super.key}); +'''), + ...helper.rangesForString(''' +class Hook extends Hook<>Widget { + const Hook({super.key}); +'''), + ...helper.rangesForString(''' +class HookConsumer extends HookConsumer<>Widget { + const HookConsumer({super.key}); +'''), + ...helper.rangesForString(''' +class Stateful extends Stateful<>Widget { + const Stateful({super.key}); +'''), + ...helper.rangesForString(''' +class ExplicitCreateState extends State<>fulWidget { + const ExplicitCreateState({super.key}); +'''), + ...helper.rangesForString(''' +class HookStateful extends StatefulH<>ookWidget { + const HookStateful({super.key}); +'''), + ...helper.rangesForString(''' +class ConsumerStateful extends ConsumerStat<>efulWidget { + const ConsumerStateful({super.key}); +'''), + ...helper.rangesForString(''' +class HookConsumerStateful extends StatefulHo<>okConsumerWidget { + const HookConsumerStateful({super.key}); +'''), + ...helper.rangesForString(''' +class Consumer extends Consume<>rWidget { + const Consumer({super.key}); +'''), + ...helper.rangesForString(''' +class StatelessWithField extends Stateless<>Widget { + const StatelessWithField({ +'''), + ...helper.rangesForString(''' +class HookConsumerWithField extends HookConsumer<>Widget { + const HookConsumerWithField({ +'''), + ...helper.rangesForString(''' +class ConsumerStatefulWithField extends ConsumerStateful<>Widget { + const ConsumerStatefulWithField({ +'''), ]; - expect( - changes, - hasLength(expectedChangeCount), + final changes = await helper.runAssist( + assist, + result, + cursors, + pubspec: pubspec, ); + expect(changes, hasLength(expectedChangeCount)); + return changes; }, ); diff --git a/packages/riverpod_lint_flutter_test/test/assists/goldens/convert_class_based_provider_to_functional/convert_class_based_provider_to_functional.diff b/packages/riverpod_lint_flutter_test/test/assists/goldens/convert_class_based_provider_to_functional/convert_class_based_provider_to_functional.diff index d32463fb6..4a35375eb 100644 --- a/packages/riverpod_lint_flutter_test/test/assists/goldens/convert_class_based_provider_to_functional/convert_class_based_provider_to_functional.diff +++ b/packages/riverpod_lint_flutter_test/test/assists/goldens/convert_class_based_provider_to_functional/convert_class_based_provider_to_functional.diff @@ -8,7 +8,7 @@ Diff for file `test/assists/convert_class_based_provider_to_functional/convert_c - @override - int build() => 0; - } -+ int example(ExampleRef ref) => 0; ++ int example(Ref ref) => 0; /// Some comment ``` @@ -23,7 +23,7 @@ Diff for file `test/assists/convert_class_based_provider_to_functional/convert_c - @override - int build() => 0; - } -+ int example(ExampleRef ref) => 0; ++ int example(Ref ref) => 0; /// Some comment ``` @@ -38,7 +38,7 @@ Diff for file `test/assists/convert_class_based_provider_to_functional/convert_c - @override - int build() => 0; - } -+ int example(ExampleRef ref) => 0; ++ int example(Ref ref) => 0; /// Some comment ``` @@ -55,7 +55,7 @@ Diff for file `test/assists/convert_class_based_provider_to_functional/convert_c - // Hello world - return 0; - } -+ int exampleFamily(ExampleFamilyRef ref, {required int a, String b = '42'}) { ++ int exampleFamily(Ref ref, {required int a, String b = '42'}) { + // Hello world + return 0; + } @@ -73,6 +73,6 @@ Diff for file `test/assists/convert_class_based_provider_to_functional/convert_c - @override - int build() => 0; - } -+ int generic(GenericRef ref) => 0; ++ int generic(Ref ref) => 0; ``` --- diff --git a/packages/riverpod_lint_flutter_test/test/assists/goldens/convert_functional_provider_to_class_based/convert_functional_provider_to_class_based.diff b/packages/riverpod_lint_flutter_test/test/assists/goldens/convert_functional_provider_to_class_based/convert_functional_provider_to_class_based.diff index 47aeb2dbf..0980c5b6b 100644 --- a/packages/riverpod_lint_flutter_test/test/assists/goldens/convert_functional_provider_to_class_based/convert_functional_provider_to_class_based.diff +++ b/packages/riverpod_lint_flutter_test/test/assists/goldens/convert_functional_provider_to_class_based/convert_functional_provider_to_class_based.diff @@ -4,7 +4,7 @@ Diff for file `test/assists/convert_functional_provider_to_class_based/convert_f ``` /// Some comment @riverpod -- int example(ExampleRef ref) => 0; +- int example(Ref ref) => 0; + class Example extends _$Example { + @override + int build() => 0; @@ -19,7 +19,7 @@ Diff for file `test/assists/convert_functional_provider_to_class_based/convert_f ``` /// Some comment @riverpod -- int exampleFamily(ExampleFamilyRef ref, {required int a, String b = '42'}) { +- int exampleFamily(Ref ref, {required int a, String b = '42'}) { - // Hello world - return 0; + class ExampleFamily extends _$ExampleFamily { diff --git a/packages/riverpod_lint_flutter_test/test/assists/wrap_widget/wrap_widget_test.dart b/packages/riverpod_lint_flutter_test/test/assists/wrap_widget/wrap_widget_test.dart index fa9d77973..29c2d8212 100644 --- a/packages/riverpod_lint_flutter_test/test/assists/wrap_widget/wrap_widget_test.dart +++ b/packages/riverpod_lint_flutter_test/test/assists/wrap_widget/wrap_widget_test.dart @@ -1,7 +1,6 @@ import 'package:test/test.dart'; import 'package:riverpod_lint/src/assists/wrap_with_consumer.dart'; import 'package:riverpod_lint/src/assists/wrap_with_provider_scope.dart'; -import 'package:analyzer/source/source_range.dart'; import '../../test_lint.dart'; @@ -10,22 +9,19 @@ void main() { 'Wrap with consumer', 'test/assists/goldens/wrap_widget/wrap_with_consumer.diff', sourcePath: 'test/assists/wrap_widget/wrap_widget.dart', - (result) async { + (result, helper) async { final assist = WrapWithConsumer(); - var changes = [ - // Map - ...await assist.testRun(result, const SourceRange(224, 0)), + final cursors = helper.rangesForString(''' + Widget build(BuildContext context) { + Ma<>p(); - // Scaffold - ...await assist.testRun(result, const SourceRange(245, 0)), + return Scaf<>fold( + body: Conta<>iner(<>), + ); +'''); - // Container - ...await assist.testRun(result, const SourceRange(268, 0)), - - // Between () - ...await assist.testRun(result, const SourceRange(273, 0)), - ]; + final changes = await helper.runAssist(assist, result, cursors); expect(changes, hasLength(2)); @@ -37,22 +33,19 @@ void main() { 'Wrap with ProviderScope', 'test/assists/goldens/wrap_widget/wrap_with_provider_scope.diff', sourcePath: 'test/assists/wrap_widget/wrap_widget.dart', - (result) async { + (result, helper) async { final assist = WrapWithProviderScope(); - final changes = [ - // Map - ...await assist.testRun(result, const SourceRange(224, 0)), - - // Scaffold - ...await assist.testRun(result, const SourceRange(245, 0)), + final cursors = helper.rangesForString(''' + Widget build(BuildContext context) { + Ma<>p(); - // Container - ...await assist.testRun(result, const SourceRange(268, 0)), + return Scaf<>fold( + body: Conta<>iner(<>), + ); +'''); - // Between () - ...await assist.testRun(result, const SourceRange(273, 0)), - ]; + final changes = await helper.runAssist(assist, result, cursors); expect(changes, hasLength(2)); diff --git a/packages/riverpod_lint_flutter_test/test/encoders.dart b/packages/riverpod_lint_flutter_test/test/encoders.dart index 46ab91732..1905b2c81 100644 --- a/packages/riverpod_lint_flutter_test/test/encoders.dart +++ b/packages/riverpod_lint_flutter_test/test/encoders.dart @@ -13,12 +13,12 @@ import 'package:test/test.dart'; import 'golden.dart'; Matcher matchesPrioritizedSourceChangesGolden( - String fileName, { + File file, { required String source, required String sourcePath, }) { return matchersGoldenFile>( - File(fileName), + file, isEmpty: (value) => value.isEmpty, encode: (changes) { return encodePrioritizedSourceChanges( diff --git a/packages/riverpod_lint_flutter_test/test/lints/avoid_build_context_in_providers.dart b/packages/riverpod_lint_flutter_test/test/lints/avoid_build_context_in_providers.dart index f75dfb0e4..e3ca4231b 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/avoid_build_context_in_providers.dart +++ b/packages/riverpod_lint_flutter_test/test/lints/avoid_build_context_in_providers.dart @@ -7,7 +7,7 @@ part 'avoid_build_context_in_providers.g.dart'; @riverpod int fn( - FnRef ref, + Ref ref, // expect_lint: avoid_build_context_in_providers BuildContext context1, { // expect_lint: avoid_build_context_in_providers @@ -34,7 +34,7 @@ class MyNotifier extends _$MyNotifier { } @riverpod -class Regresion2959 extends _$Regresion2959 { +class Regression2959 extends _$Regression2959 { @override void build() {} diff --git a/packages/riverpod_lint_flutter_test/test/lints/avoid_build_context_in_providers.g.dart b/packages/riverpod_lint_flutter_test/test/lints/avoid_build_context_in_providers.g.dart index 065501b23..1254e1c65 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/avoid_build_context_in_providers.g.dart +++ b/packages/riverpod_lint_flutter_test/test/lints/avoid_build_context_in_providers.g.dart @@ -6,13 +6,11 @@ part of 'avoid_build_context_in_providers.dart'; // RiverpodGenerator // ************************************************************************** -typedef FnRef = Ref; - @ProviderFor(fn) const fnProvider = FnFamily._(); final class FnProvider extends $FunctionalProvider - with $Provider { + with $Provider { const FnProvider._( {required FnFamily super.from, required ( @@ -21,7 +19,7 @@ final class FnProvider extends $FunctionalProvider }) super.argument, int Function( - FnRef ref, + Ref ref, BuildContext context1, { required BuildContext context2, })? create}) @@ -35,7 +33,7 @@ final class FnProvider extends $FunctionalProvider ); final int Function( - FnRef ref, + Ref ref, BuildContext context1, { required BuildContext context2, })? _createCb; @@ -66,7 +64,7 @@ final class FnProvider extends $FunctionalProvider @override FnProvider $copyWithCreate( int Function( - FnRef ref, + Ref ref, ) create, ) { return FnProvider._( @@ -84,7 +82,7 @@ final class FnProvider extends $FunctionalProvider } @override - int create(FnRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? fn; final argument = this.argument as ( BuildContext, { @@ -108,7 +106,7 @@ final class FnProvider extends $FunctionalProvider } } -String _$fnHash() => r'7b8d0cf179067c80b8553b3232fd886fac83f387'; +String _$fnHash() => r'8a726da6104b38a55782e44062757e6771b19de3'; final class FnFamily extends Family { const FnFamily._() @@ -138,7 +136,7 @@ final class FnFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( int Function( - FnRef ref, + Ref ref, ( BuildContext, { BuildContext context2, @@ -227,7 +225,7 @@ final class MyNotifierProvider extends $NotifierProvider { @override MyNotifierProvider $copyWithBuild( int Function( - Ref, + Ref, MyNotifier, ) build, ) { @@ -313,7 +311,7 @@ final class MyNotifierFamily extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( int Function( - Ref ref, + Ref ref, MyNotifier notifier, ( BuildContext, { @@ -360,28 +358,28 @@ abstract class _$MyNotifier extends $Notifier { ); } -@ProviderFor(Regresion2959) -const regresion2959Provider = Regresion2959Provider._(); +@ProviderFor(Regression2959) +const regression2959Provider = Regression2959Provider._(); -final class Regresion2959Provider - extends $NotifierProvider { - const Regresion2959Provider._( - {super.runNotifierBuildOverride, Regresion2959 Function()? create}) +final class Regression2959Provider + extends $NotifierProvider { + const Regression2959Provider._( + {super.runNotifierBuildOverride, Regression2959 Function()? create}) : _createCb = create, super( from: null, argument: null, retry: null, - name: r'regresion2959Provider', + name: r'regression2959Provider', isAutoDispose: true, dependencies: null, allTransitiveDependencies: null, ); - final Regresion2959 Function()? _createCb; + final Regression2959 Function()? _createCb; @override - String debugGetCreateSourceHash() => _$regresion2959Hash(); + String debugGetCreateSourceHash() => _$regression2959Hash(); /// {@macro riverpod.override_with_value} Override overrideWithValue(void value) { @@ -393,37 +391,37 @@ final class Regresion2959Provider @$internal @override - Regresion2959 create() => _createCb?.call() ?? Regresion2959(); + Regression2959 create() => _createCb?.call() ?? Regression2959(); @$internal @override - Regresion2959Provider $copyWithCreate( - Regresion2959 Function() create, + Regression2959Provider $copyWithCreate( + Regression2959 Function() create, ) { - return Regresion2959Provider._(create: create); + return Regression2959Provider._(create: create); } @$internal @override - Regresion2959Provider $copyWithBuild( + Regression2959Provider $copyWithBuild( void Function( - Ref, - Regresion2959, + Ref, + Regression2959, ) build, ) { - return Regresion2959Provider._(runNotifierBuildOverride: build); + return Regression2959Provider._(runNotifierBuildOverride: build); } @$internal @override - $NotifierProviderElement $createElement( + $NotifierProviderElement $createElement( $ProviderPointer pointer) => $NotifierProviderElement(this, pointer); } -String _$regresion2959Hash() => r'bcf9a829ce75026a78569de680451d157c7d90a2'; +String _$regression2959Hash() => r'e58855125577a855d642da1ef85f35178ad95afd'; -abstract class _$Regresion2959 extends $Notifier { +abstract class _$Regression2959 extends $Notifier { void build(); @$internal @override @@ -431,4 +429,4 @@ abstract class _$Regresion2959 extends $Notifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/packages/riverpod_lint_flutter_test/test/lints/avoid_public_notifier_properties.g.dart b/packages/riverpod_lint_flutter_test/test/lints/avoid_public_notifier_properties.g.dart index 8c6ea6c4a..6de5b8755 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/avoid_public_notifier_properties.g.dart +++ b/packages/riverpod_lint_flutter_test/test/lints/avoid_public_notifier_properties.g.dart @@ -64,7 +64,7 @@ final class GeneratedNotifierProvider @override GeneratedNotifierProvider $copyWithBuild( int Function( - Ref, + Ref, GeneratedNotifier, ) build, ) { @@ -136,7 +136,7 @@ final class GeneratedNotifierFamily extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( - int Function(Ref ref, GeneratedNotifier notifier, int argument) build, + int Function(Ref ref, GeneratedNotifier notifier, int argument) build, ) { return $FamilyOverride( from: this, @@ -168,4 +168,4 @@ abstract class _$GeneratedNotifier extends $Notifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/packages/riverpod_lint_flutter_test/test/lints/functional_ref/failing_functional_ref.dart b/packages/riverpod_lint_flutter_test/test/lints/functional_ref/failing_functional_ref.dart index 984c3acf7..393aba95d 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/functional_ref/failing_functional_ref.dart +++ b/packages/riverpod_lint_flutter_test/test/lints/functional_ref/failing_functional_ref.dart @@ -20,3 +20,6 @@ int incorrectlyTyped( int noRefButArgs({int a = 42}) { return 0; } + +@riverpod +int valid(Ref ref) => 0; diff --git a/packages/riverpod_lint_flutter_test/test/lints/functional_ref/fix/failing_functional_ref.diff b/packages/riverpod_lint_flutter_test/test/lints/functional_ref/fix/failing_functional_ref.diff new file mode 100644 index 000000000..81cb4b72f --- /dev/null +++ b/packages/riverpod_lint_flutter_test/test/lints/functional_ref/fix/failing_functional_ref.diff @@ -0,0 +1,36 @@ +Message: `Add ref parameter` +Priority: 90 +Diff for file `test/lints/functional_ref/failing_functional_ref.dart:5`: +``` +@riverpod +// expect_lint: functional_ref +- int refless() { ++ int refless(Ref ref) { + return 0; +} +``` +--- +Message: `Type as Ref` +Priority: 90 +Diff for file `test/lints/functional_ref/failing_functional_ref.dart:12`: +``` +int incorrectlyTyped( + // expect_lint: functional_ref +- int ref, ++ Ref ref, +) { + return 0; +``` +--- +Message: `Add ref parameter` +Priority: 90 +Diff for file `test/lints/functional_ref/failing_functional_ref.dart:20`: +``` +@riverpod +// expect_lint: functional_ref +- int noRefButArgs({int a = 42}) { ++ int noRefButArgs(Ref ref, {int a = 42}) { + return 0; +} +``` +--- diff --git a/packages/riverpod_lint_flutter_test/test/lints/functional_ref/fix/functional_ref.diff b/packages/riverpod_lint_flutter_test/test/lints/functional_ref/fix/functional_ref.diff new file mode 100644 index 000000000..69204fe4d --- /dev/null +++ b/packages/riverpod_lint_flutter_test/test/lints/functional_ref/fix/functional_ref.diff @@ -0,0 +1,12 @@ +Message: `Type as Ref` +Priority: 90 +Diff for file `test/lints/functional_ref/functional_ref.dart:8`: +``` +int nameless( + // expect_lint: functional_ref +- ref, ++ Ref ref, +) { + return 0; +``` +--- diff --git a/packages/riverpod_lint_flutter_test/test/lints/functional_ref/fix/functional_ref_test.dart b/packages/riverpod_lint_flutter_test/test/lints/functional_ref/fix/functional_ref_test.dart new file mode 100644 index 000000000..34a4d87f6 --- /dev/null +++ b/packages/riverpod_lint_flutter_test/test/lints/functional_ref/fix/functional_ref_test.dart @@ -0,0 +1,42 @@ +import 'package:collection/collection.dart'; +import 'package:riverpod_lint/src/lints/functional_ref.dart'; + +import '../../../test_lint.dart'; + +void main() { + testGolden( + 'Verify that @riverpod functions have a Ref', + 'test/lints/functional_ref/fix/functional_ref.diff', + sourcePath: 'test/lints/functional_ref/functional_ref.dart', + (result, helper) async { + const lint = FunctionalRef(); + final fix = lint.getFixes().single; + + final errors = await lint.testRun(result); + + final changes = await Future.wait([ + for (final error in errors) fix.testRun(result, error, errors), + ]); + + return changes.flattened; + }, + ); + + testGolden( + 'Verify that @riverpod functions have a Ref', + 'test/lints/functional_ref/fix/failing_functional_ref.diff', + sourcePath: 'test/lints/functional_ref/failing_functional_ref.dart', + (result, helper) async { + const lint = FunctionalRef(); + final fix = lint.getFixes().single; + + final errors = await lint.testRun(result); + + final changes = await Future.wait([ + for (final error in errors) fix.testRun(result, error, errors), + ]); + + return changes.flattened; + }, + ); +} diff --git a/packages/riverpod_lint_flutter_test/test/lints/functional_ref/functional_ref.dart b/packages/riverpod_lint_flutter_test/test/lints/functional_ref/functional_ref.dart index b2f16d752..351164386 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/functional_ref/functional_ref.dart +++ b/packages/riverpod_lint_flutter_test/test/lints/functional_ref/functional_ref.dart @@ -11,16 +11,7 @@ int nameless( } @riverpod -int generics(GenericsRef ref) => 0; +int generics(Ref ref) => 0; @riverpod -// expect_lint: functional_ref -int noGenerics(NoGenericsRef ref) => 0; - -@riverpod -// expect_lint: functional_ref -int missingGenerics(MissingGenericsRef ref) => 0; - -@riverpod -// expect_lint: functional_ref -int wrongOrder(WrongOrderRef ref) => 0; +int valid(Ref ref) => 0; diff --git a/packages/riverpod_lint_flutter_test/test/lints/functional_ref/functional_ref.g.dart b/packages/riverpod_lint_flutter_test/test/lints/functional_ref/functional_ref.g.dart index 700e79762..16f8991e7 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/functional_ref/functional_ref.g.dart +++ b/packages/riverpod_lint_flutter_test/test/lints/functional_ref/functional_ref.g.dart @@ -6,16 +6,14 @@ part of 'functional_ref.dart'; // RiverpodGenerator // ************************************************************************** -typedef NamelessRef = Ref; - @ProviderFor(nameless) const namelessProvider = NamelessProvider._(); final class NamelessProvider extends $FunctionalProvider - with $Provider { + with $Provider { const NamelessProvider._( {int Function( - NamelessRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -29,7 +27,7 @@ final class NamelessProvider extends $FunctionalProvider ); final int Function( - NamelessRef ref, + Ref ref, )? _createCb; @override @@ -51,14 +49,14 @@ final class NamelessProvider extends $FunctionalProvider @override NamelessProvider $copyWithCreate( int Function( - NamelessRef ref, + Ref ref, ) create, ) { return NamelessProvider._(create: create); } @override - int create(NamelessRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? nameless; return _$cb(ref); } @@ -66,18 +64,15 @@ final class NamelessProvider extends $FunctionalProvider String _$namelessHash() => r'1a2aa61445a64c65301051820b159c5998195606'; -typedef GenericsRef = Ref; - @ProviderFor(generics) const genericsProvider = GenericsFamily._(); final class GenericsProvider - extends $FunctionalProvider - with $Provider> { + extends $FunctionalProvider with $Provider { const GenericsProvider._( {required GenericsFamily super.from, int Function( - GenericsRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -90,7 +85,7 @@ final class GenericsProvider ); final int Function( - GenericsRef ref, + Ref ref, )? _createCb; @override @@ -98,7 +93,7 @@ final class GenericsProvider GenericsProvider _copyWithCreate( int Function( - GenericsRef ref, + Ref ref, ) create, ) { return GenericsProvider._( @@ -128,7 +123,7 @@ final class GenericsProvider @override GenericsProvider $copyWithCreate( int Function( - GenericsRef ref, + Ref ref, ) create, ) { return GenericsProvider._( @@ -136,7 +131,7 @@ final class GenericsProvider } @override - int create(GenericsRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? generics; return _$cb(ref); } @@ -154,7 +149,7 @@ final class GenericsProvider } } -String _$genericsHash() => r'b5813cf6a00581bafea48d8ab66f7d5468fff0e4'; +String _$genericsHash() => r'dddbd6460e73b1f20343bbadee6666311c5ac0ea'; final class GenericsFamily extends Family { const GenericsFamily._() @@ -177,7 +172,7 @@ final class GenericsFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( - int Function(GenericsRef ref) create, + int Function(Ref ref) create, ) { return $FamilyOverride( from: this, @@ -190,297 +185,32 @@ final class GenericsFamily extends Family { } } -typedef NoGenericsRef = Ref; - -@ProviderFor(noGenerics) -const noGenericsProvider = NoGenericsFamily._(); - -final class NoGenericsProvider - extends $FunctionalProvider - with $Provider> { - const NoGenericsProvider._( - {required NoGenericsFamily super.from, - int Function( - NoGenericsRef ref, - )? create}) - : _createCb = create, - super( - argument: null, - retry: null, - name: r'noGenericsProvider', - isAutoDispose: true, - dependencies: null, - allTransitiveDependencies: null, - ); - - final int Function( - NoGenericsRef ref, - )? _createCb; - - @override - String debugGetCreateSourceHash() => _$noGenericsHash(); - - NoGenericsProvider _copyWithCreate( - int Function( - NoGenericsRef ref, - ) create, - ) { - return NoGenericsProvider._( - from: from! as NoGenericsFamily, create: create); - } - - @override - String toString() { - return r'noGenericsProvider' - '<${A}, ${B}>' - '()'; - } - - /// {@macro riverpod.override_with_value} - Override overrideWithValue(int value) { - return $ProviderOverride( - origin: this, - providerOverride: $ValueProvider(value), - ); - } +@ProviderFor(valid) +const validProvider = ValidProvider._(); - @$internal - @override - $ProviderElement $createElement($ProviderPointer pointer) => - $ProviderElement(this, pointer); - - @override - NoGenericsProvider $copyWithCreate( - int Function( - NoGenericsRef ref, - ) create, - ) { - return NoGenericsProvider._( - from: from! as NoGenericsFamily, create: create); - } - - @override - int create(NoGenericsRef ref) { - final _$cb = _createCb ?? noGenerics; - return _$cb(ref); - } - - @override - bool operator ==(Object other) { - return other is NoGenericsProvider && - other.runtimeType == runtimeType && - other.argument == argument; - } - - @override - int get hashCode { - return Object.hash(runtimeType, argument); - } -} - -String _$noGenericsHash() => r'449264e25990bc14ad811c0940117c8cde4d730a'; - -final class NoGenericsFamily extends Family { - const NoGenericsFamily._() - : super( - retry: null, - name: r'noGenericsProvider', - dependencies: null, - allTransitiveDependencies: null, - isAutoDispose: true, - ); - - NoGenericsProvider call() => - NoGenericsProvider._(from: this); - - @override - String debugGetCreateSourceHash() => _$noGenericsHash(); - - @override - String toString() => r'noGenericsProvider'; - - /// {@macro riverpod.override_with} - Override overrideWith( - int Function(NoGenericsRef ref) create, - ) { - return $FamilyOverride( - from: this, - createElement: (pointer) { - final provider = pointer.origin as NoGenericsProvider; - - return provider._copyWithCreate(create).$createElement(pointer); - }, - ); - } -} - -typedef MissingGenericsRef = Ref; - -@ProviderFor(missingGenerics) -const missingGenericsProvider = MissingGenericsFamily._(); - -final class MissingGenericsProvider extends $FunctionalProvider - with $Provider> { - const MissingGenericsProvider._( - {required MissingGenericsFamily super.from, - int Function( - MissingGenericsRef ref, - )? create}) - : _createCb = create, - super( - argument: null, - retry: null, - name: r'missingGenericsProvider', - isAutoDispose: true, - dependencies: null, - allTransitiveDependencies: null, - ); - - final int Function( - MissingGenericsRef ref, - )? _createCb; - - @override - String debugGetCreateSourceHash() => _$missingGenericsHash(); - - MissingGenericsProvider _copyWithCreate( - int Function( - MissingGenericsRef ref, - ) create, - ) { - return MissingGenericsProvider._( - from: from! as MissingGenericsFamily, create: create); - } - - @override - String toString() { - return r'missingGenericsProvider' - '<${A}, ${B}>' - '()'; - } - - /// {@macro riverpod.override_with_value} - Override overrideWithValue(int value) { - return $ProviderOverride( - origin: this, - providerOverride: $ValueProvider(value), - ); - } - - @$internal - @override - $ProviderElement $createElement($ProviderPointer pointer) => - $ProviderElement(this, pointer); - - @override - MissingGenericsProvider $copyWithCreate( - int Function( - MissingGenericsRef ref, - ) create, - ) { - return MissingGenericsProvider._( - from: from! as MissingGenericsFamily, create: create); - } - - @override - int create(MissingGenericsRef ref) { - final _$cb = _createCb ?? missingGenerics; - return _$cb(ref); - } - - @override - bool operator ==(Object other) { - return other is MissingGenericsProvider && - other.runtimeType == runtimeType && - other.argument == argument; - } - - @override - int get hashCode { - return Object.hash(runtimeType, argument); - } -} - -String _$missingGenericsHash() => r'7d8bc49e4f1e466260fbf6a61a3f9e62b4aef28f'; - -final class MissingGenericsFamily extends Family { - const MissingGenericsFamily._() - : super( - retry: null, - name: r'missingGenericsProvider', - dependencies: null, - allTransitiveDependencies: null, - isAutoDispose: true, - ); - - MissingGenericsProvider call() => - MissingGenericsProvider._(from: this); - - @override - String debugGetCreateSourceHash() => _$missingGenericsHash(); - - @override - String toString() => r'missingGenericsProvider'; - - /// {@macro riverpod.override_with} - Override overrideWith( - int Function(MissingGenericsRef ref) create, - ) { - return $FamilyOverride( - from: this, - createElement: (pointer) { - final provider = pointer.origin as MissingGenericsProvider; - - return provider._copyWithCreate(create).$createElement(pointer); - }, - ); - } -} - -typedef WrongOrderRef = Ref; - -@ProviderFor(wrongOrder) -const wrongOrderProvider = WrongOrderFamily._(); - -final class WrongOrderProvider extends $FunctionalProvider - with $Provider> { - const WrongOrderProvider._( - {required WrongOrderFamily super.from, - int Function( - WrongOrderRef ref, +final class ValidProvider extends $FunctionalProvider + with $Provider { + const ValidProvider._( + {int Function( + Ref ref, )? create}) : _createCb = create, super( + from: null, argument: null, retry: null, - name: r'wrongOrderProvider', + name: r'validProvider', isAutoDispose: true, dependencies: null, allTransitiveDependencies: null, ); final int Function( - WrongOrderRef ref, + Ref ref, )? _createCb; @override - String debugGetCreateSourceHash() => _$wrongOrderHash(); - - WrongOrderProvider _copyWithCreate( - int Function( - WrongOrderRef ref, - ) create, - ) { - return WrongOrderProvider._( - from: from! as WrongOrderFamily, create: create); - } - - @override - String toString() { - return r'wrongOrderProvider' - '<${B}, ${A}>' - '()'; - } + String debugGetCreateSourceHash() => _$validHash(); /// {@macro riverpod.override_with_value} Override overrideWithValue(int value) { @@ -496,68 +226,22 @@ final class WrongOrderProvider extends $FunctionalProvider $ProviderElement(this, pointer); @override - WrongOrderProvider $copyWithCreate( + ValidProvider $copyWithCreate( int Function( - WrongOrderRef ref, + Ref ref, ) create, ) { - return WrongOrderProvider._( - from: from! as WrongOrderFamily, create: create); + return ValidProvider._(create: create); } @override - int create(WrongOrderRef ref) { - final _$cb = _createCb ?? wrongOrder; + int create(Ref ref) { + final _$cb = _createCb ?? valid; return _$cb(ref); } - - @override - bool operator ==(Object other) { - return other is WrongOrderProvider && - other.runtimeType == runtimeType && - other.argument == argument; - } - - @override - int get hashCode { - return Object.hash(runtimeType, argument); - } } -String _$wrongOrderHash() => r'6732863e85b220c07f82c2d13be15c1e6f08192d'; - -final class WrongOrderFamily extends Family { - const WrongOrderFamily._() - : super( - retry: null, - name: r'wrongOrderProvider', - dependencies: null, - allTransitiveDependencies: null, - isAutoDispose: true, - ); - - WrongOrderProvider call() => - WrongOrderProvider._(from: this); - - @override - String debugGetCreateSourceHash() => _$wrongOrderHash(); - - @override - String toString() => r'wrongOrderProvider'; - - /// {@macro riverpod.override_with} - Override overrideWith( - int Function(WrongOrderRef ref) create, - ) { - return $FamilyOverride( - from: this, - createElement: (pointer) { - final provider = pointer.origin as WrongOrderProvider; +String _$validHash() => r'f33913278e3b1615927fe05b3e6e1f781da7729a'; - return provider._copyWithCreate(create).$createElement(pointer); - }, - ); - } -} // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/packages/riverpod_lint_flutter_test/test/lints/goldens/avoid_build_context_in_providers/avoid_build_context_in_providers_lint.md b/packages/riverpod_lint_flutter_test/test/lints/goldens/avoid_build_context_in_providers/avoid_build_context_in_providers_lint.md index 3a90d2915..589c4dde1 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/goldens/avoid_build_context_in_providers/avoid_build_context_in_providers_lint.md +++ b/packages/riverpod_lint_flutter_test/test/lints/goldens/avoid_build_context_in_providers/avoid_build_context_in_providers_lint.md @@ -4,7 +4,7 @@ message: Passing BuildContext to providers indicates mixing UI with the business test/lints/avoid_build_context_in_providers.dart:12:3 ```dart - FnRef ref, + Ref ref, // expect_lint: avoid_build_context_in_providers >>>BuildContext context1<<<, { // expect_lint: avoid_build_context_in_providers diff --git a/packages/riverpod_lint_flutter_test/test/lints/goldens/functional_ref/failing_functional_ref_fix.diff b/packages/riverpod_lint_flutter_test/test/lints/goldens/functional_ref/failing_functional_ref_fix.diff index 9ddd8c001..81cb4b72f 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/goldens/functional_ref/failing_functional_ref_fix.diff +++ b/packages/riverpod_lint_flutter_test/test/lints/goldens/functional_ref/failing_functional_ref_fix.diff @@ -5,20 +5,32 @@ Diff for file `test/lints/functional_ref/failing_functional_ref.dart:5`: @riverpod // expect_lint: functional_ref - int refless() { -+ int refless(ReflessRef ref) { ++ int refless(Ref ref) { return 0; } ``` --- -Message: `Type as IncorrectlyTypedRef` +Message: `Type as Ref` Priority: 90 Diff for file `test/lints/functional_ref/failing_functional_ref.dart:12`: ``` int incorrectlyTyped( // expect_lint: functional_ref - int ref, -+ IncorrectlyTypedRef ref, ++ Ref ref, ) { return 0; ``` --- +Message: `Add ref parameter` +Priority: 90 +Diff for file `test/lints/functional_ref/failing_functional_ref.dart:20`: +``` +@riverpod +// expect_lint: functional_ref +- int noRefButArgs({int a = 42}) { ++ int noRefButArgs(Ref ref, {int a = 42}) { + return 0; +} +``` +--- diff --git a/packages/riverpod_lint_flutter_test/test/lints/goldens/functional_ref/functional_ref_fix.diff b/packages/riverpod_lint_flutter_test/test/lints/goldens/functional_ref/functional_ref_fix.diff index b3dab2390..69204fe4d 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/goldens/functional_ref/functional_ref_fix.diff +++ b/packages/riverpod_lint_flutter_test/test/lints/goldens/functional_ref/functional_ref_fix.diff @@ -1,46 +1,12 @@ -Message: `Type as NamelessRef` +Message: `Type as Ref` Priority: 90 Diff for file `test/lints/functional_ref/functional_ref.dart:8`: ``` int nameless( // expect_lint: functional_ref - ref, -+ NamelessRef ref, ++ Ref ref, ) { return 0; ``` --- -Message: `Type as NoGenericsRef` -Priority: 90 -Diff for file `test/lints/functional_ref/functional_ref.dart:18`: -``` -@riverpod -// expect_lint: functional_ref -- int noGenerics(NoGenericsRef ref) => 0; -+ int noGenerics(NoGenericsRef ref) => 0; - -@riverpod -``` ---- -Message: `Type as MissingGenericsRef` -Priority: 90 -Diff for file `test/lints/functional_ref/functional_ref.dart:22`: -``` -@riverpod -// expect_lint: functional_ref -- int missingGenerics(MissingGenericsRef ref) => 0; -+ int missingGenerics(MissingGenericsRef ref) => 0; - -@riverpod -``` ---- -Message: `Type as WrongOrderRef` -Priority: 90 -Diff for file `test/lints/functional_ref/functional_ref.dart:26`: -``` -@riverpod -// expect_lint: functional_ref -- int wrongOrder(WrongOrderRef ref) => 0; -+ int wrongOrder(WrongOrderRef ref) => 0; -``` ---- diff --git a/packages/riverpod_lint_flutter_test/test/lints/goldens/functional_ref/functional_ref_lint.md b/packages/riverpod_lint_flutter_test/test/lints/goldens/functional_ref/functional_ref_lint.md index 941197123..9e76f32a7 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/goldens/functional_ref/functional_ref_lint.md +++ b/packages/riverpod_lint_flutter_test/test/lints/goldens/functional_ref/functional_ref_lint.md @@ -10,46 +10,3 @@ int nameless( ) { return 0; ``` - -======= - -code: functional_ref -severity: Severity.warning -message: Functional providers must receive a ref matching the provider name as their first positional parameter. -test/lints/functional_ref/functional_ref.dart:18:34 - -```dart -@riverpod -// expect_lint: functional_ref -int noGenerics(>>>NoGenericsRef<<< ref) => 0; - -@riverpod -``` - -======= - -code: functional_ref -severity: Severity.warning -message: Functional providers must receive a ref matching the provider name as their first positional parameter. -test/lints/functional_ref/functional_ref.dart:22:27 - -```dart -@riverpod -// expect_lint: functional_ref -int missingGenerics(>>>MissingGenericsRef<<< ref) => 0; - -@riverpod -``` - -======= - -code: functional_ref -severity: Severity.warning -message: Functional providers must receive a ref matching the provider name as their first positional parameter. -test/lints/functional_ref/functional_ref.dart:26:22 - -```dart -@riverpod -// expect_lint: functional_ref -int wrongOrder(>>>WrongOrderRef<<< ref) => 0; -``` diff --git a/packages/riverpod_lint_flutter_test/test/lints/goldens/notifier_extends/failing_notifier_extends_fix.diff b/packages/riverpod_lint_flutter_test/test/lints/goldens/notifier_extends/failing_notifier_extends_fix.diff new file mode 100644 index 000000000..5edb63ff6 --- /dev/null +++ b/packages/riverpod_lint_flutter_test/test/lints/goldens/notifier_extends/failing_notifier_extends_fix.diff @@ -0,0 +1,24 @@ +Message: `Extend _$NoExtends` +Priority: 90 +Diff for file `test/lints/notifier_extends/failing_notifier_extends.dart:6`: +``` +@riverpod +// expect_lint: notifier_extends +- class NoExtends { ++ class NoExtends extends _$NoExtends { + int build() => 0; +} +``` +--- +Message: `Extend _$WrongExtends` +Priority: 90 +Diff for file `test/lints/notifier_extends/failing_notifier_extends.dart:12`: +``` +@riverpod +// expect_lint: notifier_extends +- class WrongExtends extends AsyncNotifier { ++ class WrongExtends extends _$WrongExtends { + int build() => 0; +} +``` +--- diff --git a/packages/riverpod_lint_flutter_test/test/lints/goldens/notifier_extends/failing_notifier_extends_lint.md b/packages/riverpod_lint_flutter_test/test/lints/goldens/notifier_extends/failing_notifier_extends_lint.md new file mode 100644 index 000000000..4c0aeb796 --- /dev/null +++ b/packages/riverpod_lint_flutter_test/test/lints/goldens/notifier_extends/failing_notifier_extends_lint.md @@ -0,0 +1,27 @@ +code: notifier_extends +severity: Severity.warning +message: Classes annotated by @riverpod must extend _$ClassName +test/lints/notifier_extends/failing_notifier_extends.dart:6:7 + +```dart +@riverpod +// expect_lint: notifier_extends +class >>>NoExtends<<< { + int build() => 0; +} +``` + +======= + +code: notifier_extends +severity: Severity.warning +message: Classes annotated by @riverpod must extend _$ClassName +test/lints/notifier_extends/failing_notifier_extends.dart:12:28 + +```dart +@riverpod +// expect_lint: notifier_extends +class WrongExtends extends >>>AsyncNotifier<<< { + int build() => 0; +} +``` diff --git a/packages/riverpod_lint_flutter_test/test/lints/goldens/notifier_extends/notifier_extends_fix.diff b/packages/riverpod_lint_flutter_test/test/lints/goldens/notifier_extends/notifier_extends_fix.diff index 49a064dd5..ba14cfc6d 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/goldens/notifier_extends/notifier_extends_fix.diff +++ b/packages/riverpod_lint_flutter_test/test/lints/goldens/notifier_extends/notifier_extends_fix.diff @@ -1,30 +1,6 @@ -Message: `Extend _$NoExtends` -Priority: 90 -Diff for file `test/lints/notifier_extends.dart:15`: -``` -@riverpod -// expect_lint: notifier_extends -- class NoExtends { -+ class NoExtends extends _$NoExtends { - int build() => 0; -} -``` ---- -Message: `Extend _$WrongExtends` -Priority: 90 -Diff for file `test/lints/notifier_extends.dart:21`: -``` -@riverpod -// expect_lint: notifier_extends -- class WrongExtends extends AsyncNotifier { -+ class WrongExtends extends _$WrongExtends { - int build() => 0; -} -``` ---- Message: `Extend _$NoGenerics` Priority: 90 -Diff for file `test/lints/notifier_extends.dart:39`: +Diff for file `test/lints/notifier_extends/notifier_extends.dart:26`: ``` @riverpod // expect_lint: notifier_extends @@ -36,7 +12,7 @@ Diff for file `test/lints/notifier_extends.dart:39`: --- Message: `Extend _$MissingGenerics` Priority: 90 -Diff for file `test/lints/notifier_extends.dart:45`: +Diff for file `test/lints/notifier_extends/notifier_extends.dart:32`: ``` @riverpod // expect_lint: notifier_extends @@ -48,7 +24,7 @@ Diff for file `test/lints/notifier_extends.dart:45`: --- Message: `Extend _$WrongOrder` Priority: 90 -Diff for file `test/lints/notifier_extends.dart:51`: +Diff for file `test/lints/notifier_extends/notifier_extends.dart:38`: ``` @riverpod // expect_lint: notifier_extends diff --git a/packages/riverpod_lint_flutter_test/test/lints/goldens/notifier_extends/notifier_extends_lint.md b/packages/riverpod_lint_flutter_test/test/lints/goldens/notifier_extends/notifier_extends_lint.md index 03dd8b072..d573cb8c3 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/goldens/notifier_extends/notifier_extends_lint.md +++ b/packages/riverpod_lint_flutter_test/test/lints/goldens/notifier_extends/notifier_extends_lint.md @@ -1,37 +1,7 @@ code: notifier_extends severity: Severity.warning message: Classes annotated by @riverpod must extend _$ClassName -test/lints/notifier_extends.dart:15:7 - -```dart -@riverpod -// expect_lint: notifier_extends -class >>>NoExtends<<< { - int build() => 0; -} -``` - -======= - -code: notifier_extends -severity: Severity.warning -message: Classes annotated by @riverpod must extend _$ClassName -test/lints/notifier_extends.dart:21:28 - -```dart -@riverpod -// expect_lint: notifier_extends -class WrongExtends extends >>>AsyncNotifier<<< { - int build() => 0; -} -``` - -======= - -code: notifier_extends -severity: Severity.warning -message: Classes annotated by @riverpod must extend _$ClassName -test/lints/notifier_extends.dart:39:44 +test/lints/notifier_extends/notifier_extends.dart:26:44 ```dart @riverpod @@ -46,7 +16,7 @@ class NoGenerics extends >>>_$NoGenerics<<< { code: notifier_extends severity: Severity.warning message: Classes annotated by @riverpod must extend _$ClassName -test/lints/notifier_extends.dart:45:37 +test/lints/notifier_extends/notifier_extends.dart:32:37 ```dart @riverpod @@ -61,7 +31,7 @@ class MissingGenerics extends >>>_$MissingGenerics<<< { code: notifier_extends severity: Severity.warning message: Classes annotated by @riverpod must extend _$ClassName -test/lints/notifier_extends.dart:51:32 +test/lints/notifier_extends/notifier_extends.dart:38:32 ```dart @riverpod diff --git a/packages/riverpod_lint_flutter_test/test/lints/goldens/provider_dependencies/missing_dependencies2_fix.diff b/packages/riverpod_lint_flutter_test/test/lints/goldens/provider_dependencies/missing_dependencies2_fix.diff index f235d5684..6ca7213de 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/goldens/provider_dependencies/missing_dependencies2_fix.diff +++ b/packages/riverpod_lint_flutter_test/test/lints/goldens/provider_dependencies/missing_dependencies2_fix.diff @@ -1,30 +1,75 @@ Message: `Specify "dependencies"` Priority: 100 -Diff for file `test/lints/provider_dependencies/missing_dependencies2.dart:31`: +Diff for file `test/lints/provider_dependencies/missing_dependencies2.dart:32`: ``` // expect_lint: provider_dependencies - @riverpod + @Riverpod(dependencies: [generatedScoped]) int watchGeneratedScopedButNoDependencies( - WatchGeneratedScopedButNoDependenciesRef ref, + Ref ref, ``` --- Message: `Update "dependencies"` Priority: 100 -Diff for file `test/lints/provider_dependencies/missing_dependencies2.dart:57`: +Diff for file `test/lints/provider_dependencies/missing_dependencies2.dart:60`: ``` // expect_lint: provider_dependencies - @Riverpod(dependencies: []) + @Riverpod(dependencies: [generatedScoped]) int watchGeneratedScopedButEmptyDependencies( - WatchGeneratedScopedButEmptyDependenciesRef ref, + Ref ref, +``` +--- +Message: `Update "dependencies"` +Priority: 100 +Diff for file `test/lints/provider_dependencies/missing_dependencies2.dart:92`: +``` + +// expect_lint: provider_dependencies +- @Riverpod(dependencies: [dep]) ++ @Riverpod(dependencies: [dep, generatedScoped]) +int watchGeneratedScopedButMissingDependencies( + Ref ref, +``` +--- +Message: `Remove "dependencies"` +Priority: 100 +Diff for file `test/lints/provider_dependencies/missing_dependencies2.dart:123`: +``` +} + +- @Riverpod( +- dependencies: +- // The dependency is redundant because it is not a scoped provider +- // expect_lint: provider_dependencies +- [ +- generatedRoot, +- ], +- ) ++ @riverpod +int watchGeneratedRootAndContainsDependency( + Ref ref, +``` +--- +Message: `Update "dependencies"` +Priority: 100 +Diff for file `test/lints/provider_dependencies/missing_dependencies2.dart:142`: +``` + // generatedRoot is extra + // expect_lint: provider_dependencies +- [ +- dep, +- generatedRoot, ++ [dep]) +int specifiedDependencyButNeverUsed(Ref ref) { + ref.watch(depProvider); ``` --- Message: `Remove "dependencies"` Priority: 100 -Diff for file `test/lints/provider_dependencies/missing_dependencies2.dart:155`: +Diff for file `test/lints/provider_dependencies/missing_dependencies2.dart:224`: ``` class MemberDependencies { // expect_lint: provider_dependencies @@ -36,7 +81,7 @@ class MemberDependencies { --- Message: `Update "dependencies"` Priority: 100 -Diff for file `test/lints/provider_dependencies/missing_dependencies2.dart:163`: +Diff for file `test/lints/provider_dependencies/missing_dependencies2.dart:232`: ``` class CanUpdateMultipleDependenciesAtOnce { // expect_lint: provider_dependencies @@ -48,7 +93,7 @@ class CanUpdateMultipleDependenciesAtOnce { --- Message: `Update "dependencies"` Priority: 100 -Diff for file `test/lints/provider_dependencies/missing_dependencies2.dart:160`: +Diff for file `test/lints/provider_dependencies/missing_dependencies2.dart:229`: ``` // expect_lint: provider_dependencies @@ -60,7 +105,7 @@ class CanUpdateMultipleDependenciesAtOnce { --- Message: `Remove "dependencies"` Priority: 100 -Diff for file `test/lints/provider_dependencies/missing_dependencies2.dart:183`: +Diff for file `test/lints/provider_dependencies/missing_dependencies2.dart:252`: ``` // Handle identifiers with dependencies // expect_lint: provider_dependencies @@ -72,7 +117,7 @@ void fn() {} --- Message: `Specify "dependencies"` Priority: 100 -Diff for file `test/lints/provider_dependencies/missing_dependencies2.dart:187`: +Diff for file `test/lints/provider_dependencies/missing_dependencies2.dart:256`: ``` // expect_lint: provider_dependencies @@ -85,19 +130,19 @@ Diff for file `test/lints/provider_dependencies/missing_dependencies2.dart:187`: --- Message: `Specify "dependencies"` Priority: 100 -Diff for file `test/lints/provider_dependencies/missing_dependencies2.dart:195`: +Diff for file `test/lints/provider_dependencies/missing_dependencies2.dart:264`: ``` // expect_lint: provider_dependencies - @riverpod + @Riverpod(dependencies: [dep]) -int foo(FooRef ref) { +int foo(Ref ref) { fn(); ``` --- Message: `Specify "dependencies"` Priority: 100 -Diff for file `test/lints/provider_dependencies/missing_dependencies2.dart:212`: +Diff for file `test/lints/provider_dependencies/missing_dependencies2.dart:281`: ``` // expect_lint: provider_dependencies @@ -110,7 +155,7 @@ Diff for file `test/lints/provider_dependencies/missing_dependencies2.dart:212`: --- Message: `Update "dependencies"` Priority: 100 -Diff for file `test/lints/provider_dependencies/missing_dependencies2.dart:243`: +Diff for file `test/lints/provider_dependencies/missing_dependencies2.dart:312`: ``` // expect_lint: provider_dependencies @@ -122,7 +167,7 @@ class Stateful2 extends StatefulWidget { --- Message: `Specify "dependencies"` Priority: 100 -Diff for file `test/lints/provider_dependencies/missing_dependencies2.dart:259`: +Diff for file `test/lints/provider_dependencies/missing_dependencies2.dart:328`: ``` // expect_lint: provider_dependencies @@ -135,13 +180,13 @@ Diff for file `test/lints/provider_dependencies/missing_dependencies2.dart:259`: --- Message: `Specify "dependencies"` Priority: 100 -Diff for file `test/lints/provider_dependencies/missing_dependencies2.dart:272`: +Diff for file `test/lints/provider_dependencies/missing_dependencies2.dart:341`: ``` // expect_lint: provider_dependencies - @riverpod + @Riverpod(dependencies: [anotherNonEmptyScoped]) -int crossFileDependency(CrossFileDependencyRef ref) { +int crossFileDependency(Ref ref) { ref.watch(anotherNonEmptyScopedProvider); ``` --- diff --git a/packages/riverpod_lint_flutter_test/test/lints/goldens/provider_dependencies/missing_dependencies2_lint.md b/packages/riverpod_lint_flutter_test/test/lints/goldens/provider_dependencies/missing_dependencies2_lint.md index 47da384f1..8b9fb8e7d 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/goldens/provider_dependencies/missing_dependencies2_lint.md +++ b/packages/riverpod_lint_flutter_test/test/lints/goldens/provider_dependencies/missing_dependencies2_lint.md @@ -2,24 +2,24 @@ code: provider_dependencies severity: Severity.warning contextMessages: message: generatedScoped - test/lints/provider_dependencies/missing_dependencies2.dart:35:20 + test/lints/provider_dependencies/missing_dependencies2.dart:36:20 ```dart - WatchGeneratedScopedButNoDependenciesRef ref, + Ref ref, ) { return ref.watch(>>>generatedScopedProvider<<<); } ``` message: Missing dependencies: generatedScoped -test/lints/provider_dependencies/missing_dependencies2.dart:31:1 +test/lints/provider_dependencies/missing_dependencies2.dart:32:1 ```dart // expect_lint: provider_dependencies >>>@riverpod<<< int watchGeneratedScopedButNoDependencies( - WatchGeneratedScopedButNoDependenciesRef ref, + Ref ref, ``` ======= @@ -28,24 +28,85 @@ code: provider_dependencies severity: Severity.warning contextMessages: message: generatedScoped - test/lints/provider_dependencies/missing_dependencies2.dart:61:20 + test/lints/provider_dependencies/missing_dependencies2.dart:64:20 ```dart - WatchGeneratedScopedButEmptyDependenciesRef ref, + Ref ref, ) { return ref.watch(>>>generatedScopedProvider<<<); } ``` message: Missing dependencies: generatedScoped -test/lints/provider_dependencies/missing_dependencies2.dart:57:25 +test/lints/provider_dependencies/missing_dependencies2.dart:60:25 ```dart // expect_lint: provider_dependencies @Riverpod(dependencies: >>>[]<<<) int watchGeneratedScopedButEmptyDependencies( - WatchGeneratedScopedButEmptyDependenciesRef ref, + Ref ref, +``` + +======= + +code: provider_dependencies +severity: Severity.warning +contextMessages: + message: generatedScoped + test/lints/provider_dependencies/missing_dependencies2.dart:97:20 + + ```dart + ) { + ref.watch(depProvider); + return ref.watch(>>>generatedScopedProvider<<<); + } + + ``` +message: Missing dependencies: generatedScoped +test/lints/provider_dependencies/missing_dependencies2.dart:92:25 + +```dart + +// expect_lint: provider_dependencies +@Riverpod(dependencies: >>>[dep]<<<) +int watchGeneratedScopedButMissingDependencies( + Ref ref, +``` + +======= + +code: provider_dependencies +severity: Severity.warning +message: Unused dependencies: generatedRoot +test/lints/provider_dependencies/missing_dependencies2.dart:127:7 + +```dart + // The dependency is redundant because it is not a scoped provider + // expect_lint: provider_dependencies + >>>[ + generatedRoot, + ]<<<, +) +int watchGeneratedRootAndContainsDependency( +``` + +======= + +code: provider_dependencies +severity: Severity.warning +message: Unused dependencies: generatedRoot +test/lints/provider_dependencies/missing_dependencies2.dart:142:5 + +```dart + // generatedRoot is extra + // expect_lint: provider_dependencies + >>>[ + dep, + generatedRoot, +]<<<) +int specifiedDependencyButNeverUsed(Ref ref) { + ref.watch(depProvider); ``` ======= @@ -53,7 +114,7 @@ int watchGeneratedScopedButEmptyDependencies( code: provider_dependencies severity: Severity.warning message: Unused dependencies: dep -test/lints/provider_dependencies/missing_dependencies2.dart:155:17 +test/lints/provider_dependencies/missing_dependencies2.dart:224:17 ```dart class MemberDependencies { @@ -69,7 +130,7 @@ code: provider_dependencies severity: Severity.warning contextMessages: message: dep - test/lints/provider_dependencies/missing_dependencies2.dart:165:15 + test/lints/provider_dependencies/missing_dependencies2.dart:234:15 ```dart @Dependencies([]) @@ -79,7 +140,7 @@ contextMessages: } ``` message: Missing dependencies: dep -test/lints/provider_dependencies/missing_dependencies2.dart:163:17 +test/lints/provider_dependencies/missing_dependencies2.dart:232:17 ```dart class CanUpdateMultipleDependenciesAtOnce { @@ -95,7 +156,7 @@ code: provider_dependencies severity: Severity.warning contextMessages: message: dep - test/lints/provider_dependencies/missing_dependencies2.dart:165:15 + test/lints/provider_dependencies/missing_dependencies2.dart:234:15 ```dart @Dependencies([]) @@ -105,7 +166,7 @@ contextMessages: } ``` message: Missing dependencies: dep -test/lints/provider_dependencies/missing_dependencies2.dart:160:15 +test/lints/provider_dependencies/missing_dependencies2.dart:229:15 ```dart @@ -120,7 +181,7 @@ class CanUpdateMultipleDependenciesAtOnce { code: provider_dependencies severity: Severity.warning message: Unused dependencies: dep -test/lints/provider_dependencies/missing_dependencies2.dart:183:15 +test/lints/provider_dependencies/missing_dependencies2.dart:252:15 ```dart // Handle identifiers with dependencies @@ -136,7 +197,7 @@ code: provider_dependencies severity: Severity.warning contextMessages: message: dep - test/lints/provider_dependencies/missing_dependencies2.dart:188:3 + test/lints/provider_dependencies/missing_dependencies2.dart:257:3 ```dart // expect_lint: provider_dependencies @@ -146,7 +207,7 @@ contextMessages: ``` message: Missing dependencies: dep -test/lints/provider_dependencies/missing_dependencies2.dart:187:1 +test/lints/provider_dependencies/missing_dependencies2.dart:256:1 ```dart @@ -164,23 +225,23 @@ code: provider_dependencies severity: Severity.warning contextMessages: message: dep - test/lints/provider_dependencies/missing_dependencies2.dart:197:3 + test/lints/provider_dependencies/missing_dependencies2.dart:266:3 ```dart @riverpod - int foo(FooRef ref) { + int foo(Ref ref) { >>>fn<<<(); return 0; } ``` message: Missing dependencies: dep -test/lints/provider_dependencies/missing_dependencies2.dart:195:1 +test/lints/provider_dependencies/missing_dependencies2.dart:264:1 ```dart // expect_lint: provider_dependencies >>>@riverpod<<< -int foo(FooRef ref) { +int foo(Ref ref) { fn(); ``` @@ -190,7 +251,7 @@ code: provider_dependencies severity: Severity.warning contextMessages: message: dep - test/lints/provider_dependencies/missing_dependencies2.dart:215:12 + test/lints/provider_dependencies/missing_dependencies2.dart:284:12 ```dart @override @@ -200,7 +261,7 @@ contextMessages: } ``` message: Missing dependencies: dep -test/lints/provider_dependencies/missing_dependencies2.dart:212:1 +test/lints/provider_dependencies/missing_dependencies2.dart:281:1 ```dart @@ -221,7 +282,7 @@ code: provider_dependencies severity: Severity.warning contextMessages: message: dep - test/lints/provider_dependencies/missing_dependencies2.dart:254:12 + test/lints/provider_dependencies/missing_dependencies2.dart:323:12 ```dart @override @@ -231,7 +292,7 @@ contextMessages: } ``` message: Missing dependencies: dep -test/lints/provider_dependencies/missing_dependencies2.dart:243:15 +test/lints/provider_dependencies/missing_dependencies2.dart:312:15 ```dart @@ -247,7 +308,7 @@ code: provider_dependencies severity: Severity.warning contextMessages: message: dep - test/lints/provider_dependencies/missing_dependencies2.dart:268:41 + test/lints/provider_dependencies/missing_dependencies2.dart:337:41 ```dart class _Stateful3State extends State { @@ -257,7 +318,7 @@ contextMessages: ``` message: Missing dependencies: dep -test/lints/provider_dependencies/missing_dependencies2.dart:259:1 +test/lints/provider_dependencies/missing_dependencies2.dart:328:1 ```dart @@ -278,22 +339,22 @@ code: provider_dependencies severity: Severity.warning contextMessages: message: anotherNonEmptyScoped - test/lints/provider_dependencies/missing_dependencies2.dart:274:13 + test/lints/provider_dependencies/missing_dependencies2.dart:343:13 ```dart @riverpod - int crossFileDependency(CrossFileDependencyRef ref) { + int crossFileDependency(Ref ref) { ref.watch(>>>anotherNonEmptyScopedProvider<<<); return 0; } ``` message: Missing dependencies: anotherNonEmptyScoped -test/lints/provider_dependencies/missing_dependencies2.dart:272:1 +test/lints/provider_dependencies/missing_dependencies2.dart:341:1 ```dart // expect_lint: provider_dependencies >>>@riverpod<<< -int crossFileDependency(CrossFileDependencyRef ref) { +int crossFileDependency(Ref ref) { ref.watch(anotherNonEmptyScopedProvider); ``` diff --git a/packages/riverpod_lint_flutter_test/test/lints/goldens/provider_dependencies/missing_dependencies_fix.diff b/packages/riverpod_lint_flutter_test/test/lints/goldens/provider_dependencies/missing_dependencies_fix.diff index bcee91f6b..78d2d523c 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/goldens/provider_dependencies/missing_dependencies_fix.diff +++ b/packages/riverpod_lint_flutter_test/test/lints/goldens/provider_dependencies/missing_dependencies_fix.diff @@ -42,7 +42,7 @@ Diff for file `test/lints/provider_dependencies/missing_dependencies.dart:77`: // expect_lint: provider_dependencies - @riverpod + @Riverpod(dependencies: [dep]) -int plainAnnotation(PlainAnnotationRef ref) { +int plainAnnotation(Ref ref) { ref.watch(depProvider); ``` --- @@ -54,7 +54,7 @@ Diff for file `test/lints/provider_dependencies/missing_dependencies.dart:84`: // expect_lint: provider_dependencies - @Riverpod(keepAlive: false) + @Riverpod(keepAlive: false, dependencies: [dep]) -int customAnnotation(CustomAnnotationRef ref) { +int customAnnotation(Ref ref) { ref.watch(depProvider); ``` --- @@ -79,7 +79,7 @@ Diff for file `test/lints/provider_dependencies/missing_dependencies.dart:104`: - dependencies: [], + dependencies: [dep], ) -int existingDep(ExistingDepRef ref) { +int existingDep(Ref ref) { ``` --- Message: `Update "dependencies"` @@ -91,7 +91,7 @@ Diff for file `test/lints/provider_dependencies/missing_dependencies.dart:114`: - dependencies: [], + dependencies: [dep, dep2], ) -int multipleDeps(MultipleDepsRef ref) { +int multipleDeps(Ref ref) { ``` --- Message: `Specify "dependencies"` diff --git a/packages/riverpod_lint_flutter_test/test/lints/goldens/provider_dependencies/missing_dependencies_lint.md b/packages/riverpod_lint_flutter_test/test/lints/goldens/provider_dependencies/missing_dependencies_lint.md index 37698ae8a..2ca7be720 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/goldens/provider_dependencies/missing_dependencies_lint.md +++ b/packages/riverpod_lint_flutter_test/test/lints/goldens/provider_dependencies/missing_dependencies_lint.md @@ -51,7 +51,7 @@ contextMessages: ```dart @riverpod - int plainAnnotation(PlainAnnotationRef ref) { + int plainAnnotation(Ref ref) { ref.watch(>>>depProvider<<<); return 0; } @@ -63,7 +63,7 @@ test/lints/provider_dependencies/missing_dependencies.dart:77:1 // expect_lint: provider_dependencies >>>@riverpod<<< -int plainAnnotation(PlainAnnotationRef ref) { +int plainAnnotation(Ref ref) { ref.watch(depProvider); ``` @@ -77,7 +77,7 @@ contextMessages: ```dart @Riverpod(keepAlive: false) - int customAnnotation(CustomAnnotationRef ref) { + int customAnnotation(Ref ref) { ref.watch(>>>depProvider<<<); return 0; } @@ -89,7 +89,7 @@ test/lints/provider_dependencies/missing_dependencies.dart:84:1 // expect_lint: provider_dependencies >>>@Riverpod(keepAlive: false)<<< -int customAnnotation(CustomAnnotationRef ref) { +int customAnnotation(Ref ref) { ref.watch(depProvider); ``` @@ -102,7 +102,7 @@ contextMessages: test/lints/provider_dependencies/missing_dependencies.dart:97:13 ```dart - CustomAnnotationWithTrailingCommaRef ref, + Ref ref, ) { ref.watch(>>>depProvider<<<); return 0; @@ -118,7 +118,7 @@ test/lints/provider_dependencies/missing_dependencies.dart:91:1 keepAlive: false, )<<< int customAnnotationWithTrailingComma( - CustomAnnotationWithTrailingCommaRef ref, + Ref ref, ``` ======= @@ -131,7 +131,7 @@ contextMessages: ```dart ) - int existingDep(ExistingDepRef ref) { + int existingDep(Ref ref) { ref.watch(>>>depProvider<<<); return 0; } @@ -144,7 +144,7 @@ test/lints/provider_dependencies/missing_dependencies.dart:104:17 // expect_lint: provider_dependencies dependencies: >>>[]<<<, ) -int existingDep(ExistingDepRef ref) { +int existingDep(Ref ref) { ``` ======= @@ -157,7 +157,7 @@ contextMessages: ```dart ) - int multipleDeps(MultipleDepsRef ref) { + int multipleDeps(Ref ref) { ref.watch(>>>depProvider<<<); ref.watch(dep2Provider); return 0; @@ -167,7 +167,7 @@ contextMessages: test/lints/provider_dependencies/missing_dependencies.dart:118:13 ```dart - int multipleDeps(MultipleDepsRef ref) { + int multipleDeps(Ref ref) { ref.watch(depProvider); ref.watch(>>>dep2Provider<<<); return 0; @@ -181,7 +181,7 @@ test/lints/provider_dependencies/missing_dependencies.dart:114:17 // expect_lint: provider_dependencies dependencies: >>>[]<<<, ) -int multipleDeps(MultipleDepsRef ref) { +int multipleDeps(Ref ref) { ``` ======= diff --git a/packages/riverpod_lint_flutter_test/test/lints/goldens/provider_dependencies/unused_dependency_fix.diff b/packages/riverpod_lint_flutter_test/test/lints/goldens/provider_dependencies/unused_dependency_fix.diff index 1c4036b23..8537bff58 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/goldens/provider_dependencies/unused_dependency_fix.diff +++ b/packages/riverpod_lint_flutter_test/test/lints/goldens/provider_dependencies/unused_dependency_fix.diff @@ -10,7 +10,7 @@ Diff for file `test/lints/provider_dependencies/unused_dependency.dart:22`: - ], + dependencies: [dep2], ) -int extraDep(ExtraDepRef ref) { +int extraDep(Ref ref) { ``` --- Message: `Remove "dependencies"` @@ -25,7 +25,7 @@ Diff for file `test/lints/provider_dependencies/unused_dependency.dart:34`: - ], - ) + ) -int noDep(NoDepRef ref) { +int noDep(Ref ref) { return 0; ``` --- @@ -41,7 +41,7 @@ Diff for file `test/lints/provider_dependencies/unused_dependency.dart:45`: - keepAlive: false, + keepAlive: false, ) -int dependenciesFirstThenKeepAlive(DependenciesFirstThenKeepAliveRef ref) { +int dependenciesFirstThenKeepAlive(Ref ref) { ``` --- Message: `Remove "dependencies"` @@ -57,7 +57,7 @@ Diff for file `test/lints/provider_dependencies/unused_dependency.dart:54`: - ], - ) + @riverpod -int noDepNoParam(NoDepNoParamRef ref) { +int noDepNoParam(Ref ref) { return 0; ``` --- @@ -69,7 +69,7 @@ Diff for file `test/lints/provider_dependencies/unused_dependency.dart:65`: // expect_lint: provider_dependencies - @Riverpod(keepAlive: false, dependencies: [dep]) + @Riverpod(keepAlive: false) -int noDepWithoutComma(NoDepWithoutCommaRef ref) { +int noDepWithoutComma(Ref ref) { return 0; ``` --- @@ -85,7 +85,7 @@ Diff for file `test/lints/provider_dependencies/unused_dependency.dart:72`: - ], - ) + ) -int rootDep(RootDepRef ref) => 0; +int rootDep(Ref ref) => 0; ``` --- diff --git a/packages/riverpod_lint_flutter_test/test/lints/goldens/provider_dependencies/unused_dependency_lint.md b/packages/riverpod_lint_flutter_test/test/lints/goldens/provider_dependencies/unused_dependency_lint.md index 1715ef512..69ef74d66 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/goldens/provider_dependencies/unused_dependency_lint.md +++ b/packages/riverpod_lint_flutter_test/test/lints/goldens/provider_dependencies/unused_dependency_lint.md @@ -11,7 +11,7 @@ test/lints/provider_dependencies/unused_dependency.dart:22:17 dep2, ]<<<, ) -int extraDep(ExtraDepRef ref) { +int extraDep(Ref ref) { ``` ======= @@ -28,7 +28,7 @@ test/lints/provider_dependencies/unused_dependency.dart:35:17 dep, ]<<<, ) -int noDep(NoDepRef ref) { +int noDep(Ref ref) { ``` ======= @@ -62,7 +62,7 @@ test/lints/provider_dependencies/unused_dependency.dart:56:17 dep, ]<<<, ) -int noDepNoParam(NoDepNoParamRef ref) { +int noDepNoParam(Ref ref) { ``` ======= @@ -76,7 +76,7 @@ test/lints/provider_dependencies/unused_dependency.dart:65:43 // expect_lint: provider_dependencies @Riverpod(keepAlive: false, dependencies: >>>[dep]<<<) -int noDepWithoutComma(NoDepWithoutCommaRef ref) { +int noDepWithoutComma(Ref ref) { return 0; ``` @@ -94,7 +94,7 @@ test/lints/provider_dependencies/unused_dependency.dart:73:17 root, ]<<<, ) -int rootDep(RootDepRef ref) => 0; +int rootDep(Ref ref) => 0; ``` ======= diff --git a/packages/riverpod_lint_flutter_test/test/lints/goldens/unknown_scoped_usage/unknown_scoped_usage_lint.md b/packages/riverpod_lint_flutter_test/test/lints/goldens/unknown_scoped_usage/unknown_scoped_usage_lint.md index 291f9421c..16b6c5a5d 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/goldens/unknown_scoped_usage/unknown_scoped_usage_lint.md +++ b/packages/riverpod_lint_flutter_test/test/lints/goldens/unknown_scoped_usage/unknown_scoped_usage_lint.md @@ -4,7 +4,7 @@ message: A provider was used, but could not find the associated `ref`. test/lints/unknown_scoped_usage.dart:16:3 ```dart -void fn(WidgetRef widgetRef, Ref ref) { +void fn(WidgetRef widgetRef, Ref ref) { // expect_lint: unknown_scoped_usage >>>scopedProvider<<<; rootProvider; diff --git a/packages/riverpod_lint_flutter_test/test/lints/goldens/unsupported_provider_value/unsupported_provider_value_lint.md b/packages/riverpod_lint_flutter_test/test/lints/goldens/unsupported_provider_value/unsupported_provider_value_lint.md index 0abe96313..52e37eb86 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/goldens/unsupported_provider_value/unsupported_provider_value_lint.md +++ b/packages/riverpod_lint_flutter_test/test/lints/goldens/unsupported_provider_value/unsupported_provider_value_lint.md @@ -7,7 +7,7 @@ test/lints/unsupported_provider_value.dart:13:17 ```dart @riverpod // expect_lint: unsupported_provider_value -MyStateNotifier >>>stateNotifier<<<(StateNotifierRef ref) => MyStateNotifier(); +MyStateNotifier >>>stateNotifier<<<(Ref ref) => MyStateNotifier(); @riverpod ``` @@ -23,7 +23,7 @@ test/lints/unsupported_provider_value.dart:17:25 ```dart @riverpod // expect_lint: unsupported_provider_value -Future >>>asyncStateNotifier<<<(AsyncStateNotifierRef ref) async { +Future >>>asyncStateNotifier<<<(Ref ref) async { return MyStateNotifier(); } ``` @@ -55,9 +55,9 @@ test/lints/unsupported_provider_value.dart:29:25 ```dart @riverpod // expect_lint: unsupported_provider_value -Future >>>stateNotifierAsync<<<(StateNotifierAsyncRef ref) async => - MyStateNotifier(); +Future >>>stateNotifierAsync<<<(Ref ref) async => MyStateNotifier(); +// Regression tests for https://github.com/rrousselGit/riverpod/issues/2302 ``` ======= @@ -66,7 +66,7 @@ code: unsupported_provider_value severity: Severity.info correctionMessage: If using StateNotifier even though riverpod_generator does not support it, you can wrap the type in "Raw" to silence the warning. For example by returning Raw. message: The riverpod_generator package does not support StateNotifier values. -test/lints/unsupported_provider_value.dart:52:7 +test/lints/unsupported_provider_value.dart:51:7 ```dart @riverpod @@ -82,12 +82,12 @@ code: unsupported_provider_value severity: Severity.info correctionMessage: If using ChangeNotifier even though riverpod_generator does not support it, you can wrap the type in "Raw" to silence the warning. For example by returning Raw. message: The riverpod_generator package does not support ChangeNotifier values. -test/lints/unsupported_provider_value.dart:62:18 +test/lints/unsupported_provider_value.dart:61:18 ```dart @riverpod // expect_lint: unsupported_provider_value -MyChangeNotifier >>>changeNotifier<<<(ChangeNotifierRef ref) => MyChangeNotifier(); +MyChangeNotifier >>>changeNotifier<<<(Ref ref) => MyChangeNotifier(); @riverpod ``` @@ -98,7 +98,7 @@ code: unsupported_provider_value severity: Severity.info correctionMessage: If using ChangeNotifier even though riverpod_generator does not support it, you can wrap the type in "Raw" to silence the warning. For example by returning Raw. message: The riverpod_generator package does not support ChangeNotifier values. -test/lints/unsupported_provider_value.dart:66:7 +test/lints/unsupported_provider_value.dart:65:7 ```dart @riverpod @@ -114,12 +114,12 @@ code: unsupported_provider_value severity: Severity.info correctionMessage: If using Notifier even though riverpod_generator does not support it, you can wrap the type in "Raw" to silence the warning. For example by returning Raw. message: The riverpod_generator package does not support Notifier values. -test/lints/unsupported_provider_value.dart:74:12 +test/lints/unsupported_provider_value.dart:73:12 ```dart @riverpod // expect_lint: unsupported_provider_value -MyNotifier >>>notifier<<<(NotifierRef ref) => MyNotifier(); +MyNotifier >>>notifier<<<(Ref ref) => MyNotifier(); @riverpod ``` @@ -130,12 +130,12 @@ code: unsupported_provider_value severity: Severity.info correctionMessage: If using Notifier even though riverpod_generator does not support it, you can wrap the type in "Raw" to silence the warning. For example by returning Raw. message: The riverpod_generator package does not support Notifier values. -test/lints/unsupported_provider_value.dart:78:23 +test/lints/unsupported_provider_value.dart:77:23 ```dart @riverpod // expect_lint: unsupported_provider_value -MyAutoDisposeNotifier >>>autoDisposeNotifier<<<(AutoDisposeNotifierRef ref) { +MyAutoDisposeNotifier >>>autoDisposeNotifier<<<(Ref ref) { return MyAutoDisposeNotifier(); } ``` @@ -146,7 +146,7 @@ code: unsupported_provider_value severity: Severity.info correctionMessage: If using Notifier even though riverpod_generator does not support it, you can wrap the type in "Raw" to silence the warning. For example by returning Raw. message: The riverpod_generator package does not support Notifier values. -test/lints/unsupported_provider_value.dart:84:7 +test/lints/unsupported_provider_value.dart:83:7 ```dart @riverpod @@ -162,12 +162,12 @@ code: unsupported_provider_value severity: Severity.info correctionMessage: If using AsyncNotifier even though riverpod_generator does not support it, you can wrap the type in "Raw" to silence the warning. For example by returning Raw. message: The riverpod_generator package does not support AsyncNotifier values. -test/lints/unsupported_provider_value.dart:100:17 +test/lints/unsupported_provider_value.dart:99:17 ```dart @riverpod // expect_lint: unsupported_provider_value -MyAsyncNotifier >>>asyncNotifier<<<(AsyncNotifierRef ref) => MyAsyncNotifier(); +MyAsyncNotifier >>>asyncNotifier<<<(Ref ref) => MyAsyncNotifier(); @riverpod ``` @@ -178,7 +178,7 @@ code: unsupported_provider_value severity: Severity.info correctionMessage: If using AsyncNotifier even though riverpod_generator does not support it, you can wrap the type in "Raw" to silence the warning. For example by returning Raw. message: The riverpod_generator package does not support AsyncNotifier values. -test/lints/unsupported_provider_value.dart:104:7 +test/lints/unsupported_provider_value.dart:103:7 ```dart @riverpod diff --git a/packages/riverpod_lint_flutter_test/test/lints/notifier_extends/failing_notifier_extends.dart b/packages/riverpod_lint_flutter_test/test/lints/notifier_extends/failing_notifier_extends.dart new file mode 100644 index 000000000..a07051376 --- /dev/null +++ b/packages/riverpod_lint_flutter_test/test/lints/notifier_extends/failing_notifier_extends.dart @@ -0,0 +1,14 @@ +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:riverpod_annotation/riverpod_annotation.dart'; + +@riverpod +// expect_lint: notifier_extends +class NoExtends { + int build() => 0; +} + +@riverpod +// expect_lint: notifier_extends +class WrongExtends extends AsyncNotifier { + int build() => 0; +} diff --git a/packages/riverpod_lint_flutter_test/test/lints/notifier_extends.dart b/packages/riverpod_lint_flutter_test/test/lints/notifier_extends/notifier_extends.dart similarity index 77% rename from packages/riverpod_lint_flutter_test/test/lints/notifier_extends.dart rename to packages/riverpod_lint_flutter_test/test/lints/notifier_extends/notifier_extends.dart index 5a607d83b..0c134f500 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/notifier_extends.dart +++ b/packages/riverpod_lint_flutter_test/test/lints/notifier_extends/notifier_extends.dart @@ -1,4 +1,3 @@ -import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'notifier_extends.g.dart'; @@ -10,18 +9,6 @@ class MyNotifier extends _$MyNotifier { int build() => 0; } -@riverpod -// expect_lint: notifier_extends -class NoExtends { - int build() => 0; -} - -@riverpod -// expect_lint: notifier_extends -class WrongExtends extends AsyncNotifier { - int build() => 0; -} - // Regression test for https://github.com/rrousselGit/riverpod/issues/2165 @riverpod class _PrivateClass extends _$PrivateClass { diff --git a/packages/riverpod_lint_flutter_test/test/lints/notifier_extends.g.dart b/packages/riverpod_lint_flutter_test/test/lints/notifier_extends/notifier_extends.g.dart similarity index 83% rename from packages/riverpod_lint_flutter_test/test/lints/notifier_extends.g.dart rename to packages/riverpod_lint_flutter_test/test/lints/notifier_extends/notifier_extends.g.dart index a4e054f21..cdc6ae99a 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/notifier_extends.g.dart +++ b/packages/riverpod_lint_flutter_test/test/lints/notifier_extends/notifier_extends.g.dart @@ -52,7 +52,7 @@ final class MyNotifierProvider extends $NotifierProvider { @override MyNotifierProvider $copyWithBuild( int Function( - Ref, + Ref, MyNotifier, ) build, ) { @@ -75,144 +75,6 @@ abstract class _$MyNotifier extends $Notifier { int runBuild() => build(); } -@ProviderFor(NoExtends) -const noExtendsProvider = NoExtendsProvider._(); - -final class NoExtendsProvider extends $NotifierProvider { - const NoExtendsProvider._( - {super.runNotifierBuildOverride, NoExtends Function()? create}) - : _createCb = create, - super( - from: null, - argument: null, - retry: null, - name: r'noExtendsProvider', - isAutoDispose: true, - dependencies: null, - allTransitiveDependencies: null, - ); - - final NoExtends Function()? _createCb; - - @override - String debugGetCreateSourceHash() => _$noExtendsHash(); - - /// {@macro riverpod.override_with_value} - Override overrideWithValue(int value) { - return $ProviderOverride( - origin: this, - providerOverride: $ValueProvider(value), - ); - } - - @$internal - @override - NoExtends create() => _createCb?.call() ?? NoExtends(); - - @$internal - @override - NoExtendsProvider $copyWithCreate( - NoExtends Function() create, - ) { - return NoExtendsProvider._(create: create); - } - - @$internal - @override - NoExtendsProvider $copyWithBuild( - int Function( - Ref, - NoExtends, - ) build, - ) { - return NoExtendsProvider._(runNotifierBuildOverride: build); - } - - @$internal - @override - $NotifierProviderElement $createElement( - $ProviderPointer pointer) => - $NotifierProviderElement(this, pointer); -} - -String _$noExtendsHash() => r'3f1276999a9a6d3676c628c25ed853cbefb21ce9'; - -abstract class _$NoExtends extends $Notifier { - int build(); - @$internal - @override - int runBuild() => build(); -} - -@ProviderFor(WrongExtends) -const wrongExtendsProvider = WrongExtendsProvider._(); - -final class WrongExtendsProvider extends $NotifierProvider { - const WrongExtendsProvider._( - {super.runNotifierBuildOverride, WrongExtends Function()? create}) - : _createCb = create, - super( - from: null, - argument: null, - retry: null, - name: r'wrongExtendsProvider', - isAutoDispose: true, - dependencies: null, - allTransitiveDependencies: null, - ); - - final WrongExtends Function()? _createCb; - - @override - String debugGetCreateSourceHash() => _$wrongExtendsHash(); - - /// {@macro riverpod.override_with_value} - Override overrideWithValue(int value) { - return $ProviderOverride( - origin: this, - providerOverride: $ValueProvider(value), - ); - } - - @$internal - @override - WrongExtends create() => _createCb?.call() ?? WrongExtends(); - - @$internal - @override - WrongExtendsProvider $copyWithCreate( - WrongExtends Function() create, - ) { - return WrongExtendsProvider._(create: create); - } - - @$internal - @override - WrongExtendsProvider $copyWithBuild( - int Function( - Ref, - WrongExtends, - ) build, - ) { - return WrongExtendsProvider._(runNotifierBuildOverride: build); - } - - @$internal - @override - $NotifierProviderElement $createElement( - $ProviderPointer pointer) => - $NotifierProviderElement(this, pointer); -} - -String _$wrongExtendsHash() => r'6479055793af10a34e225373a67f7eaac4d7c0de'; - -abstract class _$WrongExtends extends $Notifier { - int build(); - @$internal - @override - int runBuild() => build(); -} - @ProviderFor(_PrivateClass) const _privateClassProvider = _PrivateClassProvider._(); @@ -260,7 +122,7 @@ final class _PrivateClassProvider @override _PrivateClassProvider $copyWithBuild( String Function( - Ref, + Ref, _PrivateClass, ) build, ) { @@ -316,7 +178,7 @@ final class GenericsProvider GenericsProvider _copyWithBuild( int Function( - Ref, + Ref, Generics, ) build, ) { @@ -356,7 +218,7 @@ final class GenericsProvider @override GenericsProvider $copyWithBuild( int Function( - Ref, + Ref, Generics, ) build, ) { @@ -420,7 +282,7 @@ final class GenericsFamily extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( - int Function(Ref ref, Generics notifier) build, + int Function(Ref ref, Generics notifier) build, ) { return $FamilyOverride( from: this, @@ -473,7 +335,7 @@ final class NoGenericsProvider NoGenericsProvider _copyWithBuild( int Function( - Ref, + Ref, NoGenerics, ) build, ) { @@ -513,7 +375,7 @@ final class NoGenericsProvider @override NoGenericsProvider $copyWithBuild( int Function( - Ref, + Ref, NoGenerics, ) build, ) { @@ -577,8 +439,7 @@ final class NoGenericsFamily extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( - int Function(Ref ref, NoGenerics notifier) - build, + int Function(Ref ref, NoGenerics notifier) build, ) { return $FamilyOverride( from: this, @@ -631,7 +492,7 @@ final class MissingGenericsProvider MissingGenericsProvider _copyWithBuild( int Function( - Ref, + Ref, MissingGenerics, ) build, ) { @@ -673,7 +534,7 @@ final class MissingGenericsProvider @override MissingGenericsProvider $copyWithBuild( int Function( - Ref, + Ref, MissingGenerics, ) build, ) { @@ -737,7 +598,7 @@ final class MissingGenericsFamily extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( - int Function(Ref ref, MissingGenerics notifier) build, + int Function(Ref ref, MissingGenerics notifier) build, ) { return $FamilyOverride( from: this, @@ -790,7 +651,7 @@ final class WrongOrderProvider WrongOrderProvider _copyWithBuild( int Function( - Ref, + Ref, WrongOrder, ) build, ) { @@ -830,7 +691,7 @@ final class WrongOrderProvider @override WrongOrderProvider $copyWithBuild( int Function( - Ref, + Ref, WrongOrder, ) build, ) { @@ -894,7 +755,7 @@ final class WrongOrderFamily extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( - int Function(Ref ref, WrongOrder notifier) build, + int Function(Ref ref, WrongOrder notifier) build, ) { return $FamilyOverride( from: this, @@ -915,4 +776,4 @@ abstract class _$WrongOrder extends $Notifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/packages/riverpod_lint_flutter_test/test/lints/only_use_keep_alive_inside_keep_alive.dart b/packages/riverpod_lint_flutter_test/test/lints/only_use_keep_alive_inside_keep_alive.dart index 8e0fe9892..c01d1bcac 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/only_use_keep_alive_inside_keep_alive.dart +++ b/packages/riverpod_lint_flutter_test/test/lints/only_use_keep_alive_inside_keep_alive.dart @@ -3,7 +3,7 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'only_use_keep_alive_inside_keep_alive.g.dart'; @Riverpod(keepAlive: true) -int keepAlive(KeepAliveRef ref) => 42; +int keepAlive(Ref ref) => 42; @Riverpod(keepAlive: true) class KeepAliveClass extends _$KeepAliveClass { @@ -11,7 +11,7 @@ class KeepAliveClass extends _$KeepAliveClass { } @riverpod -int autoDispose(AutoDisposeRef ref) => 42; +int autoDispose(Ref ref) => 42; @riverpod class AutoDisposeClass extends _$AutoDisposeClass { @@ -19,7 +19,7 @@ class AutoDisposeClass extends _$AutoDisposeClass { } @Riverpod(keepAlive: true) -int fn(FnRef ref) { +int fn(Ref ref) { ref.watch(keepAliveProvider); ref.watch(keepAliveClassProvider); diff --git a/packages/riverpod_lint_flutter_test/test/lints/only_use_keep_alive_inside_keep_alive.g.dart b/packages/riverpod_lint_flutter_test/test/lints/only_use_keep_alive_inside_keep_alive.g.dart index 195bf9d30..dea54858d 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/only_use_keep_alive_inside_keep_alive.g.dart +++ b/packages/riverpod_lint_flutter_test/test/lints/only_use_keep_alive_inside_keep_alive.g.dart @@ -6,16 +6,14 @@ part of 'only_use_keep_alive_inside_keep_alive.dart'; // RiverpodGenerator // ************************************************************************** -typedef KeepAliveRef = Ref; - @ProviderFor(keepAlive) const keepAliveProvider = KeepAliveProvider._(); final class KeepAliveProvider extends $FunctionalProvider - with $Provider { + with $Provider { const KeepAliveProvider._( {int Function( - KeepAliveRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -29,7 +27,7 @@ final class KeepAliveProvider extends $FunctionalProvider ); final int Function( - KeepAliveRef ref, + Ref ref, )? _createCb; @override @@ -51,20 +49,20 @@ final class KeepAliveProvider extends $FunctionalProvider @override KeepAliveProvider $copyWithCreate( int Function( - KeepAliveRef ref, + Ref ref, ) create, ) { return KeepAliveProvider._(create: create); } @override - int create(KeepAliveRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? keepAlive; return _$cb(ref); } } -String _$keepAliveHash() => r'756ceaba79af550d4498a93ec30118f989cd5bb4'; +String _$keepAliveHash() => r'095b2cb2261b9d79721aa6552b8aaf0d8a7bb7ee'; @ProviderFor(KeepAliveClass) const keepAliveClassProvider = KeepAliveClassProvider._(); @@ -113,7 +111,7 @@ final class KeepAliveClassProvider @override KeepAliveClassProvider $copyWithBuild( int Function( - Ref, + Ref, KeepAliveClass, ) build, ) { @@ -136,16 +134,14 @@ abstract class _$KeepAliveClass extends $Notifier { int runBuild() => build(); } -typedef AutoDisposeRef = Ref; - @ProviderFor(autoDispose) const autoDisposeProvider = AutoDisposeProvider._(); final class AutoDisposeProvider extends $FunctionalProvider - with $Provider { + with $Provider { const AutoDisposeProvider._( {int Function( - AutoDisposeRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -159,7 +155,7 @@ final class AutoDisposeProvider extends $FunctionalProvider ); final int Function( - AutoDisposeRef ref, + Ref ref, )? _createCb; @override @@ -181,20 +177,20 @@ final class AutoDisposeProvider extends $FunctionalProvider @override AutoDisposeProvider $copyWithCreate( int Function( - AutoDisposeRef ref, + Ref ref, ) create, ) { return AutoDisposeProvider._(create: create); } @override - int create(AutoDisposeRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? autoDispose; return _$cb(ref); } } -String _$autoDisposeHash() => r'd46d894171aed556a8b4deafeda4de6b9465f632'; +String _$autoDisposeHash() => r'1ace7b4b2957ecf77b683b868e91a2614fc77d03'; @ProviderFor(AutoDisposeClass) const autoDisposeClassProvider = AutoDisposeClassProvider._(); @@ -243,7 +239,7 @@ final class AutoDisposeClassProvider @override AutoDisposeClassProvider $copyWithBuild( int Function( - Ref, + Ref, AutoDisposeClass, ) build, ) { @@ -266,16 +262,14 @@ abstract class _$AutoDisposeClass extends $Notifier { int runBuild() => build(); } -typedef FnRef = Ref; - @ProviderFor(fn) const fnProvider = FnProvider._(); final class FnProvider extends $FunctionalProvider - with $Provider { + with $Provider { const FnProvider._( {int Function( - FnRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -289,7 +283,7 @@ final class FnProvider extends $FunctionalProvider ); final int Function( - FnRef ref, + Ref ref, )? _createCb; @override @@ -311,20 +305,20 @@ final class FnProvider extends $FunctionalProvider @override FnProvider $copyWithCreate( int Function( - FnRef ref, + Ref ref, ) create, ) { return FnProvider._(create: create); } @override - int create(FnRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? fn; return _$cb(ref); } } -String _$fnHash() => r'9e89e9bead8aa30a86f31bd16f4106c4b38e8f2b'; +String _$fnHash() => r'e96b0302f7492f5aecedd46f6edeeea456839d01'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/packages/riverpod_lint_flutter_test/test/lints/protected_notifier_properties.g.dart b/packages/riverpod_lint_flutter_test/test/lints/protected_notifier_properties.g.dart index b263c9f96..ca5340382 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/protected_notifier_properties.g.dart +++ b/packages/riverpod_lint_flutter_test/test/lints/protected_notifier_properties.g.dart @@ -51,7 +51,7 @@ final class AProvider extends $NotifierProvider { @override AProvider $copyWithBuild( int Function( - Ref, + Ref, A, ) build, ) { @@ -118,7 +118,7 @@ final class A2Provider extends $NotifierProvider { @override A2Provider $copyWithBuild( int Function( - Ref, + Ref, A2, ) build, ) { @@ -195,7 +195,7 @@ final class A3Provider extends $NotifierProvider { @override A3Provider $copyWithBuild( int Function( - Ref, + Ref, A3, ) build, ) { @@ -266,7 +266,7 @@ final class A3Family extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( - int Function(Ref ref, A3 notifier, int argument) build, + int Function(Ref ref, A3 notifier, int argument) build, ) { return $FamilyOverride( from: this, @@ -352,7 +352,7 @@ final class A4Provider extends $NotifierProvider { @override A4Provider $copyWithBuild( int Function( - Ref, + Ref, A4, ) build, ) { @@ -423,7 +423,7 @@ final class A4Family extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( - int Function(Ref ref, A4 notifier, int argument) build, + int Function(Ref ref, A4 notifier, int argument) build, ) { return $FamilyOverride( from: this, @@ -501,7 +501,7 @@ final class A5Provider extends $AsyncNotifierProvider { @override A5Provider $copyWithBuild( FutureOr Function( - Ref>, + Ref, A5, ) build, ) { @@ -573,8 +573,7 @@ final class A5Family extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( - FutureOr Function(Ref> ref, A5 notifier, int argument) - build, + FutureOr Function(Ref ref, A5 notifier, int argument) build, ) { return $FamilyOverride( from: this, @@ -652,7 +651,7 @@ final class A6Provider extends $AsyncNotifierProvider { @override A6Provider $copyWithBuild( FutureOr Function( - Ref>, + Ref, A6, ) build, ) { @@ -724,8 +723,7 @@ final class A6Family extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( - FutureOr Function(Ref> ref, A6 notifier, int argument) - build, + FutureOr Function(Ref ref, A6 notifier, int argument) build, ) { return $FamilyOverride( from: this, @@ -803,7 +801,7 @@ final class A7Provider extends $StreamNotifierProvider { @override A7Provider $copyWithBuild( Stream Function( - Ref>, + Ref, A7, ) build, ) { @@ -875,8 +873,7 @@ final class A7Family extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( - Stream Function(Ref> ref, A7 notifier, int argument) - build, + Stream Function(Ref ref, A7 notifier, int argument) build, ) { return $FamilyOverride( from: this, @@ -954,7 +951,7 @@ final class A8Provider extends $StreamNotifierProvider { @override A8Provider $copyWithBuild( Stream Function( - Ref>, + Ref, A8, ) build, ) { @@ -1026,8 +1023,7 @@ final class A8Family extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( - Stream Function(Ref> ref, A8 notifier, int argument) - build, + Stream Function(Ref ref, A8 notifier, int argument) build, ) { return $FamilyOverride( from: this, @@ -1103,7 +1099,7 @@ final class BProvider extends $NotifierProvider { @override BProvider $copyWithBuild( int Function( - Ref, + Ref, B, ) build, ) { @@ -1170,7 +1166,7 @@ final class B2Provider extends $NotifierProvider { @override B2Provider $copyWithBuild( int Function( - Ref, + Ref, B2, ) build, ) { @@ -1193,4 +1189,4 @@ abstract class _$B2 extends $Notifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/packages/riverpod_lint_flutter_test/test/lints/provider_dependencies/another.dart b/packages/riverpod_lint_flutter_test/test/lints/provider_dependencies/another.dart index 295747979..0396dce89 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/provider_dependencies/another.dart +++ b/packages/riverpod_lint_flutter_test/test/lints/provider_dependencies/another.dart @@ -6,13 +6,13 @@ part 'another.g.dart'; final aProvider = Provider((ref) => 0); @riverpod -int b(BRef ref) => 0; +int b(Ref ref) => 0; @Riverpod(dependencies: []) -int anotherScoped(AnotherScopedRef ref) => 0; +int anotherScoped(Ref ref) => 0; @Riverpod(dependencies: [anotherScoped]) -int anotherNonEmptyScoped(AnotherNonEmptyScopedRef ref) { +int anotherNonEmptyScoped(Ref ref) { ref.watch(anotherScopedProvider); return 0; } diff --git a/packages/riverpod_lint_flutter_test/test/lints/provider_dependencies/another.g.dart b/packages/riverpod_lint_flutter_test/test/lints/provider_dependencies/another.g.dart index 126b8cede..acb68d2ab 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/provider_dependencies/another.g.dart +++ b/packages/riverpod_lint_flutter_test/test/lints/provider_dependencies/another.g.dart @@ -6,16 +6,14 @@ part of 'another.dart'; // RiverpodGenerator // ************************************************************************** -typedef BRef = Ref; - @ProviderFor(b) const bProvider = BProvider._(); final class BProvider extends $FunctionalProvider - with $Provider { + with $Provider { const BProvider._( {int Function( - BRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -29,7 +27,7 @@ final class BProvider extends $FunctionalProvider ); final int Function( - BRef ref, + Ref ref, )? _createCb; @override @@ -51,31 +49,29 @@ final class BProvider extends $FunctionalProvider @override BProvider $copyWithCreate( int Function( - BRef ref, + Ref ref, ) create, ) { return BProvider._(create: create); } @override - int create(BRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? b; return _$cb(ref); } } -String _$bHash() => r'52593050701642f22b31c590f20c003dc2ee1579'; - -typedef AnotherScopedRef = Ref; +String _$bHash() => r'31624e9aa10c9cd7941c9626e841c6df3468723b'; @ProviderFor(anotherScoped) const anotherScopedProvider = AnotherScopedProvider._(); final class AnotherScopedProvider extends $FunctionalProvider - with $Provider { + with $Provider { const AnotherScopedProvider._( {int Function( - AnotherScopedRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -89,7 +85,7 @@ final class AnotherScopedProvider extends $FunctionalProvider ); final int Function( - AnotherScopedRef ref, + Ref ref, )? _createCb; @override @@ -111,31 +107,29 @@ final class AnotherScopedProvider extends $FunctionalProvider @override AnotherScopedProvider $copyWithCreate( int Function( - AnotherScopedRef ref, + Ref ref, ) create, ) { return AnotherScopedProvider._(create: create); } @override - int create(AnotherScopedRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? anotherScoped; return _$cb(ref); } } -String _$anotherScopedHash() => r'409a070806b566d16d98f18c99bf6243d481887f'; - -typedef AnotherNonEmptyScopedRef = Ref; +String _$anotherScopedHash() => r'edf3ccffb7c3ce1b1e4ffdd4009aeed4fa38c3f8'; @ProviderFor(anotherNonEmptyScoped) const anotherNonEmptyScopedProvider = AnotherNonEmptyScopedProvider._(); final class AnotherNonEmptyScopedProvider extends $FunctionalProvider - with $Provider { + with $Provider { const AnotherNonEmptyScopedProvider._( {int Function( - AnotherNonEmptyScopedRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -153,7 +147,7 @@ final class AnotherNonEmptyScopedProvider extends $FunctionalProvider static const $allTransitiveDependencies0 = anotherScopedProvider; final int Function( - AnotherNonEmptyScopedRef ref, + Ref ref, )? _createCb; @override @@ -175,21 +169,21 @@ final class AnotherNonEmptyScopedProvider extends $FunctionalProvider @override AnotherNonEmptyScopedProvider $copyWithCreate( int Function( - AnotherNonEmptyScopedRef ref, + Ref ref, ) create, ) { return AnotherNonEmptyScopedProvider._(create: create); } @override - int create(AnotherNonEmptyScopedRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? anotherNonEmptyScoped; return _$cb(ref); } } String _$anotherNonEmptyScopedHash() => - r'cc21d248e644c853e4647ad60ca72cb42b82475f'; + r'56da5331e55d74e8e10ff710d20618f217394a69'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/packages/riverpod_lint_flutter_test/test/lints/provider_dependencies/missing_dependencies.dart b/packages/riverpod_lint_flutter_test/test/lints/provider_dependencies/missing_dependencies.dart index a1ba3a2bb..a10cd4dd1 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/provider_dependencies/missing_dependencies.dart +++ b/packages/riverpod_lint_flutter_test/test/lints/provider_dependencies/missing_dependencies.dart @@ -5,16 +5,16 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'missing_dependencies.g.dart'; @Riverpod(dependencies: []) -int dep(DepRef ref) => 0; +int dep(Ref ref) => 0; @Riverpod(dependencies: [dep]) -int transitiveDep(TransitiveDepRef ref) => ref.watch(depProvider); +int transitiveDep(Ref ref) => ref.watch(depProvider); @Riverpod(dependencies: []) -int dep2(Dep2Ref ref) => 0; +int dep2(Ref ref) => 0; @Riverpod(dependencies: []) -int depFamily(DepFamilyRef ref, int id) => 0; +int depFamily(Ref ref, int id) => 0; // expect_lint: provider_dependencies @Dependencies([dep]) @@ -75,14 +75,14 @@ class DepFamily extends StatelessWidget { // expect_lint: provider_dependencies @riverpod -int plainAnnotation(PlainAnnotationRef ref) { +int plainAnnotation(Ref ref) { ref.watch(depProvider); return 0; } // expect_lint: provider_dependencies @Riverpod(keepAlive: false) -int customAnnotation(CustomAnnotationRef ref) { +int customAnnotation(Ref ref) { ref.watch(depProvider); return 0; } @@ -92,7 +92,7 @@ int customAnnotation(CustomAnnotationRef ref) { keepAlive: false, ) int customAnnotationWithTrailingComma( - CustomAnnotationWithTrailingCommaRef ref, + Ref ref, ) { ref.watch(depProvider); return 0; @@ -103,7 +103,7 @@ int customAnnotationWithTrailingComma( // expect_lint: provider_dependencies dependencies: [], ) -int existingDep(ExistingDepRef ref) { +int existingDep(Ref ref) { ref.watch(depProvider); return 0; } @@ -113,7 +113,7 @@ int existingDep(ExistingDepRef ref) { // expect_lint: provider_dependencies dependencies: [], ) -int multipleDeps(MultipleDepsRef ref) { +int multipleDeps(Ref ref) { ref.watch(depProvider); ref.watch(dep2Provider); return 0; @@ -277,4 +277,4 @@ class _NotFoundWidgetState extends ConsumerState { /// Random doc to test that identifiers in docs don't trigger the lint. /// [dep], [DepWidget], [depProvider] @Riverpod(dependencies: []) -int providerWithDartDoc(ProviderWithDartDocRef ref) => 0; +int providerWithDartDoc(Ref ref) => 0; diff --git a/packages/riverpod_lint_flutter_test/test/lints/provider_dependencies/missing_dependencies.g.dart b/packages/riverpod_lint_flutter_test/test/lints/provider_dependencies/missing_dependencies.g.dart index c464a0c2a..06a7b3727 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/provider_dependencies/missing_dependencies.g.dart +++ b/packages/riverpod_lint_flutter_test/test/lints/provider_dependencies/missing_dependencies.g.dart @@ -6,16 +6,14 @@ part of 'missing_dependencies.dart'; // RiverpodGenerator // ************************************************************************** -typedef DepRef = Ref; - @ProviderFor(dep) const depProvider = DepProvider._(); final class DepProvider extends $FunctionalProvider - with $Provider { + with $Provider { const DepProvider._( {int Function( - DepRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -29,7 +27,7 @@ final class DepProvider extends $FunctionalProvider ); final int Function( - DepRef ref, + Ref ref, )? _createCb; @override @@ -51,31 +49,29 @@ final class DepProvider extends $FunctionalProvider @override DepProvider $copyWithCreate( int Function( - DepRef ref, + Ref ref, ) create, ) { return DepProvider._(create: create); } @override - int create(DepRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? dep; return _$cb(ref); } } -String _$depHash() => r'749c4d696d29c72686cabcabd6fa7855f5cbf4db'; - -typedef TransitiveDepRef = Ref; +String _$depHash() => r'578a350a40cda46444ecd9fa3ea2fd7bd0994692'; @ProviderFor(transitiveDep) const transitiveDepProvider = TransitiveDepProvider._(); final class TransitiveDepProvider extends $FunctionalProvider - with $Provider { + with $Provider { const TransitiveDepProvider._( {int Function( - TransitiveDepRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -93,7 +89,7 @@ final class TransitiveDepProvider extends $FunctionalProvider static const $allTransitiveDependencies0 = depProvider; final int Function( - TransitiveDepRef ref, + Ref ref, )? _createCb; @override @@ -115,31 +111,29 @@ final class TransitiveDepProvider extends $FunctionalProvider @override TransitiveDepProvider $copyWithCreate( int Function( - TransitiveDepRef ref, + Ref ref, ) create, ) { return TransitiveDepProvider._(create: create); } @override - int create(TransitiveDepRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? transitiveDep; return _$cb(ref); } } -String _$transitiveDepHash() => r'3718ab2a36c91fb776740c6aeafc49db08bbffd5'; - -typedef Dep2Ref = Ref; +String _$transitiveDepHash() => r'cedc000b7d16447684dff970ddea659cca24cdf6'; @ProviderFor(dep2) const dep2Provider = Dep2Provider._(); final class Dep2Provider extends $FunctionalProvider - with $Provider { + with $Provider { const Dep2Provider._( {int Function( - Dep2Ref ref, + Ref ref, )? create}) : _createCb = create, super( @@ -153,7 +147,7 @@ final class Dep2Provider extends $FunctionalProvider ); final int Function( - Dep2Ref ref, + Ref ref, )? _createCb; @override @@ -175,33 +169,31 @@ final class Dep2Provider extends $FunctionalProvider @override Dep2Provider $copyWithCreate( int Function( - Dep2Ref ref, + Ref ref, ) create, ) { return Dep2Provider._(create: create); } @override - int create(Dep2Ref ref) { + int create(Ref ref) { final _$cb = _createCb ?? dep2; return _$cb(ref); } } -String _$dep2Hash() => r'13cd909366c79168e3d9cd95f529ddbcee6de7dc'; - -typedef DepFamilyRef = Ref; +String _$dep2Hash() => r'97901e825cdcf5b1ac455b0fe8a2111662ce9f13'; @ProviderFor(depFamily) const depFamilyProvider = DepFamilyFamily._(); final class DepFamilyProvider extends $FunctionalProvider - with $Provider { + with $Provider { const DepFamilyProvider._( {required DepFamilyFamily super.from, required int super.argument, int Function( - DepFamilyRef ref, + Ref ref, int id, )? create}) : _createCb = create, @@ -214,7 +206,7 @@ final class DepFamilyProvider extends $FunctionalProvider ); final int Function( - DepFamilyRef ref, + Ref ref, int id, )? _createCb; @@ -244,7 +236,7 @@ final class DepFamilyProvider extends $FunctionalProvider @override DepFamilyProvider $copyWithCreate( int Function( - DepFamilyRef ref, + Ref ref, ) create, ) { return DepFamilyProvider._( @@ -258,7 +250,7 @@ final class DepFamilyProvider extends $FunctionalProvider } @override - int create(DepFamilyRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? depFamily; final argument = this.argument as int; return _$cb( @@ -278,7 +270,7 @@ final class DepFamilyProvider extends $FunctionalProvider } } -String _$depFamilyHash() => r'c11006a8b9718af9899999b7c49f78cf3423f558'; +String _$depFamilyHash() => r'6cca68b98693e352e9b801b1fc441d438fc72525'; final class DepFamilyFamily extends Family { const DepFamilyFamily._() @@ -304,7 +296,7 @@ final class DepFamilyFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( int Function( - DepFamilyRef ref, + Ref ref, int args, ) create, ) { @@ -323,10 +315,6 @@ final class DepFamilyFamily extends Family { } } -//////////// -// expect_lint: provider_dependencies -typedef PlainAnnotationRef = Ref; - //////////// // expect_lint: provider_dependencies @ProviderFor(plainAnnotation) @@ -335,12 +323,12 @@ const plainAnnotationProvider = PlainAnnotationProvider._(); //////////// // expect_lint: provider_dependencies final class PlainAnnotationProvider extends $FunctionalProvider - with $Provider { + with $Provider { //////////// // expect_lint: provider_dependencies const PlainAnnotationProvider._( {int Function( - PlainAnnotationRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -354,7 +342,7 @@ final class PlainAnnotationProvider extends $FunctionalProvider ); final int Function( - PlainAnnotationRef ref, + Ref ref, )? _createCb; @override @@ -376,31 +364,29 @@ final class PlainAnnotationProvider extends $FunctionalProvider @override PlainAnnotationProvider $copyWithCreate( int Function( - PlainAnnotationRef ref, + Ref ref, ) create, ) { return PlainAnnotationProvider._(create: create); } @override - int create(PlainAnnotationRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? plainAnnotation; return _$cb(ref); } } -String _$plainAnnotationHash() => r'ceeb01dfcbd115f3676c8e38ce35a03cff16246b'; - -typedef CustomAnnotationRef = Ref; +String _$plainAnnotationHash() => r'6a3d1f1f2e53902af56cd7ce6ceba17358690b70'; @ProviderFor(customAnnotation) const customAnnotationProvider = CustomAnnotationProvider._(); final class CustomAnnotationProvider extends $FunctionalProvider - with $Provider { + with $Provider { const CustomAnnotationProvider._( {int Function( - CustomAnnotationRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -414,7 +400,7 @@ final class CustomAnnotationProvider extends $FunctionalProvider ); final int Function( - CustomAnnotationRef ref, + Ref ref, )? _createCb; @override @@ -436,33 +422,30 @@ final class CustomAnnotationProvider extends $FunctionalProvider @override CustomAnnotationProvider $copyWithCreate( int Function( - CustomAnnotationRef ref, + Ref ref, ) create, ) { return CustomAnnotationProvider._(create: create); } @override - int create(CustomAnnotationRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? customAnnotation; return _$cb(ref); } } -String _$customAnnotationHash() => r'04faed9b424be360e594870f91c4ef4689f05672'; - -typedef CustomAnnotationWithTrailingCommaRef = Ref; +String _$customAnnotationHash() => r'8081bbad2cfbe5bff1ace9aa3be450dd28112488'; @ProviderFor(customAnnotationWithTrailingComma) const customAnnotationWithTrailingCommaProvider = CustomAnnotationWithTrailingCommaProvider._(); final class CustomAnnotationWithTrailingCommaProvider - extends $FunctionalProvider - with $Provider { + extends $FunctionalProvider with $Provider { const CustomAnnotationWithTrailingCommaProvider._( {int Function( - CustomAnnotationWithTrailingCommaRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -476,7 +459,7 @@ final class CustomAnnotationWithTrailingCommaProvider ); final int Function( - CustomAnnotationWithTrailingCommaRef ref, + Ref ref, )? _createCb; @override @@ -499,32 +482,30 @@ final class CustomAnnotationWithTrailingCommaProvider @override CustomAnnotationWithTrailingCommaProvider $copyWithCreate( int Function( - CustomAnnotationWithTrailingCommaRef ref, + Ref ref, ) create, ) { return CustomAnnotationWithTrailingCommaProvider._(create: create); } @override - int create(CustomAnnotationWithTrailingCommaRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? customAnnotationWithTrailingComma; return _$cb(ref); } } String _$customAnnotationWithTrailingCommaHash() => - r'b5c62d769dfc53d6d77e8fde9e0eb7d8a0ab9d18'; - -typedef ExistingDepRef = Ref; + r'709613050eb1db7b4c43cb87855e2c32988141d8'; @ProviderFor(existingDep) const existingDepProvider = ExistingDepProvider._(); final class ExistingDepProvider extends $FunctionalProvider - with $Provider { + with $Provider { const ExistingDepProvider._( {int Function( - ExistingDepRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -538,7 +519,7 @@ final class ExistingDepProvider extends $FunctionalProvider ); final int Function( - ExistingDepRef ref, + Ref ref, )? _createCb; @override @@ -560,31 +541,29 @@ final class ExistingDepProvider extends $FunctionalProvider @override ExistingDepProvider $copyWithCreate( int Function( - ExistingDepRef ref, + Ref ref, ) create, ) { return ExistingDepProvider._(create: create); } @override - int create(ExistingDepRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? existingDep; return _$cb(ref); } } -String _$existingDepHash() => r'8d7866d1af7e350d7c792e43a542cd47b130b239'; - -typedef MultipleDepsRef = Ref; +String _$existingDepHash() => r'73e7e1a0d4c2ae07ed03fb248408c3d82fe85554'; @ProviderFor(multipleDeps) const multipleDepsProvider = MultipleDepsProvider._(); final class MultipleDepsProvider extends $FunctionalProvider - with $Provider { + with $Provider { const MultipleDepsProvider._( {int Function( - MultipleDepsRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -598,7 +577,7 @@ final class MultipleDepsProvider extends $FunctionalProvider ); final int Function( - MultipleDepsRef ref, + Ref ref, )? _createCb; @override @@ -620,24 +599,20 @@ final class MultipleDepsProvider extends $FunctionalProvider @override MultipleDepsProvider $copyWithCreate( int Function( - MultipleDepsRef ref, + Ref ref, ) create, ) { return MultipleDepsProvider._(create: create); } @override - int create(MultipleDepsRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? multipleDeps; return _$cb(ref); } } -String _$multipleDepsHash() => r'9d08791636a0435ba115062a453d0d9e530ecf71'; - -/// Random doc to test that identifiers in docs don't trigger the lint. -/// [dep], [DepWidget], [depProvider] -typedef ProviderWithDartDocRef = Ref; +String _$multipleDepsHash() => r'66de70567c011a294a2c46703dfab8ba7247fd5e'; /// Random doc to test that identifiers in docs don't trigger the lint. /// [dep], [DepWidget], [depProvider] @@ -647,12 +622,12 @@ const providerWithDartDocProvider = ProviderWithDartDocProvider._(); /// Random doc to test that identifiers in docs don't trigger the lint. /// [dep], [DepWidget], [depProvider] final class ProviderWithDartDocProvider extends $FunctionalProvider - with $Provider { + with $Provider { /// Random doc to test that identifiers in docs don't trigger the lint. /// [dep], [DepWidget], [depProvider] const ProviderWithDartDocProvider._( {int Function( - ProviderWithDartDocRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -666,7 +641,7 @@ final class ProviderWithDartDocProvider extends $FunctionalProvider ); final int Function( - ProviderWithDartDocRef ref, + Ref ref, )? _createCb; @override @@ -688,21 +663,21 @@ final class ProviderWithDartDocProvider extends $FunctionalProvider @override ProviderWithDartDocProvider $copyWithCreate( int Function( - ProviderWithDartDocRef ref, + Ref ref, ) create, ) { return ProviderWithDartDocProvider._(create: create); } @override - int create(ProviderWithDartDocRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? providerWithDartDoc; return _$cb(ref); } } String _$providerWithDartDocHash() => - r'6aeff1697c1ec37f475319a4100e01c0e56369ae'; + r'aeb5735ad2dbe1d0b41a529828f9bb2c915071b6'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/packages/riverpod_lint_flutter_test/test/lints/provider_dependencies/missing_dependencies2.dart b/packages/riverpod_lint_flutter_test/test/lints/provider_dependencies/missing_dependencies2.dart index e97f01b02..88e0d24e1 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/provider_dependencies/missing_dependencies2.dart +++ b/packages/riverpod_lint_flutter_test/test/lints/provider_dependencies/missing_dependencies2.dart @@ -1,4 +1,4 @@ -// ignore_for_file: unused_field, avoid_manual_providers_as_generated_provider_dependency +// ignore_for_file: unused_field import 'package:flutter/material.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; @@ -9,78 +9,145 @@ import 'another.dart'; part 'missing_dependencies2.g.dart'; @Riverpod(dependencies: []) -int dep(DepRef ref) => 0; +int dep(Ref ref) => 0; final scoped = Provider((ref) => 0, dependencies: []); @Riverpod(dependencies: []) -int generatedScoped(GeneratedScopedRef ref) => 0; +int generatedScoped(Ref ref) => 0; final root = Provider((ref) => 0); @riverpod -int generatedRoot(GeneratedRootRef ref) => 0; +int generatedRoot(Ref ref) => 0; // dep no "dependencies" @riverpod -int watchScopedButNoDependencies(WatchScopedButNoDependenciesRef ref) { +int watchScopedButNoDependencies(Ref ref) { + // expect_lint: avoid_manual_providers_as_generated_provider_dependency return ref.watch(scoped); } // expect_lint: provider_dependencies @riverpod int watchGeneratedScopedButNoDependencies( - WatchGeneratedScopedButNoDependenciesRef ref, + Ref ref, ) { return ref.watch(generatedScopedProvider); } @riverpod -int watchRootButNoDependencies(WatchRootButNoDependenciesRef ref) { +int watchRootButNoDependencies(Ref ref) { + // expect_lint: avoid_manual_providers_as_generated_provider_dependency return ref.watch(root); } @riverpod int watchGeneratedRootButNoDependencies( - WatchGeneratedRootButNoDependenciesRef ref, + Ref ref, ) { return ref.watch(generatedRootProvider); } // Check "dependencies" specified but missing dependency @Riverpod(dependencies: []) -int watchScopedButEmptyDependencies(WatchScopedButEmptyDependenciesRef ref) { +int watchScopedButEmptyDependencies(Ref ref) { + // expect_lint: avoid_manual_providers_as_generated_provider_dependency return ref.watch(scoped); } // expect_lint: provider_dependencies @Riverpod(dependencies: []) int watchGeneratedScopedButEmptyDependencies( - WatchGeneratedScopedButEmptyDependenciesRef ref, + Ref ref, ) { return ref.watch(generatedScopedProvider); } @Riverpod(dependencies: []) -int watchRootButEmptyDependencies(WatchRootButEmptyDependenciesRef ref) { +int watchRootButEmptyDependencies(Ref ref) { + // expect_lint: avoid_manual_providers_as_generated_provider_dependency return ref.watch(root); } @Riverpod(dependencies: []) int watchGeneratedRootButEmptyDependencies( - WatchGeneratedRootButEmptyDependenciesRef ref, + Ref ref, ) { return ref.watch(generatedRootProvider); } +// Check "dependencies" specified but missing dependency + +@Riverpod(dependencies: [dep]) +int watchScopedButMissingDependencies( + Ref ref, +) { + ref.watch(depProvider); + // expect_lint: avoid_manual_providers_as_generated_provider_dependency + return ref.watch(scoped); +} + +// expect_lint: provider_dependencies +@Riverpod(dependencies: [dep]) +int watchGeneratedScopedButMissingDependencies( + Ref ref, +) { + ref.watch(depProvider); + return ref.watch(generatedScopedProvider); +} + +@Riverpod(dependencies: [dep]) +int watchRootButMissingDependencies(Ref ref) { + ref.watch(depProvider); + // expect_lint: avoid_manual_providers_as_generated_provider_dependency + return ref.watch(root); +} + +@Riverpod(dependencies: [dep]) +int watchGeneratedRootButMissingDependencies( + Ref ref, +) { + ref.watch(depProvider); + return ref.watch(generatedRootProvider); +} + // Check "dependencies" specified and contains dependency @Riverpod(dependencies: [generatedScoped]) int watchGeneratedScopedAndContainsDependency( - WatchGeneratedScopedAndContainsDependencyRef ref, + Ref ref, ) { return ref.watch(generatedScopedProvider); } +@Riverpod( + dependencies: + // The dependency is redundant because it is not a scoped provider + // expect_lint: provider_dependencies + [ + generatedRoot, + ], +) +int watchGeneratedRootAndContainsDependency( + Ref ref, +) { + return ref.watch(generatedRootProvider); +} + +// A dependency is specified but never used + +@Riverpod(dependencies: + // generatedRoot is extra + // expect_lint: provider_dependencies + [ + dep, + generatedRoot, +]) +int specifiedDependencyButNeverUsed(Ref ref) { + ref.watch(depProvider); + return 0; +} + // Works with classes too @Riverpod(dependencies: []) class ClassWatchGeneratedRootButMissingDependencies @@ -92,7 +159,7 @@ class ClassWatchGeneratedRootButMissingDependencies } @Riverpod(dependencies: [generatedScoped]) -int regression2348(Regression2348Ref ref) { +int regression2348(Ref ref) { ref..watch(generatedScopedProvider); return 0; } @@ -109,20 +176,21 @@ class Regression2417 extends _$Regression2417 { // Regression for https://github.com/rrousselGit/riverpod/issues/2909 @Riverpod(dependencies: [dep]) -int familyDep(FamilyDepRef ref, int p) { +int familyDep(Ref ref, int p) { final test = ref.watch(depProvider); return test * p; } @Riverpod(dependencies: [familyDep]) -int familyDep2(FamilyDep2Ref ref, int p) { +int familyDep2(Ref ref, int p) { final test = ref.watch(familyDepProvider(0)); return test * p; } // Regression test for https://github.com/rrousselGit/riverpod/issues/2935 @riverpod -int alias(AliasRef ref) { +int alias(Ref ref) { + // expect_lint: avoid_manual_providers_as_generated_provider_dependency ref.watch(import_alias.aProvider); ref.watch(import_alias.bProvider); return 0; @@ -131,6 +199,7 @@ int alias(AliasRef ref) { // Regression test for https://github.com/rrousselGit/riverpod/issues/2935 @riverpod class AliasClass extends _$AliasClass { + // expect_lint: avoid_manual_providers_as_generated_provider_dependency late final int _a = ref.read(import_alias.aProvider); late final int _b = ref.read(import_alias.bProvider); @@ -193,7 +262,7 @@ void fn3() => fn(); // expect_lint: provider_dependencies @riverpod -int foo(FooRef ref) { +int foo(Ref ref) { fn(); return 0; } @@ -270,7 +339,7 @@ class _Stateful3State extends State { // expect_lint: provider_dependencies @riverpod -int crossFileDependency(CrossFileDependencyRef ref) { +int crossFileDependency(Ref ref) { ref.watch(anotherNonEmptyScopedProvider); return 0; } diff --git a/packages/riverpod_lint_flutter_test/test/lints/provider_dependencies/missing_dependencies2.g.dart b/packages/riverpod_lint_flutter_test/test/lints/provider_dependencies/missing_dependencies2.g.dart index aebad7d82..9f0fb55b1 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/provider_dependencies/missing_dependencies2.g.dart +++ b/packages/riverpod_lint_flutter_test/test/lints/provider_dependencies/missing_dependencies2.g.dart @@ -6,16 +6,14 @@ part of 'missing_dependencies2.dart'; // RiverpodGenerator // ************************************************************************** -typedef DepRef = Ref; - @ProviderFor(dep) const depProvider = DepProvider._(); final class DepProvider extends $FunctionalProvider - with $Provider { + with $Provider { const DepProvider._( {int Function( - DepRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -29,7 +27,7 @@ final class DepProvider extends $FunctionalProvider ); final int Function( - DepRef ref, + Ref ref, )? _createCb; @override @@ -51,31 +49,29 @@ final class DepProvider extends $FunctionalProvider @override DepProvider $copyWithCreate( int Function( - DepRef ref, + Ref ref, ) create, ) { return DepProvider._(create: create); } @override - int create(DepRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? dep; return _$cb(ref); } } -String _$depHash() => r'749c4d696d29c72686cabcabd6fa7855f5cbf4db'; - -typedef GeneratedScopedRef = Ref; +String _$depHash() => r'578a350a40cda46444ecd9fa3ea2fd7bd0994692'; @ProviderFor(generatedScoped) const generatedScopedProvider = GeneratedScopedProvider._(); final class GeneratedScopedProvider extends $FunctionalProvider - with $Provider { + with $Provider { const GeneratedScopedProvider._( {int Function( - GeneratedScopedRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -89,7 +85,7 @@ final class GeneratedScopedProvider extends $FunctionalProvider ); final int Function( - GeneratedScopedRef ref, + Ref ref, )? _createCb; @override @@ -111,31 +107,29 @@ final class GeneratedScopedProvider extends $FunctionalProvider @override GeneratedScopedProvider $copyWithCreate( int Function( - GeneratedScopedRef ref, + Ref ref, ) create, ) { return GeneratedScopedProvider._(create: create); } @override - int create(GeneratedScopedRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? generatedScoped; return _$cb(ref); } } -String _$generatedScopedHash() => r'2eefb4cc872ddccfeb862142fd5f7e6d8bd82159'; - -typedef GeneratedRootRef = Ref; +String _$generatedScopedHash() => r'f8e5b6926ce13765c83dbb7f8c8458c9c5fe7d69'; @ProviderFor(generatedRoot) const generatedRootProvider = GeneratedRootProvider._(); final class GeneratedRootProvider extends $FunctionalProvider - with $Provider { + with $Provider { const GeneratedRootProvider._( {int Function( - GeneratedRootRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -149,7 +143,7 @@ final class GeneratedRootProvider extends $FunctionalProvider ); final int Function( - GeneratedRootRef ref, + Ref ref, )? _createCb; @override @@ -171,33 +165,30 @@ final class GeneratedRootProvider extends $FunctionalProvider @override GeneratedRootProvider $copyWithCreate( int Function( - GeneratedRootRef ref, + Ref ref, ) create, ) { return GeneratedRootProvider._(create: create); } @override - int create(GeneratedRootRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? generatedRoot; return _$cb(ref); } } -String _$generatedRootHash() => r'080e3393566db0f44add3607e28a5a2980948704'; - -typedef WatchScopedButNoDependenciesRef = Ref; +String _$generatedRootHash() => r'179253a56503f28bb616c602d8af9ad3b23d438f'; @ProviderFor(watchScopedButNoDependencies) const watchScopedButNoDependenciesProvider = WatchScopedButNoDependenciesProvider._(); final class WatchScopedButNoDependenciesProvider - extends $FunctionalProvider - with $Provider { + extends $FunctionalProvider with $Provider { const WatchScopedButNoDependenciesProvider._( {int Function( - WatchScopedButNoDependenciesRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -211,7 +202,7 @@ final class WatchScopedButNoDependenciesProvider ); final int Function( - WatchScopedButNoDependenciesRef ref, + Ref ref, )? _createCb; @override @@ -233,34 +224,31 @@ final class WatchScopedButNoDependenciesProvider @override WatchScopedButNoDependenciesProvider $copyWithCreate( int Function( - WatchScopedButNoDependenciesRef ref, + Ref ref, ) create, ) { return WatchScopedButNoDependenciesProvider._(create: create); } @override - int create(WatchScopedButNoDependenciesRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? watchScopedButNoDependencies; return _$cb(ref); } } String _$watchScopedButNoDependenciesHash() => - r'3ec52c4ab2ea2b3204b7aa049d1756c01c014ff0'; - -typedef WatchGeneratedScopedButNoDependenciesRef = Ref; + r'e326226fdc19ea7a4430900154c071f5a1a98e40'; @ProviderFor(watchGeneratedScopedButNoDependencies) const watchGeneratedScopedButNoDependenciesProvider = WatchGeneratedScopedButNoDependenciesProvider._(); final class WatchGeneratedScopedButNoDependenciesProvider - extends $FunctionalProvider - with $Provider { + extends $FunctionalProvider with $Provider { const WatchGeneratedScopedButNoDependenciesProvider._( {int Function( - WatchGeneratedScopedButNoDependenciesRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -274,7 +262,7 @@ final class WatchGeneratedScopedButNoDependenciesProvider ); final int Function( - WatchGeneratedScopedButNoDependenciesRef ref, + Ref ref, )? _createCb; @override @@ -297,34 +285,31 @@ final class WatchGeneratedScopedButNoDependenciesProvider @override WatchGeneratedScopedButNoDependenciesProvider $copyWithCreate( int Function( - WatchGeneratedScopedButNoDependenciesRef ref, + Ref ref, ) create, ) { return WatchGeneratedScopedButNoDependenciesProvider._(create: create); } @override - int create(WatchGeneratedScopedButNoDependenciesRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? watchGeneratedScopedButNoDependencies; return _$cb(ref); } } String _$watchGeneratedScopedButNoDependenciesHash() => - r'2a4aba824078fe2c999260b4138939dee96c4fba'; - -typedef WatchRootButNoDependenciesRef = Ref; + r'2109f8ccbc13632e45f18ccb93bc3059c431eba1'; @ProviderFor(watchRootButNoDependencies) const watchRootButNoDependenciesProvider = WatchRootButNoDependenciesProvider._(); final class WatchRootButNoDependenciesProvider - extends $FunctionalProvider - with $Provider { + extends $FunctionalProvider with $Provider { const WatchRootButNoDependenciesProvider._( {int Function( - WatchRootButNoDependenciesRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -338,7 +323,7 @@ final class WatchRootButNoDependenciesProvider ); final int Function( - WatchRootButNoDependenciesRef ref, + Ref ref, )? _createCb; @override @@ -360,34 +345,31 @@ final class WatchRootButNoDependenciesProvider @override WatchRootButNoDependenciesProvider $copyWithCreate( int Function( - WatchRootButNoDependenciesRef ref, + Ref ref, ) create, ) { return WatchRootButNoDependenciesProvider._(create: create); } @override - int create(WatchRootButNoDependenciesRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? watchRootButNoDependencies; return _$cb(ref); } } String _$watchRootButNoDependenciesHash() => - r'037187e333a5bd5d11d00147d179640b8a0f18dd'; - -typedef WatchGeneratedRootButNoDependenciesRef = Ref; + r'cfecc8aeb539e82c46276f9e4dd78c323b4bef12'; @ProviderFor(watchGeneratedRootButNoDependencies) const watchGeneratedRootButNoDependenciesProvider = WatchGeneratedRootButNoDependenciesProvider._(); final class WatchGeneratedRootButNoDependenciesProvider - extends $FunctionalProvider - with $Provider { + extends $FunctionalProvider with $Provider { const WatchGeneratedRootButNoDependenciesProvider._( {int Function( - WatchGeneratedRootButNoDependenciesRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -401,7 +383,7 @@ final class WatchGeneratedRootButNoDependenciesProvider ); final int Function( - WatchGeneratedRootButNoDependenciesRef ref, + Ref ref, )? _createCb; @override @@ -424,34 +406,31 @@ final class WatchGeneratedRootButNoDependenciesProvider @override WatchGeneratedRootButNoDependenciesProvider $copyWithCreate( int Function( - WatchGeneratedRootButNoDependenciesRef ref, + Ref ref, ) create, ) { return WatchGeneratedRootButNoDependenciesProvider._(create: create); } @override - int create(WatchGeneratedRootButNoDependenciesRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? watchGeneratedRootButNoDependencies; return _$cb(ref); } } String _$watchGeneratedRootButNoDependenciesHash() => - r'ecf43cc257376d2828638ce937813d2b72b46967'; - -typedef WatchScopedButEmptyDependenciesRef = Ref; + r'c839dab901f606c11c78f9c8761931027d3db1d1'; @ProviderFor(watchScopedButEmptyDependencies) const watchScopedButEmptyDependenciesProvider = WatchScopedButEmptyDependenciesProvider._(); final class WatchScopedButEmptyDependenciesProvider - extends $FunctionalProvider - with $Provider { + extends $FunctionalProvider with $Provider { const WatchScopedButEmptyDependenciesProvider._( {int Function( - WatchScopedButEmptyDependenciesRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -465,7 +444,7 @@ final class WatchScopedButEmptyDependenciesProvider ); final int Function( - WatchScopedButEmptyDependenciesRef ref, + Ref ref, )? _createCb; @override @@ -487,34 +466,31 @@ final class WatchScopedButEmptyDependenciesProvider @override WatchScopedButEmptyDependenciesProvider $copyWithCreate( int Function( - WatchScopedButEmptyDependenciesRef ref, + Ref ref, ) create, ) { return WatchScopedButEmptyDependenciesProvider._(create: create); } @override - int create(WatchScopedButEmptyDependenciesRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? watchScopedButEmptyDependencies; return _$cb(ref); } } String _$watchScopedButEmptyDependenciesHash() => - r'6b7526eb9dfd70c8249c71efffc60d612ca92f16'; - -typedef WatchGeneratedScopedButEmptyDependenciesRef = Ref; + r'a194f52730f635e9c92b3467b33b8c302c93b1ab'; @ProviderFor(watchGeneratedScopedButEmptyDependencies) const watchGeneratedScopedButEmptyDependenciesProvider = WatchGeneratedScopedButEmptyDependenciesProvider._(); final class WatchGeneratedScopedButEmptyDependenciesProvider - extends $FunctionalProvider - with $Provider { + extends $FunctionalProvider with $Provider { const WatchGeneratedScopedButEmptyDependenciesProvider._( {int Function( - WatchGeneratedScopedButEmptyDependenciesRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -528,7 +504,7 @@ final class WatchGeneratedScopedButEmptyDependenciesProvider ); final int Function( - WatchGeneratedScopedButEmptyDependenciesRef ref, + Ref ref, )? _createCb; @override @@ -551,34 +527,31 @@ final class WatchGeneratedScopedButEmptyDependenciesProvider @override WatchGeneratedScopedButEmptyDependenciesProvider $copyWithCreate( int Function( - WatchGeneratedScopedButEmptyDependenciesRef ref, + Ref ref, ) create, ) { return WatchGeneratedScopedButEmptyDependenciesProvider._(create: create); } @override - int create(WatchGeneratedScopedButEmptyDependenciesRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? watchGeneratedScopedButEmptyDependencies; return _$cb(ref); } } String _$watchGeneratedScopedButEmptyDependenciesHash() => - r'5dc6791ab2f661a378de3e8335943a48e8305435'; - -typedef WatchRootButEmptyDependenciesRef = Ref; + r'fa4cb564341e7b3f0dd10f70e17381c67859c643'; @ProviderFor(watchRootButEmptyDependencies) const watchRootButEmptyDependenciesProvider = WatchRootButEmptyDependenciesProvider._(); final class WatchRootButEmptyDependenciesProvider - extends $FunctionalProvider - with $Provider { + extends $FunctionalProvider with $Provider { const WatchRootButEmptyDependenciesProvider._( {int Function( - WatchRootButEmptyDependenciesRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -592,7 +565,7 @@ final class WatchRootButEmptyDependenciesProvider ); final int Function( - WatchRootButEmptyDependenciesRef ref, + Ref ref, )? _createCb; @override @@ -614,34 +587,31 @@ final class WatchRootButEmptyDependenciesProvider @override WatchRootButEmptyDependenciesProvider $copyWithCreate( int Function( - WatchRootButEmptyDependenciesRef ref, + Ref ref, ) create, ) { return WatchRootButEmptyDependenciesProvider._(create: create); } @override - int create(WatchRootButEmptyDependenciesRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? watchRootButEmptyDependencies; return _$cb(ref); } } String _$watchRootButEmptyDependenciesHash() => - r'c95800f6aec446737168ac8dc3e6edcaeeed3bc0'; - -typedef WatchGeneratedRootButEmptyDependenciesRef = Ref; + r'8669a421efcd8caadc0d070f0c88043668610bbb'; @ProviderFor(watchGeneratedRootButEmptyDependencies) const watchGeneratedRootButEmptyDependenciesProvider = WatchGeneratedRootButEmptyDependenciesProvider._(); final class WatchGeneratedRootButEmptyDependenciesProvider - extends $FunctionalProvider - with $Provider { + extends $FunctionalProvider with $Provider { const WatchGeneratedRootButEmptyDependenciesProvider._( {int Function( - WatchGeneratedRootButEmptyDependenciesRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -655,7 +625,7 @@ final class WatchGeneratedRootButEmptyDependenciesProvider ); final int Function( - WatchGeneratedRootButEmptyDependenciesRef ref, + Ref ref, )? _createCb; @override @@ -678,34 +648,293 @@ final class WatchGeneratedRootButEmptyDependenciesProvider @override WatchGeneratedRootButEmptyDependenciesProvider $copyWithCreate( int Function( - WatchGeneratedRootButEmptyDependenciesRef ref, + Ref ref, ) create, ) { return WatchGeneratedRootButEmptyDependenciesProvider._(create: create); } @override - int create(WatchGeneratedRootButEmptyDependenciesRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? watchGeneratedRootButEmptyDependencies; return _$cb(ref); } } String _$watchGeneratedRootButEmptyDependenciesHash() => - r'9fb97c1fa207a18870cd23c682305dcef413a706'; + r'80581ac491e25ae8c6ee7b7f25dff9939f8de37c'; + +@ProviderFor(watchScopedButMissingDependencies) +const watchScopedButMissingDependenciesProvider = + WatchScopedButMissingDependenciesProvider._(); + +final class WatchScopedButMissingDependenciesProvider + extends $FunctionalProvider with $Provider { + const WatchScopedButMissingDependenciesProvider._( + {int Function( + Ref ref, + )? create}) + : _createCb = create, + super( + from: null, + argument: null, + retry: null, + name: r'watchScopedButMissingDependenciesProvider', + isAutoDispose: true, + dependencies: const [depProvider], + allTransitiveDependencies: const [ + WatchScopedButMissingDependenciesProvider + .$allTransitiveDependencies0, + ], + ); + + static const $allTransitiveDependencies0 = depProvider; + + final int Function( + Ref ref, + )? _createCb; + + @override + String debugGetCreateSourceHash() => + _$watchScopedButMissingDependenciesHash(); + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(int value) { + return $ProviderOverride( + origin: this, + providerOverride: $ValueProvider(value), + ); + } + + @$internal + @override + $ProviderElement $createElement($ProviderPointer pointer) => + $ProviderElement(this, pointer); + + @override + WatchScopedButMissingDependenciesProvider $copyWithCreate( + int Function( + Ref ref, + ) create, + ) { + return WatchScopedButMissingDependenciesProvider._(create: create); + } + + @override + int create(Ref ref) { + final _$cb = _createCb ?? watchScopedButMissingDependencies; + return _$cb(ref); + } +} + +String _$watchScopedButMissingDependenciesHash() => + r'c890e4845b1fca73ee02442eb7a203734605173c'; + +@ProviderFor(watchGeneratedScopedButMissingDependencies) +const watchGeneratedScopedButMissingDependenciesProvider = + WatchGeneratedScopedButMissingDependenciesProvider._(); + +final class WatchGeneratedScopedButMissingDependenciesProvider + extends $FunctionalProvider with $Provider { + const WatchGeneratedScopedButMissingDependenciesProvider._( + {int Function( + Ref ref, + )? create}) + : _createCb = create, + super( + from: null, + argument: null, + retry: null, + name: r'watchGeneratedScopedButMissingDependenciesProvider', + isAutoDispose: true, + dependencies: const [depProvider], + allTransitiveDependencies: const [ + WatchGeneratedScopedButMissingDependenciesProvider + .$allTransitiveDependencies0, + ], + ); + + static const $allTransitiveDependencies0 = depProvider; + + final int Function( + Ref ref, + )? _createCb; + + @override + String debugGetCreateSourceHash() => + _$watchGeneratedScopedButMissingDependenciesHash(); + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(int value) { + return $ProviderOverride( + origin: this, + providerOverride: $ValueProvider(value), + ); + } + + @$internal + @override + $ProviderElement $createElement($ProviderPointer pointer) => + $ProviderElement(this, pointer); + + @override + WatchGeneratedScopedButMissingDependenciesProvider $copyWithCreate( + int Function( + Ref ref, + ) create, + ) { + return WatchGeneratedScopedButMissingDependenciesProvider._(create: create); + } + + @override + int create(Ref ref) { + final _$cb = _createCb ?? watchGeneratedScopedButMissingDependencies; + return _$cb(ref); + } +} + +String _$watchGeneratedScopedButMissingDependenciesHash() => + r'fbbb5f1ea3725a7554dc05073f47a6b9ce5d913d'; + +@ProviderFor(watchRootButMissingDependencies) +const watchRootButMissingDependenciesProvider = + WatchRootButMissingDependenciesProvider._(); + +final class WatchRootButMissingDependenciesProvider + extends $FunctionalProvider with $Provider { + const WatchRootButMissingDependenciesProvider._( + {int Function( + Ref ref, + )? create}) + : _createCb = create, + super( + from: null, + argument: null, + retry: null, + name: r'watchRootButMissingDependenciesProvider', + isAutoDispose: true, + dependencies: const [depProvider], + allTransitiveDependencies: const [ + WatchRootButMissingDependenciesProvider.$allTransitiveDependencies0, + ], + ); + + static const $allTransitiveDependencies0 = depProvider; + + final int Function( + Ref ref, + )? _createCb; + + @override + String debugGetCreateSourceHash() => _$watchRootButMissingDependenciesHash(); + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(int value) { + return $ProviderOverride( + origin: this, + providerOverride: $ValueProvider(value), + ); + } + + @$internal + @override + $ProviderElement $createElement($ProviderPointer pointer) => + $ProviderElement(this, pointer); + + @override + WatchRootButMissingDependenciesProvider $copyWithCreate( + int Function( + Ref ref, + ) create, + ) { + return WatchRootButMissingDependenciesProvider._(create: create); + } + + @override + int create(Ref ref) { + final _$cb = _createCb ?? watchRootButMissingDependencies; + return _$cb(ref); + } +} + +String _$watchRootButMissingDependenciesHash() => + r'cc9c5e6c3a1c34e291a63c429fb031e0cc701499'; + +@ProviderFor(watchGeneratedRootButMissingDependencies) +const watchGeneratedRootButMissingDependenciesProvider = + WatchGeneratedRootButMissingDependenciesProvider._(); + +final class WatchGeneratedRootButMissingDependenciesProvider + extends $FunctionalProvider with $Provider { + const WatchGeneratedRootButMissingDependenciesProvider._( + {int Function( + Ref ref, + )? create}) + : _createCb = create, + super( + from: null, + argument: null, + retry: null, + name: r'watchGeneratedRootButMissingDependenciesProvider', + isAutoDispose: true, + dependencies: const [depProvider], + allTransitiveDependencies: const [ + WatchGeneratedRootButMissingDependenciesProvider + .$allTransitiveDependencies0, + ], + ); -typedef WatchGeneratedScopedAndContainsDependencyRef = Ref; + static const $allTransitiveDependencies0 = depProvider; + + final int Function( + Ref ref, + )? _createCb; + + @override + String debugGetCreateSourceHash() => + _$watchGeneratedRootButMissingDependenciesHash(); + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(int value) { + return $ProviderOverride( + origin: this, + providerOverride: $ValueProvider(value), + ); + } + + @$internal + @override + $ProviderElement $createElement($ProviderPointer pointer) => + $ProviderElement(this, pointer); + + @override + WatchGeneratedRootButMissingDependenciesProvider $copyWithCreate( + int Function( + Ref ref, + ) create, + ) { + return WatchGeneratedRootButMissingDependenciesProvider._(create: create); + } + + @override + int create(Ref ref) { + final _$cb = _createCb ?? watchGeneratedRootButMissingDependencies; + return _$cb(ref); + } +} + +String _$watchGeneratedRootButMissingDependenciesHash() => + r'10d01aea2b6b0772e98172f410bdbfce85786243'; @ProviderFor(watchGeneratedScopedAndContainsDependency) const watchGeneratedScopedAndContainsDependencyProvider = WatchGeneratedScopedAndContainsDependencyProvider._(); final class WatchGeneratedScopedAndContainsDependencyProvider - extends $FunctionalProvider - with $Provider { + extends $FunctionalProvider with $Provider { const WatchGeneratedScopedAndContainsDependencyProvider._( {int Function( - WatchGeneratedScopedAndContainsDependencyRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -724,7 +953,7 @@ final class WatchGeneratedScopedAndContainsDependencyProvider static const $allTransitiveDependencies0 = generatedScopedProvider; final int Function( - WatchGeneratedScopedAndContainsDependencyRef ref, + Ref ref, )? _createCb; @override @@ -747,21 +976,156 @@ final class WatchGeneratedScopedAndContainsDependencyProvider @override WatchGeneratedScopedAndContainsDependencyProvider $copyWithCreate( int Function( - WatchGeneratedScopedAndContainsDependencyRef ref, + Ref ref, ) create, ) { return WatchGeneratedScopedAndContainsDependencyProvider._(create: create); } @override - int create(WatchGeneratedScopedAndContainsDependencyRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? watchGeneratedScopedAndContainsDependency; return _$cb(ref); } } String _$watchGeneratedScopedAndContainsDependencyHash() => - r'320592737e763091c1229a79ae07fe961e7aab72'; + r'948e75e097500b33ee2fdbd3dc9fdecafa5f3d10'; + +@ProviderFor(watchGeneratedRootAndContainsDependency) +const watchGeneratedRootAndContainsDependencyProvider = + WatchGeneratedRootAndContainsDependencyProvider._(); + +final class WatchGeneratedRootAndContainsDependencyProvider + extends $FunctionalProvider with $Provider { + const WatchGeneratedRootAndContainsDependencyProvider._( + {int Function( + Ref ref, + )? create}) + : _createCb = create, + super( + from: null, + argument: null, + retry: null, + name: r'watchGeneratedRootAndContainsDependencyProvider', + isAutoDispose: true, + dependencies: const [generatedRootProvider], + allTransitiveDependencies: const [ + WatchGeneratedRootAndContainsDependencyProvider + .$allTransitiveDependencies0, + ], + ); + + static const $allTransitiveDependencies0 = generatedRootProvider; + + final int Function( + Ref ref, + )? _createCb; + + @override + String debugGetCreateSourceHash() => + _$watchGeneratedRootAndContainsDependencyHash(); + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(int value) { + return $ProviderOverride( + origin: this, + providerOverride: $ValueProvider(value), + ); + } + + @$internal + @override + $ProviderElement $createElement($ProviderPointer pointer) => + $ProviderElement(this, pointer); + + @override + WatchGeneratedRootAndContainsDependencyProvider $copyWithCreate( + int Function( + Ref ref, + ) create, + ) { + return WatchGeneratedRootAndContainsDependencyProvider._(create: create); + } + + @override + int create(Ref ref) { + final _$cb = _createCb ?? watchGeneratedRootAndContainsDependency; + return _$cb(ref); + } +} + +String _$watchGeneratedRootAndContainsDependencyHash() => + r'780392b647f1606186ee0f70c81dd5b03f506284'; + +@ProviderFor(specifiedDependencyButNeverUsed) +const specifiedDependencyButNeverUsedProvider = + SpecifiedDependencyButNeverUsedProvider._(); + +final class SpecifiedDependencyButNeverUsedProvider + extends $FunctionalProvider with $Provider { + const SpecifiedDependencyButNeverUsedProvider._( + {int Function( + Ref ref, + )? create}) + : _createCb = create, + super( + from: null, + argument: null, + retry: null, + name: r'specifiedDependencyButNeverUsedProvider', + isAutoDispose: true, + dependencies: const [ + depProvider, + generatedRootProvider + ], + allTransitiveDependencies: const [ + SpecifiedDependencyButNeverUsedProvider.$allTransitiveDependencies0, + SpecifiedDependencyButNeverUsedProvider.$allTransitiveDependencies1, + ], + ); + + static const $allTransitiveDependencies0 = depProvider; + static const $allTransitiveDependencies1 = generatedRootProvider; + + final int Function( + Ref ref, + )? _createCb; + + @override + String debugGetCreateSourceHash() => _$specifiedDependencyButNeverUsedHash(); + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(int value) { + return $ProviderOverride( + origin: this, + providerOverride: $ValueProvider(value), + ); + } + + @$internal + @override + $ProviderElement $createElement($ProviderPointer pointer) => + $ProviderElement(this, pointer); + + @override + SpecifiedDependencyButNeverUsedProvider $copyWithCreate( + int Function( + Ref ref, + ) create, + ) { + return SpecifiedDependencyButNeverUsedProvider._(create: create); + } + + @override + int create(Ref ref) { + final _$cb = _createCb ?? specifiedDependencyButNeverUsed; + return _$cb(ref); + } +} + +String _$specifiedDependencyButNeverUsedHash() => + r'cca97d259bcacbff290f0d459e0de3a9b5b6a510'; @ProviderFor(ClassWatchGeneratedRootButMissingDependencies) const classWatchGeneratedRootButMissingDependenciesProvider = @@ -816,7 +1180,7 @@ final class ClassWatchGeneratedRootButMissingDependenciesProvider @override ClassWatchGeneratedRootButMissingDependenciesProvider $copyWithBuild( int Function( - Ref, + Ref, ClassWatchGeneratedRootButMissingDependencies, ) build, ) { @@ -842,16 +1206,14 @@ abstract class _$ClassWatchGeneratedRootButMissingDependencies int runBuild() => build(); } -typedef Regression2348Ref = Ref; - @ProviderFor(regression2348) const regression2348Provider = Regression2348Provider._(); final class Regression2348Provider extends $FunctionalProvider - with $Provider { + with $Provider { const Regression2348Provider._( {int Function( - Regression2348Ref ref, + Ref ref, )? create}) : _createCb = create, super( @@ -869,7 +1231,7 @@ final class Regression2348Provider extends $FunctionalProvider static const $allTransitiveDependencies0 = generatedScopedProvider; final int Function( - Regression2348Ref ref, + Ref ref, )? _createCb; @override @@ -891,20 +1253,20 @@ final class Regression2348Provider extends $FunctionalProvider @override Regression2348Provider $copyWithCreate( int Function( - Regression2348Ref ref, + Ref ref, ) create, ) { return Regression2348Provider._(create: create); } @override - int create(Regression2348Ref ref) { + int create(Ref ref) { final _$cb = _createCb ?? regression2348; return _$cb(ref); } } -String _$regression2348Hash() => r'72fbbe420e9835c9843c28b7c9375ca3d99ca4b7'; +String _$regression2348Hash() => r'6ad005595ee202c8b0188562ed8c4a33d01260e2'; @ProviderFor(Regression2417) const regression2417Provider = Regression2417Provider._(); @@ -957,7 +1319,7 @@ final class Regression2417Provider @override Regression2417Provider $copyWithBuild( int Function( - Ref, + Ref, Regression2417, ) build, ) { @@ -980,18 +1342,16 @@ abstract class _$Regression2417 extends $Notifier { int runBuild() => build(); } -typedef FamilyDepRef = Ref; - @ProviderFor(familyDep) const familyDepProvider = FamilyDepFamily._(); final class FamilyDepProvider extends $FunctionalProvider - with $Provider { + with $Provider { const FamilyDepProvider._( {required FamilyDepFamily super.from, required int super.argument, int Function( - FamilyDepRef ref, + Ref ref, int p, )? create}) : _createCb = create, @@ -1006,7 +1366,7 @@ final class FamilyDepProvider extends $FunctionalProvider static const $allTransitiveDependencies0 = depProvider; final int Function( - FamilyDepRef ref, + Ref ref, int p, )? _createCb; @@ -1036,7 +1396,7 @@ final class FamilyDepProvider extends $FunctionalProvider @override FamilyDepProvider $copyWithCreate( int Function( - FamilyDepRef ref, + Ref ref, ) create, ) { return FamilyDepProvider._( @@ -1050,7 +1410,7 @@ final class FamilyDepProvider extends $FunctionalProvider } @override - int create(FamilyDepRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? familyDep; final argument = this.argument as int; return _$cb( @@ -1070,7 +1430,7 @@ final class FamilyDepProvider extends $FunctionalProvider } } -String _$familyDepHash() => r'1c152873ed2b3e88da09d8e1fc53a33635cbe3b3'; +String _$familyDepHash() => r'ed674a44492b3871b72b4fbc68180ea0839723e5'; final class FamilyDepFamily extends Family { const FamilyDepFamily._() @@ -1098,7 +1458,7 @@ final class FamilyDepFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( int Function( - FamilyDepRef ref, + Ref ref, int args, ) create, ) { @@ -1117,18 +1477,16 @@ final class FamilyDepFamily extends Family { } } -typedef FamilyDep2Ref = Ref; - @ProviderFor(familyDep2) const familyDep2Provider = FamilyDep2Family._(); final class FamilyDep2Provider extends $FunctionalProvider - with $Provider { + with $Provider { const FamilyDep2Provider._( {required FamilyDep2Family super.from, required int super.argument, int Function( - FamilyDep2Ref ref, + Ref ref, int p, )? create}) : _createCb = create, @@ -1145,7 +1503,7 @@ final class FamilyDep2Provider extends $FunctionalProvider FamilyDepProvider.$allTransitiveDependencies0; final int Function( - FamilyDep2Ref ref, + Ref ref, int p, )? _createCb; @@ -1175,7 +1533,7 @@ final class FamilyDep2Provider extends $FunctionalProvider @override FamilyDep2Provider $copyWithCreate( int Function( - FamilyDep2Ref ref, + Ref ref, ) create, ) { return FamilyDep2Provider._( @@ -1189,7 +1547,7 @@ final class FamilyDep2Provider extends $FunctionalProvider } @override - int create(FamilyDep2Ref ref) { + int create(Ref ref) { final _$cb = _createCb ?? familyDep2; final argument = this.argument as int; return _$cb( @@ -1209,7 +1567,7 @@ final class FamilyDep2Provider extends $FunctionalProvider } } -String _$familyDep2Hash() => r'd81e2e56d75dd08a695b834853a3a6cea99ea305'; +String _$familyDep2Hash() => r'ee9c96f7a1d65e1b66c29aa8d8c030146995504c'; final class FamilyDep2Family extends Family { const FamilyDep2Family._() @@ -1238,7 +1596,7 @@ final class FamilyDep2Family extends Family { /// {@macro riverpod.override_with} Override overrideWith( int Function( - FamilyDep2Ref ref, + Ref ref, int args, ) create, ) { @@ -1257,16 +1615,14 @@ final class FamilyDep2Family extends Family { } } -typedef AliasRef = Ref; - @ProviderFor(alias) const aliasProvider = AliasProvider._(); final class AliasProvider extends $FunctionalProvider - with $Provider { + with $Provider { const AliasProvider._( {int Function( - AliasRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -1280,7 +1636,7 @@ final class AliasProvider extends $FunctionalProvider ); final int Function( - AliasRef ref, + Ref ref, )? _createCb; @override @@ -1302,20 +1658,20 @@ final class AliasProvider extends $FunctionalProvider @override AliasProvider $copyWithCreate( int Function( - AliasRef ref, + Ref ref, ) create, ) { return AliasProvider._(create: create); } @override - int create(AliasRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? alias; return _$cb(ref); } } -String _$aliasHash() => r'871c6c7ab22e4bbed2dc46917daf42e7fc1b9d88'; +String _$aliasHash() => r'b410585ad56c66160898a05647e09e1a606aa9d2'; @ProviderFor(AliasClass) const aliasClassProvider = AliasClassProvider._(); @@ -1363,7 +1719,7 @@ final class AliasClassProvider extends $NotifierProvider { @override AliasClassProvider $copyWithBuild( int Function( - Ref, + Ref, AliasClass, ) build, ) { @@ -1437,7 +1793,7 @@ final class RiverpodDependenciesProvider @override RiverpodDependenciesProvider $copyWithBuild( int Function( - Ref, + Ref, RiverpodDependencies, ) build, ) { @@ -1461,16 +1817,14 @@ abstract class _$RiverpodDependencies extends $Notifier { int runBuild() => build(); } -typedef FooRef = Ref; - @ProviderFor(foo) const fooProvider = FooProvider._(); final class FooProvider extends $FunctionalProvider - with $Provider { + with $Provider { const FooProvider._( {int Function( - FooRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -1484,7 +1838,7 @@ final class FooProvider extends $FunctionalProvider ); final int Function( - FooRef ref, + Ref ref, )? _createCb; @override @@ -1506,31 +1860,29 @@ final class FooProvider extends $FunctionalProvider @override FooProvider $copyWithCreate( int Function( - FooRef ref, + Ref ref, ) create, ) { return FooProvider._(create: create); } @override - int create(FooRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? foo; return _$cb(ref); } } -String _$fooHash() => r'f9ce60fe868c2c54aa282702554861a13e8871cd'; - -typedef CrossFileDependencyRef = Ref; +String _$fooHash() => r'a390b7b969bb0eec183426bfc85bec32750e9475'; @ProviderFor(crossFileDependency) const crossFileDependencyProvider = CrossFileDependencyProvider._(); final class CrossFileDependencyProvider extends $FunctionalProvider - with $Provider { + with $Provider { const CrossFileDependencyProvider._( {int Function( - CrossFileDependencyRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -1544,7 +1896,7 @@ final class CrossFileDependencyProvider extends $FunctionalProvider ); final int Function( - CrossFileDependencyRef ref, + Ref ref, )? _createCb; @override @@ -1566,21 +1918,21 @@ final class CrossFileDependencyProvider extends $FunctionalProvider @override CrossFileDependencyProvider $copyWithCreate( int Function( - CrossFileDependencyRef ref, + Ref ref, ) create, ) { return CrossFileDependencyProvider._(create: create); } @override - int create(CrossFileDependencyRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? crossFileDependency; return _$cb(ref); } } String _$crossFileDependencyHash() => - r'9ca6b69de674377c6906fb835cbe04d01851d088'; + r'3ab740fe1903f2c126412df43ee34eed87a6f4fe'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/packages/riverpod_lint_flutter_test/test/lints/provider_dependencies/unused_dependency.dart b/packages/riverpod_lint_flutter_test/test/lints/provider_dependencies/unused_dependency.dart index 650984ed0..1ba634f07 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/provider_dependencies/unused_dependency.dart +++ b/packages/riverpod_lint_flutter_test/test/lints/provider_dependencies/unused_dependency.dart @@ -6,13 +6,13 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'unused_dependency.g.dart'; @riverpod -int root(RootRef ref) => 0; +int root(Ref ref) => 0; @Riverpod(dependencies: []) -int dep(DepRef ref) => 0; +int dep(Ref ref) => 0; @Riverpod(dependencies: []) -int dep2(Dep2Ref ref) => 0; +int dep2(Ref ref) => 0; //////////// @@ -24,7 +24,7 @@ int dep2(Dep2Ref ref) => 0; dep2, ], ) -int extraDep(ExtraDepRef ref) { +int extraDep(Ref ref) { ref.watch(dep2Provider); return 0; } @@ -36,7 +36,7 @@ int extraDep(ExtraDepRef ref) { dep, ], ) -int noDep(NoDepRef ref) { +int noDep(Ref ref) { return 0; } @@ -47,7 +47,7 @@ int noDep(NoDepRef ref) { ], keepAlive: false, ) -int dependenciesFirstThenKeepAlive(DependenciesFirstThenKeepAliveRef ref) { +int dependenciesFirstThenKeepAlive(Ref ref) { return 0; } @@ -57,13 +57,13 @@ int dependenciesFirstThenKeepAlive(DependenciesFirstThenKeepAliveRef ref) { dep, ], ) -int noDepNoParam(NoDepNoParamRef ref) { +int noDepNoParam(Ref ref) { return 0; } // expect_lint: provider_dependencies @Riverpod(keepAlive: false, dependencies: [dep]) -int noDepWithoutComma(NoDepWithoutCommaRef ref) { +int noDepWithoutComma(Ref ref) { return 0; } @@ -74,7 +74,7 @@ int noDepWithoutComma(NoDepWithoutCommaRef ref) { root, ], ) -int rootDep(RootDepRef ref) => 0; +int rootDep(Ref ref) => 0; // expect_lint: provider_dependencies @Dependencies([dep]) diff --git a/packages/riverpod_lint_flutter_test/test/lints/provider_dependencies/unused_dependency.g.dart b/packages/riverpod_lint_flutter_test/test/lints/provider_dependencies/unused_dependency.g.dart index 59f2dc0ad..381eebcf0 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/provider_dependencies/unused_dependency.g.dart +++ b/packages/riverpod_lint_flutter_test/test/lints/provider_dependencies/unused_dependency.g.dart @@ -6,16 +6,14 @@ part of 'unused_dependency.dart'; // RiverpodGenerator // ************************************************************************** -typedef RootRef = Ref; - @ProviderFor(root) const rootProvider = RootProvider._(); final class RootProvider extends $FunctionalProvider - with $Provider { + with $Provider { const RootProvider._( {int Function( - RootRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -29,7 +27,7 @@ final class RootProvider extends $FunctionalProvider ); final int Function( - RootRef ref, + Ref ref, )? _createCb; @override @@ -51,31 +49,29 @@ final class RootProvider extends $FunctionalProvider @override RootProvider $copyWithCreate( int Function( - RootRef ref, + Ref ref, ) create, ) { return RootProvider._(create: create); } @override - int create(RootRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? root; return _$cb(ref); } } -String _$rootHash() => r'1cd85d73316aad02169ff0f5e7af5cf1423410ff'; - -typedef DepRef = Ref; +String _$rootHash() => r'dda8bbb46cb4d7c658597669e3be92e2447dcfb0'; @ProviderFor(dep) const depProvider = DepProvider._(); final class DepProvider extends $FunctionalProvider - with $Provider { + with $Provider { const DepProvider._( {int Function( - DepRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -89,7 +85,7 @@ final class DepProvider extends $FunctionalProvider ); final int Function( - DepRef ref, + Ref ref, )? _createCb; @override @@ -111,31 +107,29 @@ final class DepProvider extends $FunctionalProvider @override DepProvider $copyWithCreate( int Function( - DepRef ref, + Ref ref, ) create, ) { return DepProvider._(create: create); } @override - int create(DepRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? dep; return _$cb(ref); } } -String _$depHash() => r'749c4d696d29c72686cabcabd6fa7855f5cbf4db'; - -typedef Dep2Ref = Ref; +String _$depHash() => r'578a350a40cda46444ecd9fa3ea2fd7bd0994692'; @ProviderFor(dep2) const dep2Provider = Dep2Provider._(); final class Dep2Provider extends $FunctionalProvider - with $Provider { + with $Provider { const Dep2Provider._( {int Function( - Dep2Ref ref, + Ref ref, )? create}) : _createCb = create, super( @@ -149,7 +143,7 @@ final class Dep2Provider extends $FunctionalProvider ); final int Function( - Dep2Ref ref, + Ref ref, )? _createCb; @override @@ -171,23 +165,20 @@ final class Dep2Provider extends $FunctionalProvider @override Dep2Provider $copyWithCreate( int Function( - Dep2Ref ref, + Ref ref, ) create, ) { return Dep2Provider._(create: create); } @override - int create(Dep2Ref ref) { + int create(Ref ref) { final _$cb = _createCb ?? dep2; return _$cb(ref); } } -String _$dep2Hash() => r'13cd909366c79168e3d9cd95f529ddbcee6de7dc'; - -//////////// -typedef ExtraDepRef = Ref; +String _$dep2Hash() => r'97901e825cdcf5b1ac455b0fe8a2111662ce9f13'; //////////// @ProviderFor(extraDep) @@ -195,11 +186,11 @@ const extraDepProvider = ExtraDepProvider._(); //////////// final class ExtraDepProvider extends $FunctionalProvider - with $Provider { + with $Provider { //////////// const ExtraDepProvider._( {int Function( - ExtraDepRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -219,7 +210,7 @@ final class ExtraDepProvider extends $FunctionalProvider static const $allTransitiveDependencies1 = dep2Provider; final int Function( - ExtraDepRef ref, + Ref ref, )? _createCb; @override @@ -241,31 +232,29 @@ final class ExtraDepProvider extends $FunctionalProvider @override ExtraDepProvider $copyWithCreate( int Function( - ExtraDepRef ref, + Ref ref, ) create, ) { return ExtraDepProvider._(create: create); } @override - int create(ExtraDepRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? extraDep; return _$cb(ref); } } -String _$extraDepHash() => r'038d9c819b5d91eb1f7166194d8e646f17ea24d7'; - -typedef NoDepRef = Ref; +String _$extraDepHash() => r'586c1a0f0ac120f8608c025a6a47fe5282b80320'; @ProviderFor(noDep) const noDepProvider = NoDepProvider._(); final class NoDepProvider extends $FunctionalProvider - with $Provider { + with $Provider { const NoDepProvider._( {int Function( - NoDepRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -283,7 +272,7 @@ final class NoDepProvider extends $FunctionalProvider static const $allTransitiveDependencies0 = depProvider; final int Function( - NoDepRef ref, + Ref ref, )? _createCb; @override @@ -305,33 +294,30 @@ final class NoDepProvider extends $FunctionalProvider @override NoDepProvider $copyWithCreate( int Function( - NoDepRef ref, + Ref ref, ) create, ) { return NoDepProvider._(create: create); } @override - int create(NoDepRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? noDep; return _$cb(ref); } } -String _$noDepHash() => r'38d78ded1eba491968c0200cc0b51969fcf3ec9a'; - -typedef DependenciesFirstThenKeepAliveRef = Ref; +String _$noDepHash() => r'99022366e7dd3e19464747d1e2f23184691aa134'; @ProviderFor(dependenciesFirstThenKeepAlive) const dependenciesFirstThenKeepAliveProvider = DependenciesFirstThenKeepAliveProvider._(); final class DependenciesFirstThenKeepAliveProvider - extends $FunctionalProvider - with $Provider { + extends $FunctionalProvider with $Provider { const DependenciesFirstThenKeepAliveProvider._( {int Function( - DependenciesFirstThenKeepAliveRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -349,7 +335,7 @@ final class DependenciesFirstThenKeepAliveProvider static const $allTransitiveDependencies0 = depProvider; final int Function( - DependenciesFirstThenKeepAliveRef ref, + Ref ref, )? _createCb; @override @@ -371,32 +357,30 @@ final class DependenciesFirstThenKeepAliveProvider @override DependenciesFirstThenKeepAliveProvider $copyWithCreate( int Function( - DependenciesFirstThenKeepAliveRef ref, + Ref ref, ) create, ) { return DependenciesFirstThenKeepAliveProvider._(create: create); } @override - int create(DependenciesFirstThenKeepAliveRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? dependenciesFirstThenKeepAlive; return _$cb(ref); } } String _$dependenciesFirstThenKeepAliveHash() => - r'15604dafd167408515dfb4e846fab0af46e7e566'; - -typedef NoDepNoParamRef = Ref; + r'b9bd9082ce9a72feea33f9327b26e7b428cadfd3'; @ProviderFor(noDepNoParam) const noDepNoParamProvider = NoDepNoParamProvider._(); final class NoDepNoParamProvider extends $FunctionalProvider - with $Provider { + with $Provider { const NoDepNoParamProvider._( {int Function( - NoDepNoParamRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -414,7 +398,7 @@ final class NoDepNoParamProvider extends $FunctionalProvider static const $allTransitiveDependencies0 = depProvider; final int Function( - NoDepNoParamRef ref, + Ref ref, )? _createCb; @override @@ -436,31 +420,29 @@ final class NoDepNoParamProvider extends $FunctionalProvider @override NoDepNoParamProvider $copyWithCreate( int Function( - NoDepNoParamRef ref, + Ref ref, ) create, ) { return NoDepNoParamProvider._(create: create); } @override - int create(NoDepNoParamRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? noDepNoParam; return _$cb(ref); } } -String _$noDepNoParamHash() => r'fe52f15a4d98159beafe8b9a177073f6b6cbae6d'; - -typedef NoDepWithoutCommaRef = Ref; +String _$noDepNoParamHash() => r'ea3e66e28bbfb716adf89cea37a1607c78283e06'; @ProviderFor(noDepWithoutComma) const noDepWithoutCommaProvider = NoDepWithoutCommaProvider._(); final class NoDepWithoutCommaProvider extends $FunctionalProvider - with $Provider { + with $Provider { const NoDepWithoutCommaProvider._( {int Function( - NoDepWithoutCommaRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -478,7 +460,7 @@ final class NoDepWithoutCommaProvider extends $FunctionalProvider static const $allTransitiveDependencies0 = depProvider; final int Function( - NoDepWithoutCommaRef ref, + Ref ref, )? _createCb; @override @@ -500,31 +482,29 @@ final class NoDepWithoutCommaProvider extends $FunctionalProvider @override NoDepWithoutCommaProvider $copyWithCreate( int Function( - NoDepWithoutCommaRef ref, + Ref ref, ) create, ) { return NoDepWithoutCommaProvider._(create: create); } @override - int create(NoDepWithoutCommaRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? noDepWithoutComma; return _$cb(ref); } } -String _$noDepWithoutCommaHash() => r'59d5a7874da40605b1b187766ebb4927d2eaae81'; - -typedef RootDepRef = Ref; +String _$noDepWithoutCommaHash() => r'a3b07e526b4829ee4ed1848de4ff64c3b05c1a30'; @ProviderFor(rootDep) const rootDepProvider = RootDepProvider._(); final class RootDepProvider extends $FunctionalProvider - with $Provider { + with $Provider { const RootDepProvider._( {int Function( - RootDepRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -542,7 +522,7 @@ final class RootDepProvider extends $FunctionalProvider static const $allTransitiveDependencies0 = rootProvider; final int Function( - RootDepRef ref, + Ref ref, )? _createCb; @override @@ -564,20 +544,20 @@ final class RootDepProvider extends $FunctionalProvider @override RootDepProvider $copyWithCreate( int Function( - RootDepRef ref, + Ref ref, ) create, ) { return RootDepProvider._(create: create); } @override - int create(RootDepRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? rootDep; return _$cb(ref); } } -String _$rootDepHash() => r'a57728bf865d5a9a73f40f08b038946418cdcf52'; +String _$rootDepHash() => r'c406dc7e58c18bc46ed722a81208bc13fe62654a'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/packages/riverpod_lint_flutter_test/test/lints/provider_parameters.dart b/packages/riverpod_lint_flutter_test/test/lints/provider_parameters.dart index a5992bd7d..5ad69f049 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/provider_parameters.dart +++ b/packages/riverpod_lint_flutter_test/test/lints/provider_parameters.dart @@ -10,7 +10,7 @@ final legacy = Provider.family((ref, value) => 0); final provider = Provider.family((ref, value) => 0); @Riverpod(keepAlive: true) -int generator(GeneratorRef ref, {Object? value}) => 0; +int generator(Ref ref, {Object? value}) => 0; var list = [42]; final dep = Provider((ref) { diff --git a/packages/riverpod_lint_flutter_test/test/lints/provider_parameters.g.dart b/packages/riverpod_lint_flutter_test/test/lints/provider_parameters.g.dart index cac3f9f6f..96dacfe00 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/provider_parameters.g.dart +++ b/packages/riverpod_lint_flutter_test/test/lints/provider_parameters.g.dart @@ -6,18 +6,16 @@ part of 'provider_parameters.dart'; // RiverpodGenerator // ************************************************************************** -typedef GeneratorRef = Ref; - @ProviderFor(generator) const generatorProvider = GeneratorFamily._(); final class GeneratorProvider extends $FunctionalProvider - with $Provider { + with $Provider { const GeneratorProvider._( {required GeneratorFamily super.from, required Object? super.argument, int Function( - GeneratorRef ref, { + Ref ref, { Object? value, })? create}) : _createCb = create, @@ -30,7 +28,7 @@ final class GeneratorProvider extends $FunctionalProvider ); final int Function( - GeneratorRef ref, { + Ref ref, { Object? value, })? _createCb; @@ -60,7 +58,7 @@ final class GeneratorProvider extends $FunctionalProvider @override GeneratorProvider $copyWithCreate( int Function( - GeneratorRef ref, + Ref ref, ) create, ) { return GeneratorProvider._( @@ -74,7 +72,7 @@ final class GeneratorProvider extends $FunctionalProvider } @override - int create(GeneratorRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? generator; final argument = this.argument; return _$cb( @@ -94,7 +92,7 @@ final class GeneratorProvider extends $FunctionalProvider } } -String _$generatorHash() => r'e76b8050c3a272ecef1985e4dc7dfe5df3270f2f'; +String _$generatorHash() => r'd7d1733f8884b6702f363ddb178ae57797d0034f'; final class GeneratorFamily extends Family { const GeneratorFamily._() @@ -120,7 +118,7 @@ final class GeneratorFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( int Function( - GeneratorRef ref, + Ref ref, Object? args, ) create, ) { @@ -139,4 +137,4 @@ final class GeneratorFamily extends Family { } } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/packages/riverpod_lint_flutter_test/test/lints/scoped_providers_should_specify_dependencies.dart b/packages/riverpod_lint_flutter_test/test/lints/scoped_providers_should_specify_dependencies.dart index 5c274efa4..a7a06d4eb 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/scoped_providers_should_specify_dependencies.dart +++ b/packages/riverpod_lint_flutter_test/test/lints/scoped_providers_should_specify_dependencies.dart @@ -15,10 +15,10 @@ class UnimplementedScoped extends _$UnimplementedScoped { } @Riverpod(dependencies: []) -int scoped(ScopedRef ref) => 0; +int scoped(Ref ref) => 0; @riverpod -int root(RootRef ref) => 0; +int root(Ref ref) => 0; // A fake runApp to check that we lint only on the official Flutter's runApp void runApp(Widget widget) {} diff --git a/packages/riverpod_lint_flutter_test/test/lints/scoped_providers_should_specify_dependencies.g.dart b/packages/riverpod_lint_flutter_test/test/lints/scoped_providers_should_specify_dependencies.g.dart index 08c0d1d49..1051c1d99 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/scoped_providers_should_specify_dependencies.g.dart +++ b/packages/riverpod_lint_flutter_test/test/lints/scoped_providers_should_specify_dependencies.g.dart @@ -53,7 +53,7 @@ final class UnimplementedScopedProvider @override UnimplementedScopedProvider $copyWithBuild( int Function( - Ref, + Ref, UnimplementedScoped, ) build, ) { @@ -77,16 +77,14 @@ abstract class _$UnimplementedScoped extends $Notifier { int runBuild() => build(); } -typedef ScopedRef = Ref; - @ProviderFor(scoped) const scopedProvider = ScopedProvider._(); final class ScopedProvider extends $FunctionalProvider - with $Provider { + with $Provider { const ScopedProvider._( {int Function( - ScopedRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -100,7 +98,7 @@ final class ScopedProvider extends $FunctionalProvider ); final int Function( - ScopedRef ref, + Ref ref, )? _createCb; @override @@ -122,31 +120,29 @@ final class ScopedProvider extends $FunctionalProvider @override ScopedProvider $copyWithCreate( int Function( - ScopedRef ref, + Ref ref, ) create, ) { return ScopedProvider._(create: create); } @override - int create(ScopedRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? scoped; return _$cb(ref); } } -String _$scopedHash() => r'bbf25968b1186d2dd63d10545364453712d491cf'; - -typedef RootRef = Ref; +String _$scopedHash() => r'5a271e9b23e18517694454448b922a6c9d03781e'; @ProviderFor(root) const rootProvider = RootProvider._(); final class RootProvider extends $FunctionalProvider - with $Provider { + with $Provider { const RootProvider._( {int Function( - RootRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -160,7 +156,7 @@ final class RootProvider extends $FunctionalProvider ); final int Function( - RootRef ref, + Ref ref, )? _createCb; @override @@ -182,20 +178,20 @@ final class RootProvider extends $FunctionalProvider @override RootProvider $copyWithCreate( int Function( - RootRef ref, + Ref ref, ) create, ) { return RootProvider._(create: create); } @override - int create(RootRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? root; return _$cb(ref); } } -String _$rootHash() => r'1cd85d73316aad02169ff0f5e7af5cf1423410ff'; +String _$rootHash() => r'dda8bbb46cb4d7c658597669e3be92e2447dcfb0'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/packages/riverpod_lint_flutter_test/test/lints/unknown_scoped_usage.dart b/packages/riverpod_lint_flutter_test/test/lints/unknown_scoped_usage.dart index 1d4abfe53..ac0546121 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/unknown_scoped_usage.dart +++ b/packages/riverpod_lint_flutter_test/test/lints/unknown_scoped_usage.dart @@ -5,13 +5,13 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'unknown_scoped_usage.g.dart'; @Riverpod(dependencies: []) -int scoped(ScopedRef ref) => 0; +int scoped(Ref ref) => 0; @riverpod -int root(RootRef ref) => 0; +int root(Ref ref) => 0; @Dependencies([scoped]) -void fn(WidgetRef widgetRef, Ref ref) { +void fn(WidgetRef widgetRef, Ref ref) { // expect_lint: unknown_scoped_usage scopedProvider; rootProvider; diff --git a/packages/riverpod_lint_flutter_test/test/lints/unknown_scoped_usage.g.dart b/packages/riverpod_lint_flutter_test/test/lints/unknown_scoped_usage.g.dart index 4d26711bf..b9df28400 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/unknown_scoped_usage.g.dart +++ b/packages/riverpod_lint_flutter_test/test/lints/unknown_scoped_usage.g.dart @@ -6,16 +6,14 @@ part of 'unknown_scoped_usage.dart'; // RiverpodGenerator // ************************************************************************** -typedef ScopedRef = Ref; - @ProviderFor(scoped) const scopedProvider = ScopedProvider._(); final class ScopedProvider extends $FunctionalProvider - with $Provider { + with $Provider { const ScopedProvider._( {int Function( - ScopedRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -29,7 +27,7 @@ final class ScopedProvider extends $FunctionalProvider ); final int Function( - ScopedRef ref, + Ref ref, )? _createCb; @override @@ -51,31 +49,29 @@ final class ScopedProvider extends $FunctionalProvider @override ScopedProvider $copyWithCreate( int Function( - ScopedRef ref, + Ref ref, ) create, ) { return ScopedProvider._(create: create); } @override - int create(ScopedRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? scoped; return _$cb(ref); } } -String _$scopedHash() => r'bbf25968b1186d2dd63d10545364453712d491cf'; - -typedef RootRef = Ref; +String _$scopedHash() => r'5a271e9b23e18517694454448b922a6c9d03781e'; @ProviderFor(root) const rootProvider = RootProvider._(); final class RootProvider extends $FunctionalProvider - with $Provider { + with $Provider { const RootProvider._( {int Function( - RootRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -89,7 +85,7 @@ final class RootProvider extends $FunctionalProvider ); final int Function( - RootRef ref, + Ref ref, )? _createCb; @override @@ -111,20 +107,20 @@ final class RootProvider extends $FunctionalProvider @override RootProvider $copyWithCreate( int Function( - RootRef ref, + Ref ref, ) create, ) { return RootProvider._(create: create); } @override - int create(RootRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? root; return _$cb(ref); } } -String _$rootHash() => r'1cd85d73316aad02169ff0f5e7af5cf1423410ff'; +String _$rootHash() => r'dda8bbb46cb4d7c658597669e3be92e2447dcfb0'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/packages/riverpod_lint_flutter_test/test/lints/unsupported_provider_value.dart b/packages/riverpod_lint_flutter_test/test/lints/unsupported_provider_value.dart index 2b09ef0ed..4df784c6d 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/unsupported_provider_value.dart +++ b/packages/riverpod_lint_flutter_test/test/lints/unsupported_provider_value.dart @@ -6,15 +6,15 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'unsupported_provider_value.g.dart'; @riverpod -int integer(IntegerRef ref) => 0; +int integer(Ref ref) => 0; @riverpod // expect_lint: unsupported_provider_value -MyStateNotifier stateNotifier(StateNotifierRef ref) => MyStateNotifier(); +MyStateNotifier stateNotifier(Ref ref) => MyStateNotifier(); @riverpod // expect_lint: unsupported_provider_value -Future asyncStateNotifier(AsyncStateNotifierRef ref) async { +Future asyncStateNotifier(Ref ref) async { return MyStateNotifier(); } @@ -26,8 +26,7 @@ class StateNotifierClass extends _$StateNotifierClass { @riverpod // expect_lint: unsupported_provider_value -Future stateNotifierAsync(StateNotifierAsyncRef ref) async => - MyStateNotifier(); +Future stateNotifierAsync(Ref ref) async => MyStateNotifier(); // Regression tests for https://github.com/rrousselGit/riverpod/issues/2302 @riverpod @@ -59,7 +58,7 @@ class MyStateNotifier extends StateNotifier { @riverpod // expect_lint: unsupported_provider_value -MyChangeNotifier changeNotifier(ChangeNotifierRef ref) => MyChangeNotifier(); +MyChangeNotifier changeNotifier(Ref ref) => MyChangeNotifier(); @riverpod // expect_lint: unsupported_provider_value @@ -71,11 +70,11 @@ class MyChangeNotifier extends ChangeNotifier {} @riverpod // expect_lint: unsupported_provider_value -MyNotifier notifier(NotifierRef ref) => MyNotifier(); +MyNotifier notifier(Ref ref) => MyNotifier(); @riverpod // expect_lint: unsupported_provider_value -MyAutoDisposeNotifier autoDisposeNotifier(AutoDisposeNotifierRef ref) { +MyAutoDisposeNotifier autoDisposeNotifier(Ref ref) { return MyAutoDisposeNotifier(); } @@ -97,7 +96,7 @@ class MyAutoDisposeNotifier extends Notifier { @riverpod // expect_lint: unsupported_provider_value -MyAsyncNotifier asyncNotifier(AsyncNotifierRef ref) => MyAsyncNotifier(); +MyAsyncNotifier asyncNotifier(Ref ref) => MyAsyncNotifier(); @riverpod // expect_lint: unsupported_provider_value @@ -111,32 +110,32 @@ class MyAsyncNotifier extends AsyncNotifier { } @riverpod -Raw rawNotifier(RawNotifierRef ref) => MyChangeNotifier(); +Raw rawNotifier(Ref ref) => MyChangeNotifier(); @riverpod Raw> rawFutureNotifier( - RawFutureNotifierRef ref, + Ref ref, ) async { return MyChangeNotifier(); } @riverpod Raw> rawStreamNotifier( - RawStreamNotifierRef ref, + Ref ref, ) async* { yield MyChangeNotifier(); } @riverpod Future> futureRawNotifier( - FutureRawNotifierRef ref, + Ref ref, ) async { return MyChangeNotifier(); } @riverpod Stream> streamRawNotifier( - StreamRawNotifierRef ref, + Ref ref, ) async* { yield MyChangeNotifier(); } diff --git a/packages/riverpod_lint_flutter_test/test/lints/unsupported_provider_value.g.dart b/packages/riverpod_lint_flutter_test/test/lints/unsupported_provider_value.g.dart index 648dc92a9..dd62d2b38 100644 --- a/packages/riverpod_lint_flutter_test/test/lints/unsupported_provider_value.g.dart +++ b/packages/riverpod_lint_flutter_test/test/lints/unsupported_provider_value.g.dart @@ -6,16 +6,14 @@ part of 'unsupported_provider_value.dart'; // RiverpodGenerator // ************************************************************************** -typedef IntegerRef = Ref; - @ProviderFor(integer) const integerProvider = IntegerProvider._(); final class IntegerProvider extends $FunctionalProvider - with $Provider { + with $Provider { const IntegerProvider._( {int Function( - IntegerRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -29,7 +27,7 @@ final class IntegerProvider extends $FunctionalProvider ); final int Function( - IntegerRef ref, + Ref ref, )? _createCb; @override @@ -51,32 +49,30 @@ final class IntegerProvider extends $FunctionalProvider @override IntegerProvider $copyWithCreate( int Function( - IntegerRef ref, + Ref ref, ) create, ) { return IntegerProvider._(create: create); } @override - int create(IntegerRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? integer; return _$cb(ref); } } -String _$integerHash() => r'a8ce0296e677f64c8b9d1893eed85598c096765e'; - -typedef StateNotifierRef = Ref; +String _$integerHash() => r'8ad63bb35c89ffcf2ef281d7c39539760afff303'; @ProviderFor(stateNotifier) const stateNotifierProvider = StateNotifierProvider._(); final class StateNotifierProvider extends $FunctionalProvider - with $Provider { + with $Provider { const StateNotifierProvider._( {MyStateNotifier Function( - StateNotifierRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -90,7 +86,7 @@ final class StateNotifierProvider ); final MyStateNotifier Function( - StateNotifierRef ref, + Ref ref, )? _createCb; @override @@ -112,34 +108,30 @@ final class StateNotifierProvider @override StateNotifierProvider $copyWithCreate( MyStateNotifier Function( - StateNotifierRef ref, + Ref ref, ) create, ) { return StateNotifierProvider._(create: create); } @override - MyStateNotifier create(StateNotifierRef ref) { + MyStateNotifier create(Ref ref) { final _$cb = _createCb ?? stateNotifier; return _$cb(ref); } } -String _$stateNotifierHash() => r'5d517187bf927e19246ffbcc279d59e15df8ef30'; - -typedef AsyncStateNotifierRef = Ref>; +String _$stateNotifierHash() => r'2505b564fd3a623976548c715b1623dea507f6d3'; @ProviderFor(asyncStateNotifier) const asyncStateNotifierProvider = AsyncStateNotifierProvider._(); final class AsyncStateNotifierProvider extends $FunctionalProvider< AsyncValue, FutureOr> - with - $FutureModifier, - $FutureProvider { + with $FutureModifier, $FutureProvider { const AsyncStateNotifierProvider._( {FutureOr Function( - AsyncStateNotifierRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -153,7 +145,7 @@ final class AsyncStateNotifierProvider extends $FunctionalProvider< ); final FutureOr Function( - AsyncStateNotifierRef ref, + Ref ref, )? _createCb; @override @@ -168,21 +160,21 @@ final class AsyncStateNotifierProvider extends $FunctionalProvider< @override AsyncStateNotifierProvider $copyWithCreate( FutureOr Function( - AsyncStateNotifierRef ref, + Ref ref, ) create, ) { return AsyncStateNotifierProvider._(create: create); } @override - FutureOr create(AsyncStateNotifierRef ref) { + FutureOr create(Ref ref) { final _$cb = _createCb ?? asyncStateNotifier; return _$cb(ref); } } String _$asyncStateNotifierHash() => - r'66442390f13e38cd9594f841a7610ab0f632db81'; + r'5c5954eb030f5688abdf881e047c8893c864b1a2'; @ProviderFor(StateNotifierClass) const stateNotifierClassProvider = StateNotifierClassProvider._(); @@ -231,7 +223,7 @@ final class StateNotifierClassProvider @override StateNotifierClassProvider $copyWithBuild( MyStateNotifier Function( - Ref, + Ref, StateNotifierClass, ) build, ) { @@ -255,19 +247,15 @@ abstract class _$StateNotifierClass extends $Notifier { MyStateNotifier runBuild() => build(); } -typedef StateNotifierAsyncRef = Ref>; - @ProviderFor(stateNotifierAsync) const stateNotifierAsyncProvider = StateNotifierAsyncProvider._(); final class StateNotifierAsyncProvider extends $FunctionalProvider< AsyncValue, FutureOr> - with - $FutureModifier, - $FutureProvider { + with $FutureModifier, $FutureProvider { const StateNotifierAsyncProvider._( {FutureOr Function( - StateNotifierAsyncRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -281,7 +269,7 @@ final class StateNotifierAsyncProvider extends $FunctionalProvider< ); final FutureOr Function( - StateNotifierAsyncRef ref, + Ref ref, )? _createCb; @override @@ -296,21 +284,21 @@ final class StateNotifierAsyncProvider extends $FunctionalProvider< @override StateNotifierAsyncProvider $copyWithCreate( FutureOr Function( - StateNotifierAsyncRef ref, + Ref ref, ) create, ) { return StateNotifierAsyncProvider._(create: create); } @override - FutureOr create(StateNotifierAsyncRef ref) { + FutureOr create(Ref ref) { final _$cb = _createCb ?? stateNotifierAsync; return _$cb(ref); } } String _$stateNotifierAsyncHash() => - r'9a9b1986076dfdfa4490cc109f1bd0f112a7455c'; + r'ce67cf8c6f4bda46835042c17ea01186b5b399a5'; @ProviderFor(SelfNotifier) const selfNotifierProvider = SelfNotifierProvider._(); @@ -351,7 +339,7 @@ final class SelfNotifierProvider @override SelfNotifierProvider $copyWithBuild( FutureOr Function( - Ref>, + Ref, SelfNotifier, ) build, ) { @@ -421,7 +409,7 @@ final class SyncSelfNotifierProvider @override SyncSelfNotifierProvider $copyWithBuild( SyncSelfNotifier Function( - Ref, + Ref, SyncSelfNotifier, ) build, ) { @@ -483,7 +471,7 @@ final class StreamSelfNotifierProvider @override StreamSelfNotifierProvider $copyWithBuild( Stream Function( - Ref>, + Ref, StreamSelfNotifier, ) build, ) { @@ -549,7 +537,7 @@ final class StateNotifierClassAsyncProvider @override StateNotifierClassAsyncProvider $copyWithBuild( FutureOr Function( - Ref>, + Ref, StateNotifierClassAsync, ) build, ) { @@ -574,17 +562,15 @@ abstract class _$StateNotifierClassAsync FutureOr runBuild() => build(); } -typedef ChangeNotifierRef = Ref; - @ProviderFor(changeNotifier) const changeNotifierProvider = ChangeNotifierProvider._(); final class ChangeNotifierProvider extends $FunctionalProvider - with $Provider { + with $Provider { const ChangeNotifierProvider._( {MyChangeNotifier Function( - ChangeNotifierRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -598,7 +584,7 @@ final class ChangeNotifierProvider ); final MyChangeNotifier Function( - ChangeNotifierRef ref, + Ref ref, )? _createCb; @override @@ -620,20 +606,20 @@ final class ChangeNotifierProvider @override ChangeNotifierProvider $copyWithCreate( MyChangeNotifier Function( - ChangeNotifierRef ref, + Ref ref, ) create, ) { return ChangeNotifierProvider._(create: create); } @override - MyChangeNotifier create(ChangeNotifierRef ref) { + MyChangeNotifier create(Ref ref) { final _$cb = _createCb ?? changeNotifier; return _$cb(ref); } } -String _$changeNotifierHash() => r'6325328c129773979364c3cfd628f8f696bbaf66'; +String _$changeNotifierHash() => r'1686043b72e25b3143c5131906924f1393569400'; @ProviderFor(ChangeNotifierClass) const changeNotifierClassProvider = ChangeNotifierClassProvider._(); @@ -682,7 +668,7 @@ final class ChangeNotifierClassProvider @override ChangeNotifierClassProvider $copyWithBuild( MyChangeNotifier Function( - Ref, + Ref, ChangeNotifierClass, ) build, ) { @@ -706,16 +692,14 @@ abstract class _$ChangeNotifierClass extends $Notifier { MyChangeNotifier runBuild() => build(); } -typedef NotifierRef = Ref; - @ProviderFor(notifier) const notifierProvider = NotifierProvider._(); final class NotifierProvider extends $FunctionalProvider - with $Provider { + with $Provider { const NotifierProvider._( {MyNotifier Function( - NotifierRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -729,7 +713,7 @@ final class NotifierProvider extends $FunctionalProvider ); final MyNotifier Function( - NotifierRef ref, + Ref ref, )? _createCb; @override @@ -751,32 +735,30 @@ final class NotifierProvider extends $FunctionalProvider @override NotifierProvider $copyWithCreate( MyNotifier Function( - NotifierRef ref, + Ref ref, ) create, ) { return NotifierProvider._(create: create); } @override - MyNotifier create(NotifierRef ref) { + MyNotifier create(Ref ref) { final _$cb = _createCb ?? notifier; return _$cb(ref); } } -String _$notifierHash() => r'2f323c78400044790faaf61912fc98c6153942f6'; - -typedef AutoDisposeNotifierRef = Ref; +String _$notifierHash() => r'5ad63d9ccd05ab78e7a6ba5c763cacf0b1decb7b'; @ProviderFor(autoDisposeNotifier) const autoDisposeNotifierProvider = AutoDisposeNotifierProvider._(); final class AutoDisposeNotifierProvider extends $FunctionalProvider - with $Provider { + with $Provider { const AutoDisposeNotifierProvider._( {MyAutoDisposeNotifier Function( - AutoDisposeNotifierRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -790,7 +772,7 @@ final class AutoDisposeNotifierProvider ); final MyAutoDisposeNotifier Function( - AutoDisposeNotifierRef ref, + Ref ref, )? _createCb; @override @@ -813,21 +795,21 @@ final class AutoDisposeNotifierProvider @override AutoDisposeNotifierProvider $copyWithCreate( MyAutoDisposeNotifier Function( - AutoDisposeNotifierRef ref, + Ref ref, ) create, ) { return AutoDisposeNotifierProvider._(create: create); } @override - MyAutoDisposeNotifier create(AutoDisposeNotifierRef ref) { + MyAutoDisposeNotifier create(Ref ref) { final _$cb = _createCb ?? autoDisposeNotifier; return _$cb(ref); } } String _$autoDisposeNotifierHash() => - r'620df0fc11c887f01e125454afe8de553cfea6d0'; + r'6aecd9dee1e2734c3acf8eab05145418d10656e1'; @ProviderFor(NotifierClass) const notifierClassProvider = NotifierClassProvider._(); @@ -876,7 +858,7 @@ final class NotifierClassProvider @override NotifierClassProvider $copyWithBuild( MyNotifier Function( - Ref, + Ref, NotifierClass, ) build, ) { @@ -899,17 +881,15 @@ abstract class _$NotifierClass extends $Notifier { MyNotifier runBuild() => build(); } -typedef AsyncNotifierRef = Ref; - @ProviderFor(asyncNotifier) const asyncNotifierProvider = AsyncNotifierProvider._(); final class AsyncNotifierProvider extends $FunctionalProvider - with $Provider { + with $Provider { const AsyncNotifierProvider._( {MyAsyncNotifier Function( - AsyncNotifierRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -923,7 +903,7 @@ final class AsyncNotifierProvider ); final MyAsyncNotifier Function( - AsyncNotifierRef ref, + Ref ref, )? _createCb; @override @@ -945,20 +925,20 @@ final class AsyncNotifierProvider @override AsyncNotifierProvider $copyWithCreate( MyAsyncNotifier Function( - AsyncNotifierRef ref, + Ref ref, ) create, ) { return AsyncNotifierProvider._(create: create); } @override - MyAsyncNotifier create(AsyncNotifierRef ref) { + MyAsyncNotifier create(Ref ref) { final _$cb = _createCb ?? asyncNotifier; return _$cb(ref); } } -String _$asyncNotifierHash() => r'c90348efac71d241468236924f6c6bc80ae0d0e0'; +String _$asyncNotifierHash() => r'8800a97f6bf80a56caf5d968d4b4ab91f7f0a64e'; @ProviderFor(AsyncNotifierClass) const asyncNotifierClassProvider = AsyncNotifierClassProvider._(); @@ -1007,7 +987,7 @@ final class AsyncNotifierClassProvider @override AsyncNotifierClassProvider $copyWithBuild( MyAsyncNotifier Function( - Ref, + Ref, AsyncNotifierClass, ) build, ) { @@ -1031,17 +1011,15 @@ abstract class _$AsyncNotifierClass extends $Notifier { MyAsyncNotifier runBuild() => build(); } -typedef RawNotifierRef = Ref>; - @ProviderFor(rawNotifier) const rawNotifierProvider = RawNotifierProvider._(); final class RawNotifierProvider extends $FunctionalProvider, Raw> - with $Provider, RawNotifierRef> { + with $Provider> { const RawNotifierProvider._( {Raw Function( - RawNotifierRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -1055,7 +1033,7 @@ final class RawNotifierProvider ); final Raw Function( - RawNotifierRef ref, + Ref ref, )? _createCb; @override @@ -1078,32 +1056,30 @@ final class RawNotifierProvider @override RawNotifierProvider $copyWithCreate( Raw Function( - RawNotifierRef ref, + Ref ref, ) create, ) { return RawNotifierProvider._(create: create); } @override - Raw create(RawNotifierRef ref) { + Raw create(Ref ref) { final _$cb = _createCb ?? rawNotifier; return _$cb(ref); } } -String _$rawNotifierHash() => r'c01adc70a8e08258bf5d13024aa8e9b86359a2b2'; - -typedef RawFutureNotifierRef = Ref>>; +String _$rawNotifierHash() => r'c667d10419c9ce1fdd227e2afd1f3aaf63c3380b'; @ProviderFor(rawFutureNotifier) const rawFutureNotifierProvider = RawFutureNotifierProvider._(); final class RawFutureNotifierProvider extends $FunctionalProvider< Raw>, Raw>> - with $Provider>, RawFutureNotifierRef> { + with $Provider>> { const RawFutureNotifierProvider._( {Raw> Function( - RawFutureNotifierRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -1117,7 +1093,7 @@ final class RawFutureNotifierProvider extends $FunctionalProvider< ); final Raw> Function( - RawFutureNotifierRef ref, + Ref ref, )? _createCb; @override @@ -1140,32 +1116,30 @@ final class RawFutureNotifierProvider extends $FunctionalProvider< @override RawFutureNotifierProvider $copyWithCreate( Raw> Function( - RawFutureNotifierRef ref, + Ref ref, ) create, ) { return RawFutureNotifierProvider._(create: create); } @override - Raw> create(RawFutureNotifierRef ref) { + Raw> create(Ref ref) { final _$cb = _createCb ?? rawFutureNotifier; return _$cb(ref); } } -String _$rawFutureNotifierHash() => r'883253dbf7ade868c44b288ec3da02be64dcfb20'; - -typedef RawStreamNotifierRef = Ref>>; +String _$rawFutureNotifierHash() => r'ff2744c369ebd96615f19451eae416d7afeef03f'; @ProviderFor(rawStreamNotifier) const rawStreamNotifierProvider = RawStreamNotifierProvider._(); final class RawStreamNotifierProvider extends $FunctionalProvider< Raw>, Raw>> - with $Provider>, RawStreamNotifierRef> { + with $Provider>> { const RawStreamNotifierProvider._( {Raw> Function( - RawStreamNotifierRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -1179,7 +1153,7 @@ final class RawStreamNotifierProvider extends $FunctionalProvider< ); final Raw> Function( - RawStreamNotifierRef ref, + Ref ref, )? _createCb; @override @@ -1202,22 +1176,20 @@ final class RawStreamNotifierProvider extends $FunctionalProvider< @override RawStreamNotifierProvider $copyWithCreate( Raw> Function( - RawStreamNotifierRef ref, + Ref ref, ) create, ) { return RawStreamNotifierProvider._(create: create); } @override - Raw> create(RawStreamNotifierRef ref) { + Raw> create(Ref ref) { final _$cb = _createCb ?? rawStreamNotifier; return _$cb(ref); } } -String _$rawStreamNotifierHash() => r'f22f6a906e275c6245365bf029e2dc217cf3a301'; - -typedef FutureRawNotifierRef = Ref>>; +String _$rawStreamNotifierHash() => r'9a13efb8fbcef6c4388d5a2535b1b0aec6e46a9a'; @ProviderFor(futureRawNotifier) const futureRawNotifierProvider = FutureRawNotifierProvider._(); @@ -1226,10 +1198,10 @@ final class FutureRawNotifierProvider extends $FunctionalProvider< AsyncValue>, FutureOr>> with $FutureModifier>, - $FutureProvider, FutureRawNotifierRef> { + $FutureProvider> { const FutureRawNotifierProvider._( {FutureOr> Function( - FutureRawNotifierRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -1243,7 +1215,7 @@ final class FutureRawNotifierProvider extends $FunctionalProvider< ); final FutureOr> Function( - FutureRawNotifierRef ref, + Ref ref, )? _createCb; @override @@ -1258,22 +1230,20 @@ final class FutureRawNotifierProvider extends $FunctionalProvider< @override FutureRawNotifierProvider $copyWithCreate( FutureOr> Function( - FutureRawNotifierRef ref, + Ref ref, ) create, ) { return FutureRawNotifierProvider._(create: create); } @override - FutureOr> create(FutureRawNotifierRef ref) { + FutureOr> create(Ref ref) { final _$cb = _createCb ?? futureRawNotifier; return _$cb(ref); } } -String _$futureRawNotifierHash() => r'd70ca757ff2539fc698ff924c135ee5e88a98018'; - -typedef StreamRawNotifierRef = Ref>>; +String _$futureRawNotifierHash() => r'87103845bce1f4cae4ad62ae3b7da6ca3539581f'; @ProviderFor(streamRawNotifier) const streamRawNotifierProvider = StreamRawNotifierProvider._(); @@ -1282,10 +1252,10 @@ final class StreamRawNotifierProvider extends $FunctionalProvider< AsyncValue>, Stream>> with $FutureModifier>, - $StreamProvider, StreamRawNotifierRef> { + $StreamProvider> { const StreamRawNotifierProvider._( {Stream> Function( - StreamRawNotifierRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -1299,7 +1269,7 @@ final class StreamRawNotifierProvider extends $FunctionalProvider< ); final Stream> Function( - StreamRawNotifierRef ref, + Ref ref, )? _createCb; @override @@ -1314,20 +1284,20 @@ final class StreamRawNotifierProvider extends $FunctionalProvider< @override StreamRawNotifierProvider $copyWithCreate( Stream> Function( - StreamRawNotifierRef ref, + Ref ref, ) create, ) { return StreamRawNotifierProvider._(create: create); } @override - Stream> create(StreamRawNotifierRef ref) { + Stream> create(Ref ref) { final _$cb = _createCb ?? streamRawNotifier; return _$cb(ref); } } -String _$streamRawNotifierHash() => r'b1075c37ef3e8a83dfb9a3d469b76bd4855c336f'; +String _$streamRawNotifierHash() => r'1d4abe389b7dfe1381879d8ffb174f6d1d9325e0'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/packages/riverpod_lint_flutter_test/test/test_lint.dart b/packages/riverpod_lint_flutter_test/test/test_lint.dart index feefe45ab..8f89c0da9 100644 --- a/packages/riverpod_lint_flutter_test/test/test_lint.dart +++ b/packages/riverpod_lint_flutter_test/test/test_lint.dart @@ -1,7 +1,10 @@ +import 'dart:convert'; import 'dart:io'; +import 'package:analyzer/source/source_range.dart'; import 'package:analyzer_plugin/protocol/protocol_generated.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:pubspec_parse/pubspec_parse.dart'; import 'package:test/test.dart'; import 'package:path/path.dart'; import 'package:riverpod_lint/src/riverpod_custom_lint.dart'; @@ -48,7 +51,7 @@ void testLint( expect( changes.flattened, matchesPrioritizedSourceChangesGolden( - fixesGoldenPath, + File(fixesGoldenPath), source: result.content, sourcePath: sourcePath.path, ), @@ -59,24 +62,149 @@ void testLint( @isTest void testGolden( String description, - String file, - Future> Function(ResolvedUnitResult) - testRun, { + String goldensFile, + Future> Function( + ResolvedUnitResult, + OffsetHelper helper, + ) body, { required String sourcePath, }) { assert(sourcePath.endsWith('.dart')); test(description, () async { - final absoluteSourcePath = File(normalize(sourcePath)).absolute; - final result = await resolveFile2(path: absoluteSourcePath.path); + final absoluteSource = File(normalize(sourcePath)).absolute; + + final sourceFile = File(sourcePath).absolute; + + final result = await resolveFile2(path: absoluteSource.path); result as ResolvedUnitResult; + final source = sourceFile.readAsStringSync(); + final changes = await body(result, OffsetHelper._(source)).then( + (value) => value.toList(), + ); + expect( - await testRun(result), + await changes, matchesPrioritizedSourceChangesGolden( - file, + File(goldensFile), source: result.content, sourcePath: sourcePath, ), ); }); } + +const _cursor = '<>'; + +class OffsetHelper { + OffsetHelper._(this._content); + + final String _content; + + /// Strings must be code of the format: + /// + /// ``dart + /// Some<>Code + /// ``` + /// + /// where `<>` is the location of the cursor. + /// + /// At least one `<>` must be present, or the function will throw. + Iterable rangesForString(String string) sync* { + final cursors = '<>'.allMatches(string).toList(); + if (cursors.isEmpty) { + throw ArgumentError('String does not contain any cursors: $string'); + } + + final stringWithoutCursors = string.replaceAll(_cursor, ''); + + final start = _content.indexOf(stringWithoutCursors); + if (start == -1) { + throw ArgumentError('String not found in content: $stringWithoutCursors'); + } + + if (_content.indexOf(stringWithoutCursors, start + 1) != -1) { + throw ArgumentError( + 'Found the string twice in the content: $stringWithoutCursors', + ); + } + + for (final (index, cursor) in cursors.indexed) { + // In the case of multiple cursors, we need to adjust the offset + // to account for the previous cursors. + final actualCursorStart = cursor.start - 2 * index; + yield SourceRange(start + actualCursorStart, 0); + } + } + + Future> runAssist( + RiverpodAssist assist, + ResolvedUnitResult result, + Iterable cursorRanges, { + Pubspec? pubspec, + }) async { + return Future.wait( + cursorRanges.map( + (range) => assist.testRun(result, range, pubspec: pubspec), + ), + ).then((value) => value.expand((e) => e)); + } + + void debugOffset(List offsets) { + offsets.sort(); + + var mappedContent = _content; + for (final offset in offsets.reversed) { + mappedContent = mappedContent.substring(0, offset) + + '<>' + + mappedContent.substring(offset); + } + + final lines = LineSplitter.split(mappedContent).toList(); + + final codes = []; + + StringBuffer? buffer; + + void openBuffer() { + buffer ??= StringBuffer("helper.rangesForString('''\n"); + } + + void closeBuffer() { + if (buffer == null) return; + + buffer!.write("''')"); + codes.add(buffer.toString()); + buffer = null; + } + + // Print all lines with <> in them and one line before and after. + for (final (index, line) in lines.indexed) { + if (buffer == null && line.trim().isEmpty) continue; + + final hasCursor = line.contains(_cursor); + late final hadCursor = index >= 1 && lines[index - 1].contains(_cursor); + late final willHaveCursor = + index + 1 < lines.length && lines[index + 1].contains(_cursor); + + if (hasCursor || hadCursor || willHaveCursor) { + openBuffer(); + buffer!.writeln(line); + } else { + closeBuffer(); + } + } + + if (buffer != null) closeBuffer(); + + if (codes.length == 1) { + print(' final cursors = ${codes.single};'); + } else { + print(' final cursors = ['); + for (final code in codes) { + print(' ...$code,'); + } + print(' ];'); + } + } +} diff --git a/tools/generate_providers/bin/generate_providers.dart b/tools/generate_providers/bin/generate_providers.dart index d4b524d06..e374260d0 100644 --- a/tools/generate_providers/bin/generate_providers.dart +++ b/tools/generate_providers/bin/generate_providers.dart @@ -39,11 +39,9 @@ class _FunctionalBuilder extends _Builder { required super.genericsDefinition, required super.genericsUsage, required this.createdT, - required this.refT, }); final String createdT; - final String refT; } class _NotifierBuilder extends _Builder { @@ -95,7 +93,6 @@ Future main(List args) async { genericsUsage: 'StateT', genericsDefinition: 'StateT', createdT: 'StateT', - refT: 'Ref', ), _FunctionalBuilder( 'StateNotifierProvider', @@ -103,28 +100,24 @@ Future main(List args) async { genericsDefinition: 'NotifierT extends StateNotifier, StateT', createdT: 'NotifierT', - refT: 'Ref', ), _FunctionalBuilder( 'Provider', genericsUsage: 'StateT', genericsDefinition: 'StateT', createdT: 'StateT', - refT: 'Ref', ), _FunctionalBuilder( 'FutureProvider', genericsUsage: 'StateT', genericsDefinition: 'StateT', createdT: 'FutureOr', - refT: 'Ref>', ), _FunctionalBuilder( 'StreamProvider', genericsUsage: 'StateT', genericsDefinition: 'StateT', createdT: 'Stream', - refT: 'Ref>', ), _NotifierBuilder( 'NotifierProvider', @@ -190,7 +183,6 @@ import 'internals.dart'; genericsUsage: 'NotifierT', genericsDefinition: 'NotifierT extends ChangeNotifier?', createdT: 'NotifierT', - refT: 'Ref', ), ], kinds: _ProviderKind.values, @@ -260,7 +252,7 @@ class $builderName { $familyDoc ${provider.providerName}Family<${provider.genericsUsage}, ArgT> call<${provider.genericsDefinition}, ArgT>( - ${provider.createdT} Function(${provider.refT} ref, ArgT param) create, { + ${provider.createdT} Function(Ref ref, ArgT param) create, { String? name, Iterable? dependencies, Retry? retry, @@ -296,7 +288,7 @@ class $builderName { $familyDoc ${provider.providerName}<${provider.genericsUsage}> call<${provider.genericsDefinition}>( - ${provider.createdT} Function(${provider.refT} ref) create, { + ${provider.createdT} Function(Ref ref) create, { String? name, Iterable? dependencies, Retry? retry, diff --git a/website/docs/advanced/select/select/codegen.dart b/website/docs/advanced/select/select/codegen.dart index 67f529215..fce0f19a3 100644 --- a/website/docs/advanced/select/select/codegen.dart +++ b/website/docs/advanced/select/select/codegen.dart @@ -12,7 +12,7 @@ class User { } @riverpod -User example(ExampleRef ref) => User() +User example(Ref ref) => User() ..firstName = 'John' ..lastName = 'Doe'; diff --git a/website/docs/advanced/select/select/codegen.g.dart b/website/docs/advanced/select/select/codegen.g.dart index 2d51a144c..0aaaa5a94 100644 --- a/website/docs/advanced/select/select/codegen.g.dart +++ b/website/docs/advanced/select/select/codegen.g.dart @@ -8,16 +8,14 @@ part of 'codegen.dart'; // RiverpodGenerator // ************************************************************************** -typedef ExampleRef = Ref; - @ProviderFor(example) const exampleProvider = ExampleProvider._(); final class ExampleProvider extends $FunctionalProvider - with $Provider { + with $Provider { const ExampleProvider._( {User Function( - ExampleRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -31,7 +29,7 @@ final class ExampleProvider extends $FunctionalProvider ); final User Function( - ExampleRef ref, + Ref ref, )? _createCb; @override @@ -53,20 +51,20 @@ final class ExampleProvider extends $FunctionalProvider @override ExampleProvider $copyWithCreate( User Function( - ExampleRef ref, + Ref ref, ) create, ) { return ExampleProvider._(create: create); } @override - User create(ExampleRef ref) { + User create(Ref ref) { final _$cb = _createCb ?? example; return _$cb(ref); } } -String _$exampleHash() => r'72881c6147d44adb957180debefe7696d93107f0'; +String _$exampleHash() => r'c9865d4390aad5b8480addcbb73dbd225c8417b8'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/advanced/select/select_async/codegen.dart b/website/docs/advanced/select/select_async/codegen.dart index 60b6285e5..9ddf7256b 100644 --- a/website/docs/advanced/select/select_async/codegen.dart +++ b/website/docs/advanced/select/select_async/codegen.dart @@ -9,7 +9,7 @@ class User { } @riverpod -FutureOr user(UserRef ref) { +FutureOr user(Ref ref) { return User() ..firstName = 'John' ..lastName = 'Doe'; @@ -17,7 +17,7 @@ FutureOr user(UserRef ref) { /* SNIPPET START */ @riverpod -Object? example(ExampleRef ref) async { +Object? example(Ref ref) async { // {@template watch} // Wait for a user to be available, and listen to only the "firstName" property // {@endtemplate} diff --git a/website/docs/advanced/select/select_async/codegen.g.dart b/website/docs/advanced/select/select_async/codegen.g.dart index e1f780f62..c53201dae 100644 --- a/website/docs/advanced/select/select_async/codegen.g.dart +++ b/website/docs/advanced/select/select_async/codegen.g.dart @@ -8,17 +8,15 @@ part of 'codegen.dart'; // RiverpodGenerator // ************************************************************************** -typedef UserRef = Ref>; - @ProviderFor(user) const userProvider = UserProvider._(); final class UserProvider extends $FunctionalProvider, FutureOr> - with $FutureModifier, $FutureProvider { + with $FutureModifier, $FutureProvider { const UserProvider._( {FutureOr Function( - UserRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -32,7 +30,7 @@ final class UserProvider ); final FutureOr Function( - UserRef ref, + Ref ref, )? _createCb; @override @@ -46,31 +44,29 @@ final class UserProvider @override UserProvider $copyWithCreate( FutureOr Function( - UserRef ref, + Ref ref, ) create, ) { return UserProvider._(create: create); } @override - FutureOr create(UserRef ref) { + FutureOr create(Ref ref) { final _$cb = _createCb ?? user; return _$cb(ref); } } -String _$userHash() => r'19a4464690c31301e47fd7bd5bf6ea475c1a73eb'; - -typedef ExampleRef = Ref; +String _$userHash() => r'b83ca110a6fae2341d1bfca73fb3d89c4d12723d'; @ProviderFor(example) const exampleProvider = ExampleProvider._(); final class ExampleProvider extends $FunctionalProvider - with $Provider { + with $Provider { const ExampleProvider._( {Object? Function( - ExampleRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -84,7 +80,7 @@ final class ExampleProvider extends $FunctionalProvider ); final Object? Function( - ExampleRef ref, + Ref ref, )? _createCb; @override @@ -106,20 +102,20 @@ final class ExampleProvider extends $FunctionalProvider @override ExampleProvider $copyWithCreate( Object? Function( - ExampleRef ref, + Ref ref, ) create, ) { return ExampleProvider._(create: create); } @override - Object? create(ExampleRef ref) { + Object? create(Ref ref) { final _$cb = _createCb ?? example; return _$cb(ref); } } -String _$exampleHash() => r'1fccbdbec0e3585bc9d3a5709ac88a8919dd78fa'; +String _$exampleHash() => r'05abb7bf29fe43807cb1a31a17eb23c821529a69'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/case_studies/cancel/detail_screen/codegen.dart b/website/docs/case_studies/cancel/detail_screen/codegen.dart index 1941e884c..7a47d834a 100644 --- a/website/docs/case_studies/cancel/detail_screen/codegen.dart +++ b/website/docs/case_studies/cancel/detail_screen/codegen.dart @@ -24,7 +24,7 @@ class Activity with _$Activity { } @riverpod -Future activity(ActivityRef ref) async { +Future activity(Ref ref) async { final response = await http.get( Uri.https('www.boredapi.com', '/api/activity'), ); diff --git a/website/docs/case_studies/cancel/detail_screen/codegen.g.dart b/website/docs/case_studies/cancel/detail_screen/codegen.g.dart index 127c57c1a..30cf3b400 100644 --- a/website/docs/case_studies/cancel/detail_screen/codegen.g.dart +++ b/website/docs/case_studies/cancel/detail_screen/codegen.g.dart @@ -28,17 +28,15 @@ Map _$$ActivityImplToJson(_$ActivityImpl instance) => // RiverpodGenerator // ************************************************************************** -typedef ActivityRef = Ref>; - @ProviderFor(activity) const activityProvider = ActivityProvider._(); final class ActivityProvider extends $FunctionalProvider, FutureOr> - with $FutureModifier, $FutureProvider { + with $FutureModifier, $FutureProvider { const ActivityProvider._( {FutureOr Function( - ActivityRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -52,7 +50,7 @@ final class ActivityProvider ); final FutureOr Function( - ActivityRef ref, + Ref ref, )? _createCb; @override @@ -66,20 +64,20 @@ final class ActivityProvider @override ActivityProvider $copyWithCreate( FutureOr Function( - ActivityRef ref, + Ref ref, ) create, ) { return ActivityProvider._(create: create); } @override - FutureOr create(ActivityRef ref) { + FutureOr create(Ref ref) { final _$cb = _createCb ?? activity; return _$cb(ref); } } -String _$activityHash() => r'c73d0af18bcf7072f6a5a913b0b272649fb99a81'; +String _$activityHash() => r'609ac1c1d8008d8109ea5869c7aa88013032917c'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/case_studies/cancel/detail_screen_cancel/codegen.dart b/website/docs/case_studies/cancel/detail_screen_cancel/codegen.dart index d88aa6b16..8094b9996 100644 --- a/website/docs/case_studies/cancel/detail_screen_cancel/codegen.dart +++ b/website/docs/case_studies/cancel/detail_screen_cancel/codegen.dart @@ -9,7 +9,7 @@ part 'codegen.g.dart'; /* SNIPPET START */ @riverpod -Future activity(ActivityRef ref) async { +Future activity(Ref ref) async { // {@template client} // We create an HTTP client using package:http // {@endtemplate} diff --git a/website/docs/case_studies/cancel/detail_screen_cancel/codegen.g.dart b/website/docs/case_studies/cancel/detail_screen_cancel/codegen.g.dart index 46529fa89..d5d5e9bdc 100644 --- a/website/docs/case_studies/cancel/detail_screen_cancel/codegen.g.dart +++ b/website/docs/case_studies/cancel/detail_screen_cancel/codegen.g.dart @@ -8,17 +8,15 @@ part of 'codegen.dart'; // RiverpodGenerator // ************************************************************************** -typedef ActivityRef = Ref>; - @ProviderFor(activity) const activityProvider = ActivityProvider._(); final class ActivityProvider extends $FunctionalProvider, FutureOr> - with $FutureModifier, $FutureProvider { + with $FutureModifier, $FutureProvider { const ActivityProvider._( {FutureOr Function( - ActivityRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -32,7 +30,7 @@ final class ActivityProvider ); final FutureOr Function( - ActivityRef ref, + Ref ref, )? _createCb; @override @@ -46,20 +44,20 @@ final class ActivityProvider @override ActivityProvider $copyWithCreate( FutureOr Function( - ActivityRef ref, + Ref ref, ) create, ) { return ActivityProvider._(create: create); } @override - FutureOr create(ActivityRef ref) { + FutureOr create(Ref ref) { final _$cb = _createCb ?? activity; return _$cb(ref); } } -String _$activityHash() => r'304864a6b8051925061a2bba397574ec45b94d08'; +String _$activityHash() => r'ac82ab2c8ff5c059f8f9abebed0a5c1fb6dc66c8'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/case_studies/cancel/detail_screen_debounce/codegen.dart b/website/docs/case_studies/cancel/detail_screen_debounce/codegen.dart index f93cba60c..732f8e134 100644 --- a/website/docs/case_studies/cancel/detail_screen_debounce/codegen.dart +++ b/website/docs/case_studies/cancel/detail_screen_debounce/codegen.dart @@ -9,7 +9,7 @@ part 'codegen.g.dart'; /* SNIPPET START */ @riverpod -Future activity(ActivityRef ref) async { +Future activity(Ref ref) async { // {@template didDispose} // We capture whether the provider is currently disposed or not. // {@endtemplate} diff --git a/website/docs/case_studies/cancel/detail_screen_debounce/codegen.g.dart b/website/docs/case_studies/cancel/detail_screen_debounce/codegen.g.dart index 5c8f2d5bf..5599a976f 100644 --- a/website/docs/case_studies/cancel/detail_screen_debounce/codegen.g.dart +++ b/website/docs/case_studies/cancel/detail_screen_debounce/codegen.g.dart @@ -8,17 +8,15 @@ part of 'codegen.dart'; // RiverpodGenerator // ************************************************************************** -typedef ActivityRef = Ref>; - @ProviderFor(activity) const activityProvider = ActivityProvider._(); final class ActivityProvider extends $FunctionalProvider, FutureOr> - with $FutureModifier, $FutureProvider { + with $FutureModifier, $FutureProvider { const ActivityProvider._( {FutureOr Function( - ActivityRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -32,7 +30,7 @@ final class ActivityProvider ); final FutureOr Function( - ActivityRef ref, + Ref ref, )? _createCb; @override @@ -46,20 +44,20 @@ final class ActivityProvider @override ActivityProvider $copyWithCreate( FutureOr Function( - ActivityRef ref, + Ref ref, ) create, ) { return ActivityProvider._(create: create); } @override - FutureOr create(ActivityRef ref) { + FutureOr create(Ref ref) { final _$cb = _createCb ?? activity; return _$cb(ref); } } -String _$activityHash() => r'ef908e3b46693862f082769663b14d5369d6e155'; +String _$activityHash() => r'dd7d10807315da17e775b99e8e03f5d9634fc822'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/case_studies/cancel/extension.dart b/website/docs/case_studies/cancel/extension.dart index d6e34982d..162f777fa 100644 --- a/website/docs/case_studies/cancel/extension.dart +++ b/website/docs/case_studies/cancel/extension.dart @@ -2,7 +2,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:http/http.dart' as http; /* SNIPPET START */ -extension DebounceAndCancelExtension on Ref { +extension DebounceAndCancelExtension on Ref { // {@template note} /// Wait for [duration] (defaults to 500ms), and then return a [http.Client] /// which can be used to make a request. diff --git a/website/docs/case_studies/cancel/provider_with_extension/codegen.dart b/website/docs/case_studies/cancel/provider_with_extension/codegen.dart index 5bd3ccfca..e3663c7a0 100644 --- a/website/docs/case_studies/cancel/provider_with_extension/codegen.dart +++ b/website/docs/case_studies/cancel/provider_with_extension/codegen.dart @@ -9,7 +9,7 @@ part 'codegen.g.dart'; /* SNIPPET START */ @riverpod -Future activity(ActivityRef ref) async { +Future activity(Ref ref) async { // {@template client} // We obtain an HTTP client using the extension we created earlier. // {@endtemplate} diff --git a/website/docs/case_studies/cancel/provider_with_extension/codegen.g.dart b/website/docs/case_studies/cancel/provider_with_extension/codegen.g.dart index c3bd25059..bfc06dfd6 100644 --- a/website/docs/case_studies/cancel/provider_with_extension/codegen.g.dart +++ b/website/docs/case_studies/cancel/provider_with_extension/codegen.g.dart @@ -8,17 +8,15 @@ part of 'codegen.dart'; // RiverpodGenerator // ************************************************************************** -typedef ActivityRef = Ref>; - @ProviderFor(activity) const activityProvider = ActivityProvider._(); final class ActivityProvider extends $FunctionalProvider, FutureOr> - with $FutureModifier, $FutureProvider { + with $FutureModifier, $FutureProvider { const ActivityProvider._( {FutureOr Function( - ActivityRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -32,7 +30,7 @@ final class ActivityProvider ); final FutureOr Function( - ActivityRef ref, + Ref ref, )? _createCb; @override @@ -46,20 +44,20 @@ final class ActivityProvider @override ActivityProvider $copyWithCreate( FutureOr Function( - ActivityRef ref, + Ref ref, ) create, ) { return ActivityProvider._(create: create); } @override - FutureOr create(ActivityRef ref) { + FutureOr create(Ref ref) { final _$cb = _createCb ?? activity; return _$cb(ref); } } -String _$activityHash() => r'f045dd6e89fde6bbe12a89f243290d289a3e692d'; +String _$activityHash() => r'c1d2d6dca725a8b75b31c73630a5641dba0bec2b'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/case_studies/pull_to_refresh/fetch_activity/codegen.dart b/website/docs/case_studies/pull_to_refresh/fetch_activity/codegen.dart index 0cec67cba..16ac99207 100644 --- a/website/docs/case_studies/pull_to_refresh/fetch_activity/codegen.dart +++ b/website/docs/case_studies/pull_to_refresh/fetch_activity/codegen.dart @@ -9,7 +9,7 @@ part 'codegen.g.dart'; /* SNIPPET START */ @riverpod -Future activity(ActivityRef ref) async { +Future activity(Ref ref) async { final response = await http.get( Uri.https('www.boredapi.com', '/api/activity'), ); diff --git a/website/docs/case_studies/pull_to_refresh/fetch_activity/codegen.g.dart b/website/docs/case_studies/pull_to_refresh/fetch_activity/codegen.g.dart index df778ce92..ce5bea251 100644 --- a/website/docs/case_studies/pull_to_refresh/fetch_activity/codegen.g.dart +++ b/website/docs/case_studies/pull_to_refresh/fetch_activity/codegen.g.dart @@ -8,17 +8,15 @@ part of 'codegen.dart'; // RiverpodGenerator // ************************************************************************** -typedef ActivityRef = Ref>; - @ProviderFor(activity) const activityProvider = ActivityProvider._(); final class ActivityProvider extends $FunctionalProvider, FutureOr> - with $FutureModifier, $FutureProvider { + with $FutureModifier, $FutureProvider { const ActivityProvider._( {FutureOr Function( - ActivityRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -32,7 +30,7 @@ final class ActivityProvider ); final FutureOr Function( - ActivityRef ref, + Ref ref, )? _createCb; @override @@ -46,20 +44,20 @@ final class ActivityProvider @override ActivityProvider $copyWithCreate( FutureOr Function( - ActivityRef ref, + Ref ref, ) create, ) { return ActivityProvider._(create: create); } @override - FutureOr create(ActivityRef ref) { + FutureOr create(Ref ref) { final _$cb = _createCb ?? activity; return _$cb(ref); } } -String _$activityHash() => r'c73d0af18bcf7072f6a5a913b0b272649fb99a81'; +String _$activityHash() => r'609ac1c1d8008d8109ea5869c7aa88013032917c'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/case_studies/pull_to_refresh/full_app/codegen.dart b/website/docs/case_studies/pull_to_refresh/full_app/codegen.dart index 837a4b2d7..865e30cc7 100644 --- a/website/docs/case_studies/pull_to_refresh/full_app/codegen.dart +++ b/website/docs/case_studies/pull_to_refresh/full_app/codegen.dart @@ -45,7 +45,7 @@ class ActivityView extends ConsumerWidget { } @riverpod -Future activity(ActivityRef ref) async { +Future activity(Ref ref) async { final response = await http.get( Uri.https('www.boredapi.com', '/api/activity'), ); diff --git a/website/docs/case_studies/pull_to_refresh/full_app/codegen.g.dart b/website/docs/case_studies/pull_to_refresh/full_app/codegen.g.dart index 127c57c1a..30cf3b400 100644 --- a/website/docs/case_studies/pull_to_refresh/full_app/codegen.g.dart +++ b/website/docs/case_studies/pull_to_refresh/full_app/codegen.g.dart @@ -28,17 +28,15 @@ Map _$$ActivityImplToJson(_$ActivityImpl instance) => // RiverpodGenerator // ************************************************************************** -typedef ActivityRef = Ref>; - @ProviderFor(activity) const activityProvider = ActivityProvider._(); final class ActivityProvider extends $FunctionalProvider, FutureOr> - with $FutureModifier, $FutureProvider { + with $FutureModifier, $FutureProvider { const ActivityProvider._( {FutureOr Function( - ActivityRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -52,7 +50,7 @@ final class ActivityProvider ); final FutureOr Function( - ActivityRef ref, + Ref ref, )? _createCb; @override @@ -66,20 +64,20 @@ final class ActivityProvider @override ActivityProvider $copyWithCreate( FutureOr Function( - ActivityRef ref, + Ref ref, ) create, ) { return ActivityProvider._(create: create); } @override - FutureOr create(ActivityRef ref) { + FutureOr create(Ref ref) { final _$cb = _createCb ?? activity; return _$cb(ref); } } -String _$activityHash() => r'c73d0af18bcf7072f6a5a913b0b272649fb99a81'; +String _$activityHash() => r'609ac1c1d8008d8109ea5869c7aa88013032917c'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/concepts/about_codegen/main.dart b/website/docs/concepts/about_codegen/main.dart index 1ccb42807..6dbbf14aa 100644 --- a/website/docs/concepts/about_codegen/main.dart +++ b/website/docs/concepts/about_codegen/main.dart @@ -16,7 +16,7 @@ final http = Http(); /* SNIPPET START */ @riverpod -Future fetchUser(FetchUserRef ref, {required int userId}) async { +Future fetchUser(Ref ref, {required int userId}) async { final json = await http.get('api/user/$userId'); return User.fromJson(json); } diff --git a/website/docs/concepts/about_codegen/main.g.dart b/website/docs/concepts/about_codegen/main.g.dart index 35ce3eec9..889d75b37 100644 --- a/website/docs/concepts/about_codegen/main.g.dart +++ b/website/docs/concepts/about_codegen/main.g.dart @@ -8,19 +8,17 @@ part of 'main.dart'; // RiverpodGenerator // ************************************************************************** -typedef FetchUserRef = Ref>; - @ProviderFor(fetchUser) const fetchUserProvider = FetchUserFamily._(); final class FetchUserProvider extends $FunctionalProvider, FutureOr> - with $FutureModifier, $FutureProvider { + with $FutureModifier, $FutureProvider { const FetchUserProvider._( {required FetchUserFamily super.from, required int super.argument, FutureOr Function( - FetchUserRef ref, { + Ref ref, { required int userId, })? create}) : _createCb = create, @@ -33,7 +31,7 @@ final class FetchUserProvider ); final FutureOr Function( - FetchUserRef ref, { + Ref ref, { required int userId, })? _createCb; @@ -55,7 +53,7 @@ final class FetchUserProvider @override FetchUserProvider $copyWithCreate( FutureOr Function( - FetchUserRef ref, + Ref ref, ) create, ) { return FetchUserProvider._( @@ -69,7 +67,7 @@ final class FetchUserProvider } @override - FutureOr create(FetchUserRef ref) { + FutureOr create(Ref ref) { final _$cb = _createCb ?? fetchUser; final argument = this.argument as int; return _$cb( @@ -89,7 +87,7 @@ final class FetchUserProvider } } -String _$fetchUserHash() => r'ff427bbb4130a8a6994fa623ae70997f7b0f6bdb'; +String _$fetchUserHash() => r'0ea61464a124f8af2cf15b830a1a012d4272eb47'; final class FetchUserFamily extends Family { const FetchUserFamily._() @@ -115,7 +113,7 @@ final class FetchUserFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( FutureOr Function( - FetchUserRef ref, + Ref ref, int args, ) create, ) { @@ -134,4 +132,4 @@ final class FetchUserFamily extends Family { } } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/concepts/about_codegen/provider_type/async_class_future.g.dart b/website/docs/concepts/about_codegen/provider_type/async_class_future.g.dart index dacbd45bb..52014d865 100644 --- a/website/docs/concepts/about_codegen/provider_type/async_class_future.g.dart +++ b/website/docs/concepts/about_codegen/provider_type/async_class_future.g.dart @@ -46,7 +46,7 @@ final class ExampleProvider extends $AsyncNotifierProvider { @override ExampleProvider $copyWithBuild( FutureOr Function( - Ref>, + Ref, Example, ) build, ) { @@ -70,4 +70,4 @@ abstract class _$Example extends $AsyncNotifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/concepts/about_codegen/provider_type/async_class_stream.g.dart b/website/docs/concepts/about_codegen/provider_type/async_class_stream.g.dart index 9e044bab2..382965278 100644 --- a/website/docs/concepts/about_codegen/provider_type/async_class_stream.g.dart +++ b/website/docs/concepts/about_codegen/provider_type/async_class_stream.g.dart @@ -46,7 +46,7 @@ final class ExampleProvider extends $StreamNotifierProvider { @override ExampleProvider $copyWithBuild( Stream Function( - Ref>, + Ref, Example, ) build, ) { @@ -70,4 +70,4 @@ abstract class _$Example extends $StreamNotifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/concepts/about_codegen/provider_type/async_fn_future.dart b/website/docs/concepts/about_codegen/provider_type/async_fn_future.dart index 95fdd909c..7ab60af7c 100644 --- a/website/docs/concepts/about_codegen/provider_type/async_fn_future.dart +++ b/website/docs/concepts/about_codegen/provider_type/async_fn_future.dart @@ -4,6 +4,6 @@ part 'async_fn_future.g.dart'; /* SNIPPET START */ @riverpod -Future example(ExampleRef ref) async { +Future example(Ref ref) async { return Future.value('foo'); } diff --git a/website/docs/concepts/about_codegen/provider_type/async_fn_future.g.dart b/website/docs/concepts/about_codegen/provider_type/async_fn_future.g.dart index 45170ea57..779c98093 100644 --- a/website/docs/concepts/about_codegen/provider_type/async_fn_future.g.dart +++ b/website/docs/concepts/about_codegen/provider_type/async_fn_future.g.dart @@ -8,17 +8,15 @@ part of 'async_fn_future.dart'; // RiverpodGenerator // ************************************************************************** -typedef ExampleRef = Ref>; - @ProviderFor(example) const exampleProvider = ExampleProvider._(); final class ExampleProvider extends $FunctionalProvider, FutureOr> - with $FutureModifier, $FutureProvider { + with $FutureModifier, $FutureProvider { const ExampleProvider._( {FutureOr Function( - ExampleRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -32,7 +30,7 @@ final class ExampleProvider ); final FutureOr Function( - ExampleRef ref, + Ref ref, )? _createCb; @override @@ -46,20 +44,20 @@ final class ExampleProvider @override ExampleProvider $copyWithCreate( FutureOr Function( - ExampleRef ref, + Ref ref, ) create, ) { return ExampleProvider._(create: create); } @override - FutureOr create(ExampleRef ref) { + FutureOr create(Ref ref) { final _$cb = _createCb ?? example; return _$cb(ref); } } -String _$exampleHash() => r'e620af6b870a76eea4228989433de0666957d813'; +String _$exampleHash() => r'24ba6aa120f9e40b3796d5429f7723b82f8f0970'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/concepts/about_codegen/provider_type/async_fn_stream.dart b/website/docs/concepts/about_codegen/provider_type/async_fn_stream.dart index 74da790ad..43b3a877f 100644 --- a/website/docs/concepts/about_codegen/provider_type/async_fn_stream.dart +++ b/website/docs/concepts/about_codegen/provider_type/async_fn_stream.dart @@ -4,6 +4,6 @@ part 'async_fn_stream.g.dart'; /* SNIPPET START */ @riverpod -Stream example(ExampleRef ref) async* { +Stream example(Ref ref) async* { yield 'foo'; } diff --git a/website/docs/concepts/about_codegen/provider_type/async_fn_stream.g.dart b/website/docs/concepts/about_codegen/provider_type/async_fn_stream.g.dart index d565bb46f..f743c75ef 100644 --- a/website/docs/concepts/about_codegen/provider_type/async_fn_stream.g.dart +++ b/website/docs/concepts/about_codegen/provider_type/async_fn_stream.g.dart @@ -8,17 +8,15 @@ part of 'async_fn_stream.dart'; // RiverpodGenerator // ************************************************************************** -typedef ExampleRef = Ref>; - @ProviderFor(example) const exampleProvider = ExampleProvider._(); final class ExampleProvider extends $FunctionalProvider, Stream> - with $FutureModifier, $StreamProvider { + with $FutureModifier, $StreamProvider { const ExampleProvider._( {Stream Function( - ExampleRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -32,7 +30,7 @@ final class ExampleProvider ); final Stream Function( - ExampleRef ref, + Ref ref, )? _createCb; @override @@ -46,20 +44,20 @@ final class ExampleProvider @override ExampleProvider $copyWithCreate( Stream Function( - ExampleRef ref, + Ref ref, ) create, ) { return ExampleProvider._(create: create); } @override - Stream create(ExampleRef ref) { + Stream create(Ref ref) { final _$cb = _createCb ?? example; return _$cb(ref); } } -String _$exampleHash() => r'8a2b19776fb9bbb1631f898bd6446b57b102dd9d'; +String _$exampleHash() => r'f7f90ac5fbf939c0259a549b8e01a559b0d95ff1'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/concepts/about_codegen/provider_type/auto_dispose.dart b/website/docs/concepts/about_codegen/provider_type/auto_dispose.dart index 0c714c702..3351a2da9 100644 --- a/website/docs/concepts/about_codegen/provider_type/auto_dispose.dart +++ b/website/docs/concepts/about_codegen/provider_type/auto_dispose.dart @@ -5,8 +5,8 @@ part 'auto_dispose.g.dart'; /* SNIPPET START */ // AutoDispose provider (keepAlive is false by default) @riverpod -String example1(Example1Ref ref) => 'foo'; +String example1(Ref ref) => 'foo'; // Non autoDispose provider @Riverpod(keepAlive: true) -String example2(Example2Ref ref) => 'foo'; +String example2(Ref ref) => 'foo'; diff --git a/website/docs/concepts/about_codegen/provider_type/auto_dispose.g.dart b/website/docs/concepts/about_codegen/provider_type/auto_dispose.g.dart index 41638f78b..9abfc469c 100644 --- a/website/docs/concepts/about_codegen/provider_type/auto_dispose.g.dart +++ b/website/docs/concepts/about_codegen/provider_type/auto_dispose.g.dart @@ -8,16 +8,14 @@ part of 'auto_dispose.dart'; // RiverpodGenerator // ************************************************************************** -typedef Example1Ref = Ref; - @ProviderFor(example1) const example1Provider = Example1Provider._(); final class Example1Provider extends $FunctionalProvider - with $Provider { + with $Provider { const Example1Provider._( {String Function( - Example1Ref ref, + Ref ref, )? create}) : _createCb = create, super( @@ -31,7 +29,7 @@ final class Example1Provider extends $FunctionalProvider ); final String Function( - Example1Ref ref, + Ref ref, )? _createCb; @override @@ -53,31 +51,29 @@ final class Example1Provider extends $FunctionalProvider @override Example1Provider $copyWithCreate( String Function( - Example1Ref ref, + Ref ref, ) create, ) { return Example1Provider._(create: create); } @override - String create(Example1Ref ref) { + String create(Ref ref) { final _$cb = _createCb ?? example1; return _$cb(ref); } } -String _$example1Hash() => r'8a5f0865f758792cc8e4f2ca67db334196df6e88'; - -typedef Example2Ref = Ref; +String _$example1Hash() => r'6a361ee6f9dd1d0cdbb42f967f6356aa058f7041'; @ProviderFor(example2) const example2Provider = Example2Provider._(); final class Example2Provider extends $FunctionalProvider - with $Provider { + with $Provider { const Example2Provider._( {String Function( - Example2Ref ref, + Ref ref, )? create}) : _createCb = create, super( @@ -91,7 +87,7 @@ final class Example2Provider extends $FunctionalProvider ); final String Function( - Example2Ref ref, + Ref ref, )? _createCb; @override @@ -113,20 +109,20 @@ final class Example2Provider extends $FunctionalProvider @override Example2Provider $copyWithCreate( String Function( - Example2Ref ref, + Ref ref, ) create, ) { return Example2Provider._(create: create); } @override - String create(Example2Ref ref) { + String create(Ref ref) { final _$cb = _createCb ?? example2; return _$cb(ref); } } -String _$example2Hash() => r'bc25731d759be185125d12d995d0b89b07d1e271'; +String _$example2Hash() => r'181b89435c06a7284a8978c5ab9f13bb4a3693b0'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/concepts/about_codegen/provider_type/family.dart b/website/docs/concepts/about_codegen/provider_type/family.dart index e1ee685fb..d4a88c306 100644 --- a/website/docs/concepts/about_codegen/provider_type/family.dart +++ b/website/docs/concepts/about_codegen/provider_type/family.dart @@ -4,4 +4,4 @@ part 'family.g.dart'; /* SNIPPET START */ @riverpod -String example(ExampleRef ref, int param) => 'Hello $param'; +String example(Ref ref, int param) => 'Hello $param'; diff --git a/website/docs/concepts/about_codegen/provider_type/family.g.dart b/website/docs/concepts/about_codegen/provider_type/family.g.dart index 37d1cc09d..703faf3b7 100644 --- a/website/docs/concepts/about_codegen/provider_type/family.g.dart +++ b/website/docs/concepts/about_codegen/provider_type/family.g.dart @@ -8,18 +8,16 @@ part of 'family.dart'; // RiverpodGenerator // ************************************************************************** -typedef ExampleRef = Ref; - @ProviderFor(example) const exampleProvider = ExampleFamily._(); final class ExampleProvider extends $FunctionalProvider - with $Provider { + with $Provider { const ExampleProvider._( {required ExampleFamily super.from, required int super.argument, String Function( - ExampleRef ref, + Ref ref, int param, )? create}) : _createCb = create, @@ -32,7 +30,7 @@ final class ExampleProvider extends $FunctionalProvider ); final String Function( - ExampleRef ref, + Ref ref, int param, )? _createCb; @@ -62,7 +60,7 @@ final class ExampleProvider extends $FunctionalProvider @override ExampleProvider $copyWithCreate( String Function( - ExampleRef ref, + Ref ref, ) create, ) { return ExampleProvider._( @@ -76,7 +74,7 @@ final class ExampleProvider extends $FunctionalProvider } @override - String create(ExampleRef ref) { + String create(Ref ref) { final _$cb = _createCb ?? example; final argument = this.argument as int; return _$cb( @@ -96,7 +94,7 @@ final class ExampleProvider extends $FunctionalProvider } } -String _$exampleHash() => r'c4f5a651a55bcf34b0c92d98d77436844cbdc097'; +String _$exampleHash() => r'7cd87bca029ed938b0e314a14fdfaa2875bd3079'; final class ExampleFamily extends Family { const ExampleFamily._() @@ -122,7 +120,7 @@ final class ExampleFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( String Function( - ExampleRef ref, + Ref ref, int args, ) create, ) { @@ -141,4 +139,4 @@ final class ExampleFamily extends Family { } } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/concepts/about_codegen/provider_type/family_class.g.dart b/website/docs/concepts/about_codegen/provider_type/family_class.g.dart index 7adf9c927..c26d84a59 100644 --- a/website/docs/concepts/about_codegen/provider_type/family_class.g.dart +++ b/website/docs/concepts/about_codegen/provider_type/family_class.g.dart @@ -72,7 +72,7 @@ final class ExampleProvider extends $NotifierProvider { @override ExampleProvider $copyWithBuild( String Function( - Ref, + Ref, Example, ) build, ) { @@ -158,7 +158,7 @@ final class ExampleFamily extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( String Function( - Ref ref, + Ref ref, Example notifier, ( int, { @@ -205,4 +205,4 @@ abstract class _$Example extends $Notifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/concepts/about_codegen/provider_type/family_fn.dart b/website/docs/concepts/about_codegen/provider_type/family_fn.dart index 9f6ff57cd..6ac513340 100644 --- a/website/docs/concepts/about_codegen/provider_type/family_fn.dart +++ b/website/docs/concepts/about_codegen/provider_type/family_fn.dart @@ -5,7 +5,7 @@ part 'family_fn.g.dart'; /* SNIPPET START */ @riverpod String example( - ExampleRef ref, + Ref ref, int param1, { String param2 = 'foo', }) { diff --git a/website/docs/concepts/about_codegen/provider_type/family_fn.g.dart b/website/docs/concepts/about_codegen/provider_type/family_fn.g.dart index 261ea5829..d918bce6f 100644 --- a/website/docs/concepts/about_codegen/provider_type/family_fn.g.dart +++ b/website/docs/concepts/about_codegen/provider_type/family_fn.g.dart @@ -8,13 +8,11 @@ part of 'family_fn.dart'; // RiverpodGenerator // ************************************************************************** -typedef ExampleRef = Ref; - @ProviderFor(example) const exampleProvider = ExampleFamily._(); final class ExampleProvider extends $FunctionalProvider - with $Provider { + with $Provider { const ExampleProvider._( {required ExampleFamily super.from, required ( @@ -23,7 +21,7 @@ final class ExampleProvider extends $FunctionalProvider }) super.argument, String Function( - ExampleRef ref, + Ref ref, int param1, { String param2, })? create}) @@ -37,7 +35,7 @@ final class ExampleProvider extends $FunctionalProvider ); final String Function( - ExampleRef ref, + Ref ref, int param1, { String param2, })? _createCb; @@ -68,7 +66,7 @@ final class ExampleProvider extends $FunctionalProvider @override ExampleProvider $copyWithCreate( String Function( - ExampleRef ref, + Ref ref, ) create, ) { return ExampleProvider._( @@ -86,7 +84,7 @@ final class ExampleProvider extends $FunctionalProvider } @override - String create(ExampleRef ref) { + String create(Ref ref) { final _$cb = _createCb ?? example; final argument = this.argument as ( int, { @@ -110,7 +108,7 @@ final class ExampleProvider extends $FunctionalProvider } } -String _$exampleHash() => r'9c32e94eea83a436746088de51e6426f251b2190'; +String _$exampleHash() => r'5795b1f6c6f075de18d0e9789a3a52040c144f0c'; final class ExampleFamily extends Family { const ExampleFamily._() @@ -140,7 +138,7 @@ final class ExampleFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( String Function( - ExampleRef ref, + Ref ref, ( int, { String param2, @@ -165,4 +163,4 @@ final class ExampleFamily extends Family { } } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/concepts/about_codegen/provider_type/sync_class.g.dart b/website/docs/concepts/about_codegen/provider_type/sync_class.g.dart index 667033101..3984ef54d 100644 --- a/website/docs/concepts/about_codegen/provider_type/sync_class.g.dart +++ b/website/docs/concepts/about_codegen/provider_type/sync_class.g.dart @@ -54,7 +54,7 @@ final class ExampleProvider extends $NotifierProvider { @override ExampleProvider $copyWithBuild( String Function( - Ref, + Ref, Example, ) build, ) { @@ -78,4 +78,4 @@ abstract class _$Example extends $Notifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/concepts/about_codegen/provider_type/sync_fn.dart b/website/docs/concepts/about_codegen/provider_type/sync_fn.dart index 0d4922734..73e82b7e2 100644 --- a/website/docs/concepts/about_codegen/provider_type/sync_fn.dart +++ b/website/docs/concepts/about_codegen/provider_type/sync_fn.dart @@ -4,6 +4,6 @@ part 'sync_fn.g.dart'; /* SNIPPET START */ @riverpod -String example(ExampleRef ref) { +String example(Ref ref) { return 'foo'; } diff --git a/website/docs/concepts/about_codegen/provider_type/sync_fn.g.dart b/website/docs/concepts/about_codegen/provider_type/sync_fn.g.dart index 95a8f5e82..0da673a93 100644 --- a/website/docs/concepts/about_codegen/provider_type/sync_fn.g.dart +++ b/website/docs/concepts/about_codegen/provider_type/sync_fn.g.dart @@ -8,16 +8,14 @@ part of 'sync_fn.dart'; // RiverpodGenerator // ************************************************************************** -typedef ExampleRef = Ref; - @ProviderFor(example) const exampleProvider = ExampleProvider._(); final class ExampleProvider extends $FunctionalProvider - with $Provider { + with $Provider { const ExampleProvider._( {String Function( - ExampleRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -31,7 +29,7 @@ final class ExampleProvider extends $FunctionalProvider ); final String Function( - ExampleRef ref, + Ref ref, )? _createCb; @override @@ -53,20 +51,20 @@ final class ExampleProvider extends $FunctionalProvider @override ExampleProvider $copyWithCreate( String Function( - ExampleRef ref, + Ref ref, ) create, ) { return ExampleProvider._(create: create); } @override - String create(ExampleRef ref) { + String create(Ref ref) { final _$cb = _createCb ?? example; return _$cb(ref); } } -String _$exampleHash() => r'dd4e9043c704a42a3fc025e7fef9515f659fc78a'; +String _$exampleHash() => r'e75fe2037fef7a3f80e04fa007fe64d719dba2fd'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/concepts/about_hooks.mdx b/website/docs/concepts/about_hooks.mdx index ffce70b56..d65fa3c86 100644 --- a/website/docs/concepts/about_hooks.mdx +++ b/website/docs/concepts/about_hooks.mdx @@ -56,7 +56,7 @@ In general, hooks are helpful for: - Forms - Animations - Reacting to user events -- ... +- etc. As an example, we could use hooks to manually implement a fade-in animation, where a widget starts invisible and slowly appears. diff --git a/website/docs/concepts/async_initialization.dart b/website/docs/concepts/async_initialization.dart index a006cf77d..8163a5896 100644 --- a/website/docs/concepts/async_initialization.dart +++ b/website/docs/concepts/async_initialization.dart @@ -1,8 +1,7 @@ -// ignore_for_file: omit_local_variable_types, prefer_final_locals +// ignore_for_file: omit_local_variable_types, prefer_final_locals, unreachable_from_main import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:flutter_riverpod/legacy.dart'; import 'package:shared_preferences/shared_preferences.dart'; class LoadingScreen extends StatelessWidget { @@ -15,15 +14,22 @@ class LoadingScreen extends StatelessWidget { } /* SNIPPET START */ -// We'd like to obtain an instance of shared preferences synchronously in a provider -final countProvider = StateProvider((ref) { - final preferences = ref.watch(sharedPreferencesProvider); - final currentValue = preferences.getInt('count') ?? 0; - ref.listenSelf((prev, curr) { - preferences.setInt('count', curr); - }); - return currentValue; -}); +final countProvider = NotifierProvider(CountNotifier.new); + +class CountNotifier extends Notifier { + @override + int build() { + // We'd like to obtain an instance of shared preferences synchronously in a provider + final preferences = ref.watch(sharedPreferencesProvider); + final currentValue = preferences.getInt('count') ?? 0; + listenSelf((prev, next) { + preferences.setInt('count', next); + }); + return currentValue; + } + + void increment() => state++; +} // We don't have an actual instance of SharedPreferences, and we can't get one except asynchronously final sharedPreferencesProvider = diff --git a/website/docs/concepts/combining_provider_states/characters_provider/codegen.dart b/website/docs/concepts/combining_provider_states/characters_provider/codegen.dart index 8c5ea014e..dbab1b4e1 100644 --- a/website/docs/concepts/combining_provider_states/characters_provider/codegen.dart +++ b/website/docs/concepts/combining_provider_states/characters_provider/codegen.dart @@ -11,15 +11,15 @@ final dio = Dio(); // The current search filter @riverpod -String search(SearchRef ref) => ''; +String search(Ref ref) => ''; @riverpod -Stream configs(ConfigsRef ref) { +Stream configs(Ref ref) { return Stream.value(Configuration()); } @riverpod -Future> characters(CharactersRef ref) async { +Future> characters(Ref ref) async { final search = ref.watch(searchProvider); final configs = await ref.watch(configsProvider.future); final response = await dio.get>>( diff --git a/website/docs/concepts/combining_provider_states/characters_provider/codegen.g.dart b/website/docs/concepts/combining_provider_states/characters_provider/codegen.g.dart index 42f2e78d3..94def9aad 100644 --- a/website/docs/concepts/combining_provider_states/characters_provider/codegen.g.dart +++ b/website/docs/concepts/combining_provider_states/characters_provider/codegen.g.dart @@ -8,16 +8,14 @@ part of 'codegen.dart'; // RiverpodGenerator // ************************************************************************** -typedef SearchRef = Ref; - @ProviderFor(search) const searchProvider = SearchProvider._(); final class SearchProvider extends $FunctionalProvider - with $Provider { + with $Provider { const SearchProvider._( {String Function( - SearchRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -31,7 +29,7 @@ final class SearchProvider extends $FunctionalProvider ); final String Function( - SearchRef ref, + Ref ref, )? _createCb; @override @@ -53,34 +51,30 @@ final class SearchProvider extends $FunctionalProvider @override SearchProvider $copyWithCreate( String Function( - SearchRef ref, + Ref ref, ) create, ) { return SearchProvider._(create: create); } @override - String create(SearchRef ref) { + String create(Ref ref) { final _$cb = _createCb ?? search; return _$cb(ref); } } -String _$searchHash() => r'a093687a671a5d5481789cf3e401a09f96f8896d'; - -typedef ConfigsRef = Ref>; +String _$searchHash() => r'bc08d7ad4026615f3c0e4824c6b943f315cf18be'; @ProviderFor(configs) const configsProvider = ConfigsProvider._(); final class ConfigsProvider extends $FunctionalProvider< AsyncValue, Stream> - with - $FutureModifier, - $StreamProvider { + with $FutureModifier, $StreamProvider { const ConfigsProvider._( {Stream Function( - ConfigsRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -94,7 +88,7 @@ final class ConfigsProvider extends $FunctionalProvider< ); final Stream Function( - ConfigsRef ref, + Ref ref, )? _createCb; @override @@ -109,34 +103,30 @@ final class ConfigsProvider extends $FunctionalProvider< @override ConfigsProvider $copyWithCreate( Stream Function( - ConfigsRef ref, + Ref ref, ) create, ) { return ConfigsProvider._(create: create); } @override - Stream create(ConfigsRef ref) { + Stream create(Ref ref) { final _$cb = _createCb ?? configs; return _$cb(ref); } } -String _$configsHash() => r'166cbe95e6b49ed7bc78c96041fb14abddbf6911'; - -typedef CharactersRef = Ref>>; +String _$configsHash() => r'6416514dacd408abb24de2bd1404860e6518c564'; @ProviderFor(characters) const charactersProvider = CharactersProvider._(); final class CharactersProvider extends $FunctionalProvider< AsyncValue>, FutureOr>> - with - $FutureModifier>, - $FutureProvider, CharactersRef> { + with $FutureModifier>, $FutureProvider> { const CharactersProvider._( {FutureOr> Function( - CharactersRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -150,7 +140,7 @@ final class CharactersProvider extends $FunctionalProvider< ); final FutureOr> Function( - CharactersRef ref, + Ref ref, )? _createCb; @override @@ -165,20 +155,20 @@ final class CharactersProvider extends $FunctionalProvider< @override CharactersProvider $copyWithCreate( FutureOr> Function( - CharactersRef ref, + Ref ref, ) create, ) { return CharactersProvider._(create: create); } @override - FutureOr> create(CharactersRef ref) { + FutureOr> create(Ref ref) { final _$cb = _createCb ?? characters; return _$cb(ref); } } -String _$charactersHash() => r'b1e8e15bbeab60d92fe959d9e1dd4ceba6a31446'; +String _$charactersHash() => r'd2bac558571ceae538d012696be58e2a06e8013f'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/concepts/combining_provider_states/city_provider/codegen.dart b/website/docs/concepts/combining_provider_states/city_provider/codegen.dart index 8b8f234b9..092367038 100644 --- a/website/docs/concepts/combining_provider_states/city_provider/codegen.dart +++ b/website/docs/concepts/combining_provider_states/city_provider/codegen.dart @@ -4,4 +4,4 @@ part 'codegen.g.dart'; /* SNIPPET START */ @riverpod -String city(CityRef ref) => 'London'; +String city(Ref ref) => 'London'; diff --git a/website/docs/concepts/combining_provider_states/city_provider/codegen.g.dart b/website/docs/concepts/combining_provider_states/city_provider/codegen.g.dart index 730fd5cb5..b60e09654 100644 --- a/website/docs/concepts/combining_provider_states/city_provider/codegen.g.dart +++ b/website/docs/concepts/combining_provider_states/city_provider/codegen.g.dart @@ -8,16 +8,14 @@ part of 'codegen.dart'; // RiverpodGenerator // ************************************************************************** -typedef CityRef = Ref; - @ProviderFor(city) const cityProvider = CityProvider._(); final class CityProvider extends $FunctionalProvider - with $Provider { + with $Provider { const CityProvider._( {String Function( - CityRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -31,7 +29,7 @@ final class CityProvider extends $FunctionalProvider ); final String Function( - CityRef ref, + Ref ref, )? _createCb; @override @@ -53,20 +51,20 @@ final class CityProvider extends $FunctionalProvider @override CityProvider $copyWithCreate( String Function( - CityRef ref, + Ref ref, ) create, ) { return CityProvider._(create: create); } @override - String create(CityRef ref) { + String create(Ref ref) { final _$cb = _createCb ?? city; return _$cb(ref); } } -String _$cityHash() => r'2ccdee096b5d5c1cafa736b3e52b788431b9af38'; +String _$cityHash() => r'6a5023a3aba119f1ecaee6c7db44b3f519e72759'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/concepts/combining_provider_states/filtered_todo_list_provider/codegen.dart b/website/docs/concepts/combining_provider_states/filtered_todo_list_provider/codegen.dart index c224a8c57..4e16203ed 100644 --- a/website/docs/concepts/combining_provider_states/filtered_todo_list_provider/codegen.dart +++ b/website/docs/concepts/combining_provider_states/filtered_todo_list_provider/codegen.dart @@ -11,12 +11,12 @@ enum Filter { } @riverpod -Filter filter(FilterRef ref) => Filter.none; +Filter filter(Ref ref) => Filter.none; /* SNIPPET START */ @riverpod -List filteredTodoList(FilteredTodoListRef ref) { +List filteredTodoList(Ref ref) { final filter = ref.watch(filterProvider); final todos = ref.watch(todoListProvider); diff --git a/website/docs/concepts/combining_provider_states/filtered_todo_list_provider/codegen.g.dart b/website/docs/concepts/combining_provider_states/filtered_todo_list_provider/codegen.g.dart index 853d26933..8d5daac4e 100644 --- a/website/docs/concepts/combining_provider_states/filtered_todo_list_provider/codegen.g.dart +++ b/website/docs/concepts/combining_provider_states/filtered_todo_list_provider/codegen.g.dart @@ -8,16 +8,14 @@ part of 'codegen.dart'; // RiverpodGenerator // ************************************************************************** -typedef FilterRef = Ref; - @ProviderFor(filter) const filterProvider = FilterProvider._(); final class FilterProvider extends $FunctionalProvider - with $Provider { + with $Provider { const FilterProvider._( {Filter Function( - FilterRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -31,7 +29,7 @@ final class FilterProvider extends $FunctionalProvider ); final Filter Function( - FilterRef ref, + Ref ref, )? _createCb; @override @@ -53,32 +51,30 @@ final class FilterProvider extends $FunctionalProvider @override FilterProvider $copyWithCreate( Filter Function( - FilterRef ref, + Ref ref, ) create, ) { return FilterProvider._(create: create); } @override - Filter create(FilterRef ref) { + Filter create(Ref ref) { final _$cb = _createCb ?? filter; return _$cb(ref); } } -String _$filterHash() => r'53b85f9e189dabb39aa269e62536a3f1a3559ef7'; - -typedef FilteredTodoListRef = Ref>; +String _$filterHash() => r'6583f8bace972f4385964cd26f217751164b537b'; @ProviderFor(filteredTodoList) const filteredTodoListProvider = FilteredTodoListProvider._(); final class FilteredTodoListProvider extends $FunctionalProvider, List> - with $Provider, FilteredTodoListRef> { + with $Provider> { const FilteredTodoListProvider._( {List Function( - FilteredTodoListRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -92,7 +88,7 @@ final class FilteredTodoListProvider ); final List Function( - FilteredTodoListRef ref, + Ref ref, )? _createCb; @override @@ -114,20 +110,20 @@ final class FilteredTodoListProvider @override FilteredTodoListProvider $copyWithCreate( List Function( - FilteredTodoListRef ref, + Ref ref, ) create, ) { return FilteredTodoListProvider._(create: create); } @override - List create(FilteredTodoListRef ref) { + List create(Ref ref) { final _$cb = _createCb ?? filteredTodoList; return _$cb(ref); } } -String _$filteredTodoListHash() => r'1c35eb0fce8fc7c7cda86413b02f606f8c8ae2b4'; +String _$filteredTodoListHash() => r'e0faf3934cd30a62b5771f2e4d64eaa727065c2f'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/concepts/combining_provider_states/read_in_provider/codegen.dart b/website/docs/concepts/combining_provider_states/read_in_provider/codegen.dart index b1cb3dbe3..c76e47a97 100644 --- a/website/docs/concepts/combining_provider_states/read_in_provider/codegen.dart +++ b/website/docs/concepts/combining_provider_states/read_in_provider/codegen.dart @@ -3,14 +3,14 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'codegen.g.dart'; @riverpod -MyValue another(AnotherRef ref) => MyValue(); +MyValue another(Ref ref) => MyValue(); class MyValue {} /* SNIPPET START */ @riverpod -MyValue my(MyRef ref) { +MyValue my(Ref ref) { // Bad practice to call `read` here final value = ref.read(anotherProvider); return value; diff --git a/website/docs/concepts/combining_provider_states/read_in_provider/codegen.g.dart b/website/docs/concepts/combining_provider_states/read_in_provider/codegen.g.dart index 4b37b373a..309085274 100644 --- a/website/docs/concepts/combining_provider_states/read_in_provider/codegen.g.dart +++ b/website/docs/concepts/combining_provider_states/read_in_provider/codegen.g.dart @@ -8,16 +8,14 @@ part of 'codegen.dart'; // RiverpodGenerator // ************************************************************************** -typedef AnotherRef = Ref; - @ProviderFor(another) const anotherProvider = AnotherProvider._(); final class AnotherProvider extends $FunctionalProvider - with $Provider { + with $Provider { const AnotherProvider._( {MyValue Function( - AnotherRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -31,7 +29,7 @@ final class AnotherProvider extends $FunctionalProvider ); final MyValue Function( - AnotherRef ref, + Ref ref, )? _createCb; @override @@ -53,31 +51,29 @@ final class AnotherProvider extends $FunctionalProvider @override AnotherProvider $copyWithCreate( MyValue Function( - AnotherRef ref, + Ref ref, ) create, ) { return AnotherProvider._(create: create); } @override - MyValue create(AnotherRef ref) { + MyValue create(Ref ref) { final _$cb = _createCb ?? another; return _$cb(ref); } } -String _$anotherHash() => r'bb412edc55657c14eace37792cd18e5254604a36'; - -typedef MyRef = Ref; +String _$anotherHash() => r'07629e5ae4a53bcd316b91c07d7558edbdea9317'; @ProviderFor(my) const myProvider = MyProvider._(); final class MyProvider extends $FunctionalProvider - with $Provider { + with $Provider { const MyProvider._( {MyValue Function( - MyRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -91,7 +87,7 @@ final class MyProvider extends $FunctionalProvider ); final MyValue Function( - MyRef ref, + Ref ref, )? _createCb; @override @@ -113,20 +109,20 @@ final class MyProvider extends $FunctionalProvider @override MyProvider $copyWithCreate( MyValue Function( - MyRef ref, + Ref ref, ) create, ) { return MyProvider._(create: create); } @override - MyValue create(MyRef ref) { + MyValue create(Ref ref) { final _$cb = _createCb ?? my; return _$cb(ref); } } -String _$myHash() => r'2712c772be4dbaabd4c99fd803f927a7e9938b21'; +String _$myHash() => r'816efc8816269dabd0944c434946903db197fe0b'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/concepts/combining_provider_states/select_async_provider/codegen.dart b/website/docs/concepts/combining_provider_states/select_async_provider/codegen.dart index e44e202bc..0bdb6db69 100644 --- a/website/docs/concepts/combining_provider_states/select_async_provider/codegen.dart +++ b/website/docs/concepts/combining_provider_states/select_async_provider/codegen.dart @@ -1,4 +1,3 @@ - import 'package:dio/dio.dart'; import 'package:riverpod_annotation/riverpod_annotation.dart'; @@ -11,13 +10,14 @@ final dio = Dio(); /* SNIPPET START */ @riverpod -Stream config(ConfigRef ref) => Stream.value(Configuration()); +Stream config(Ref ref) => Stream.value(Configuration()); @riverpod -Future> products(ProductsRef ref) async { +Future> products(Ref ref) async { // Listens only to the host. If something else in the configurations // changes, this will not pointlessly re-evaluate our provider. - final host = await ref.watch(configProvider.selectAsync((config) => config.host)); + final host = + await ref.watch(configProvider.selectAsync((config) => config.host)); final result = await dio.get>>('$host/products'); diff --git a/website/docs/concepts/combining_provider_states/select_async_provider/codegen.g.dart b/website/docs/concepts/combining_provider_states/select_async_provider/codegen.g.dart index 7fb8dd81b..428bc97f0 100644 --- a/website/docs/concepts/combining_provider_states/select_async_provider/codegen.g.dart +++ b/website/docs/concepts/combining_provider_states/select_async_provider/codegen.g.dart @@ -8,19 +8,15 @@ part of 'codegen.dart'; // RiverpodGenerator // ************************************************************************** -typedef ConfigRef = Ref>; - @ProviderFor(config) const configProvider = ConfigProvider._(); final class ConfigProvider extends $FunctionalProvider< AsyncValue, Stream> - with - $FutureModifier, - $StreamProvider { + with $FutureModifier, $StreamProvider { const ConfigProvider._( {Stream Function( - ConfigRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -34,7 +30,7 @@ final class ConfigProvider extends $FunctionalProvider< ); final Stream Function( - ConfigRef ref, + Ref ref, )? _createCb; @override @@ -49,34 +45,30 @@ final class ConfigProvider extends $FunctionalProvider< @override ConfigProvider $copyWithCreate( Stream Function( - ConfigRef ref, + Ref ref, ) create, ) { return ConfigProvider._(create: create); } @override - Stream create(ConfigRef ref) { + Stream create(Ref ref) { final _$cb = _createCb ?? config; return _$cb(ref); } } -String _$configHash() => r'3021d1a8aac384e99d5d22714ffe6e868954888b'; - -typedef ProductsRef = Ref>>; +String _$configHash() => r'66f48a02bf939463649f0e7ad34137265e5c8b66'; @ProviderFor(products) const productsProvider = ProductsProvider._(); final class ProductsProvider extends $FunctionalProvider< AsyncValue>, FutureOr>> - with - $FutureModifier>, - $FutureProvider, ProductsRef> { + with $FutureModifier>, $FutureProvider> { const ProductsProvider._( {FutureOr> Function( - ProductsRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -90,7 +82,7 @@ final class ProductsProvider extends $FunctionalProvider< ); final FutureOr> Function( - ProductsRef ref, + Ref ref, )? _createCb; @override @@ -105,20 +97,20 @@ final class ProductsProvider extends $FunctionalProvider< @override ProductsProvider $copyWithCreate( FutureOr> Function( - ProductsRef ref, + Ref ref, ) create, ) { return ProductsProvider._(create: create); } @override - FutureOr> create(ProductsRef ref) { + FutureOr> create(Ref ref) { final _$cb = _createCb ?? products; return _$cb(ref); } } -String _$productsHash() => r'd1f4523880408cf8ee0e68969c40cf87d5c78557'; +String _$productsHash() => r'1915c65cef29cadc8b0adadd6ecddf753586974b'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/concepts/combining_provider_states/todo_list_provider/codegen.g.dart b/website/docs/concepts/combining_provider_states/todo_list_provider/codegen.g.dart index e348a795b..fd5cc7759 100644 --- a/website/docs/concepts/combining_provider_states/todo_list_provider/codegen.g.dart +++ b/website/docs/concepts/combining_provider_states/todo_list_provider/codegen.g.dart @@ -54,7 +54,7 @@ final class TodoListProvider extends $NotifierProvider> { @override TodoListProvider $copyWithBuild( List Function( - Ref>, + Ref, TodoList, ) build, ) { @@ -78,4 +78,4 @@ abstract class _$TodoList extends $Notifier> { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/concepts/combining_provider_states/weather_provider/codegen.dart b/website/docs/concepts/combining_provider_states/weather_provider/codegen.dart index 8f7af2644..a66b91521 100644 --- a/website/docs/concepts/combining_provider_states/weather_provider/codegen.dart +++ b/website/docs/concepts/combining_provider_states/weather_provider/codegen.dart @@ -3,14 +3,14 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'codegen.g.dart'; @riverpod -String city(CityRef ref) => 'London'; +String city(Ref ref) => 'London'; class Weather {} Future fetchWeather({required String city}) async => Weather(); /* SNIPPET START */ @riverpod -Future weather(WeatherRef ref) { +Future weather(Ref ref) { // We use `ref.watch` to listen to another provider, and we pass it the provider // that we want to consume. Here: cityProvider final city = ref.watch(cityProvider); diff --git a/website/docs/concepts/combining_provider_states/weather_provider/codegen.g.dart b/website/docs/concepts/combining_provider_states/weather_provider/codegen.g.dart index 32ac94816..ac5fc993c 100644 --- a/website/docs/concepts/combining_provider_states/weather_provider/codegen.g.dart +++ b/website/docs/concepts/combining_provider_states/weather_provider/codegen.g.dart @@ -8,16 +8,14 @@ part of 'codegen.dart'; // RiverpodGenerator // ************************************************************************** -typedef CityRef = Ref; - @ProviderFor(city) const cityProvider = CityProvider._(); final class CityProvider extends $FunctionalProvider - with $Provider { + with $Provider { const CityProvider._( {String Function( - CityRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -31,7 +29,7 @@ final class CityProvider extends $FunctionalProvider ); final String Function( - CityRef ref, + Ref ref, )? _createCb; @override @@ -53,32 +51,30 @@ final class CityProvider extends $FunctionalProvider @override CityProvider $copyWithCreate( String Function( - CityRef ref, + Ref ref, ) create, ) { return CityProvider._(create: create); } @override - String create(CityRef ref) { + String create(Ref ref) { final _$cb = _createCb ?? city; return _$cb(ref); } } -String _$cityHash() => r'2ccdee096b5d5c1cafa736b3e52b788431b9af38'; - -typedef WeatherRef = Ref>; +String _$cityHash() => r'6a5023a3aba119f1ecaee6c7db44b3f519e72759'; @ProviderFor(weather) const weatherProvider = WeatherProvider._(); final class WeatherProvider extends $FunctionalProvider, FutureOr> - with $FutureModifier, $FutureProvider { + with $FutureModifier, $FutureProvider { const WeatherProvider._( {FutureOr Function( - WeatherRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -92,7 +88,7 @@ final class WeatherProvider ); final FutureOr Function( - WeatherRef ref, + Ref ref, )? _createCb; @override @@ -106,20 +102,20 @@ final class WeatherProvider @override WeatherProvider $copyWithCreate( FutureOr Function( - WeatherRef ref, + Ref ref, ) create, ) { return WeatherProvider._(create: create); } @override - FutureOr create(WeatherRef ref) { + FutureOr create(Ref ref) { final _$cb = _createCb ?? weather; return _$cb(ref); } } -String _$weatherHash() => r'9a79d0269032630918eef9d3f562ff35b5860061'; +String _$weatherHash() => r'277f005f0a4ea0bc28eaa4bc6628ba2a5d1034c8'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/concepts/combining_provider_states/whole_object_provider/codegen.dart b/website/docs/concepts/combining_provider_states/whole_object_provider/codegen.dart index 1a90008ed..cb3a1ec73 100644 --- a/website/docs/concepts/combining_provider_states/whole_object_provider/codegen.dart +++ b/website/docs/concepts/combining_provider_states/whole_object_provider/codegen.dart @@ -10,10 +10,10 @@ final dio = Dio(); /* SNIPPET START */ @riverpod -Stream config(ConfigRef ref) => Stream.value(Configuration()); +Stream config(Ref ref) => Stream.value(Configuration()); @riverpod -Future> products(ProductsRef ref) async { +Future> products(Ref ref) async { // Will cause productsProvider to re-fetch the products if anything in the // configurations changes final configs = await ref.watch(configProvider.future); diff --git a/website/docs/concepts/combining_provider_states/whole_object_provider/codegen.g.dart b/website/docs/concepts/combining_provider_states/whole_object_provider/codegen.g.dart index b34376210..310381d65 100644 --- a/website/docs/concepts/combining_provider_states/whole_object_provider/codegen.g.dart +++ b/website/docs/concepts/combining_provider_states/whole_object_provider/codegen.g.dart @@ -8,19 +8,15 @@ part of 'codegen.dart'; // RiverpodGenerator // ************************************************************************** -typedef ConfigRef = Ref>; - @ProviderFor(config) const configProvider = ConfigProvider._(); final class ConfigProvider extends $FunctionalProvider< AsyncValue, Stream> - with - $FutureModifier, - $StreamProvider { + with $FutureModifier, $StreamProvider { const ConfigProvider._( {Stream Function( - ConfigRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -34,7 +30,7 @@ final class ConfigProvider extends $FunctionalProvider< ); final Stream Function( - ConfigRef ref, + Ref ref, )? _createCb; @override @@ -49,34 +45,30 @@ final class ConfigProvider extends $FunctionalProvider< @override ConfigProvider $copyWithCreate( Stream Function( - ConfigRef ref, + Ref ref, ) create, ) { return ConfigProvider._(create: create); } @override - Stream create(ConfigRef ref) { + Stream create(Ref ref) { final _$cb = _createCb ?? config; return _$cb(ref); } } -String _$configHash() => r'3021d1a8aac384e99d5d22714ffe6e868954888b'; - -typedef ProductsRef = Ref>>; +String _$configHash() => r'66f48a02bf939463649f0e7ad34137265e5c8b66'; @ProviderFor(products) const productsProvider = ProductsProvider._(); final class ProductsProvider extends $FunctionalProvider< AsyncValue>, FutureOr>> - with - $FutureModifier>, - $FutureProvider, ProductsRef> { + with $FutureModifier>, $FutureProvider> { const ProductsProvider._( {FutureOr> Function( - ProductsRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -90,7 +82,7 @@ final class ProductsProvider extends $FunctionalProvider< ); final FutureOr> Function( - ProductsRef ref, + Ref ref, )? _createCb; @override @@ -105,20 +97,20 @@ final class ProductsProvider extends $FunctionalProvider< @override ProductsProvider $copyWithCreate( FutureOr> Function( - ProductsRef ref, + Ref ref, ) create, ) { return ProductsProvider._(create: create); } @override - FutureOr> create(ProductsRef ref) { + FutureOr> create(Ref ref) { final _$cb = _createCb ?? products; return _$cb(ref); } } -String _$productsHash() => r'637254615fa398af0d36e212f09e5d3d8ff866aa'; +String _$productsHash() => r'd0ddbfac09629b48b568f0cc07e063bb7d649162'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/concepts/combining_providers.mdx b/website/docs/concepts/combining_providers.mdx index 541647f57..42a483b9b 100644 --- a/website/docs/concepts/combining_providers.mdx +++ b/website/docs/concepts/combining_providers.mdx @@ -128,7 +128,7 @@ final repositoryProvider = Provider(Repository.new); class Repository { Repository(this.ref); - final Ref ref; + final Ref ref; Future fetchCatalog() async { String token = ref.read(userTokenProvider); diff --git a/website/docs/concepts/lifecycle_on_dispose/codegen.dart b/website/docs/concepts/lifecycle_on_dispose/codegen.dart index b881d7bf9..35f832a69 100644 --- a/website/docs/concepts/lifecycle_on_dispose/codegen.dart +++ b/website/docs/concepts/lifecycle_on_dispose/codegen.dart @@ -8,7 +8,7 @@ part 'codegen.g.dart'; /* SNIPPET START */ @riverpod -Stream example(ExampleRef ref) { +Stream example(Ref ref) { final streamController = StreamController(); ref.onDispose(() { diff --git a/website/docs/concepts/lifecycle_on_dispose/codegen.g.dart b/website/docs/concepts/lifecycle_on_dispose/codegen.g.dart index 24597d983..a54e676cf 100644 --- a/website/docs/concepts/lifecycle_on_dispose/codegen.g.dart +++ b/website/docs/concepts/lifecycle_on_dispose/codegen.g.dart @@ -8,17 +8,15 @@ part of 'codegen.dart'; // RiverpodGenerator // ************************************************************************** -typedef ExampleRef = Ref>; - @ProviderFor(example) const exampleProvider = ExampleProvider._(); final class ExampleProvider extends $FunctionalProvider, Stream> - with $FutureModifier, $StreamProvider { + with $FutureModifier, $StreamProvider { const ExampleProvider._( {Stream Function( - ExampleRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -32,7 +30,7 @@ final class ExampleProvider ); final Stream Function( - ExampleRef ref, + Ref ref, )? _createCb; @override @@ -46,20 +44,20 @@ final class ExampleProvider @override ExampleProvider $copyWithCreate( Stream Function( - ExampleRef ref, + Ref ref, ) create, ) { return ExampleProvider._(create: create); } @override - Stream create(ExampleRef ref) { + Stream create(Ref ref) { final _$cb = _createCb ?? example; return _$cb(ref); } } -String _$exampleHash() => r'e2c4eb8a7cf06c7a0e5d07ee2bd51db254033fa6'; +String _$exampleHash() => r'ec358d3864f4c5daaab92153afd5cf79e915aebc'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/concepts/providers/creating_a_provider/codegen.dart b/website/docs/concepts/providers/creating_a_provider/codegen.dart index 8dc6c5e12..15efd2d7a 100644 --- a/website/docs/concepts/providers/creating_a_provider/codegen.dart +++ b/website/docs/concepts/providers/creating_a_provider/codegen.dart @@ -7,6 +7,6 @@ class MyValue {} /* SNIPPET START */ @riverpod -MyValue my(MyRef ref) { +MyValue my(Ref ref) { return MyValue(); } diff --git a/website/docs/concepts/providers/creating_a_provider/codegen.g.dart b/website/docs/concepts/providers/creating_a_provider/codegen.g.dart index 1478a2bd2..5e7e8aafb 100644 --- a/website/docs/concepts/providers/creating_a_provider/codegen.g.dart +++ b/website/docs/concepts/providers/creating_a_provider/codegen.g.dart @@ -8,16 +8,14 @@ part of 'codegen.dart'; // RiverpodGenerator // ************************************************************************** -typedef MyRef = Ref; - @ProviderFor(my) const myProvider = MyProvider._(); final class MyProvider extends $FunctionalProvider - with $Provider { + with $Provider { const MyProvider._( {MyValue Function( - MyRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -31,7 +29,7 @@ final class MyProvider extends $FunctionalProvider ); final MyValue Function( - MyRef ref, + Ref ref, )? _createCb; @override @@ -53,20 +51,20 @@ final class MyProvider extends $FunctionalProvider @override MyProvider $copyWithCreate( MyValue Function( - MyRef ref, + Ref ref, ) create, ) { return MyProvider._(create: create); } @override - MyValue create(MyRef ref) { + MyValue create(Ref ref) { final _$cb = _createCb ?? my; return _$cb(ref); } } -String _$myHash() => r'0810ee24cae78c131d00773ac20d254c83eefab7'; +String _$myHash() => r'abf4b86b981ed95db3f391483b0a1497c33e98b8'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/concepts/providers/declaring_many_providers/codegen.dart b/website/docs/concepts/providers/declaring_many_providers/codegen.dart index 474fe004b..276cab4dd 100644 --- a/website/docs/concepts/providers/declaring_many_providers/codegen.dart +++ b/website/docs/concepts/providers/declaring_many_providers/codegen.dart @@ -5,6 +5,6 @@ part 'codegen.g.dart'; /* SNIPPET START */ @riverpod -String city(CityRef ref) => 'London'; +String city(Ref ref) => 'London'; @riverpod -String country(CountryRef ref) => 'England'; +String country(Ref ref) => 'England'; diff --git a/website/docs/concepts/providers/declaring_many_providers/codegen.g.dart b/website/docs/concepts/providers/declaring_many_providers/codegen.g.dart index b3c4216c7..be7fa50dc 100644 --- a/website/docs/concepts/providers/declaring_many_providers/codegen.g.dart +++ b/website/docs/concepts/providers/declaring_many_providers/codegen.g.dart @@ -8,16 +8,14 @@ part of 'codegen.dart'; // RiverpodGenerator // ************************************************************************** -typedef CityRef = Ref; - @ProviderFor(city) const cityProvider = CityProvider._(); final class CityProvider extends $FunctionalProvider - with $Provider { + with $Provider { const CityProvider._( {String Function( - CityRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -31,7 +29,7 @@ final class CityProvider extends $FunctionalProvider ); final String Function( - CityRef ref, + Ref ref, )? _createCb; @override @@ -53,31 +51,29 @@ final class CityProvider extends $FunctionalProvider @override CityProvider $copyWithCreate( String Function( - CityRef ref, + Ref ref, ) create, ) { return CityProvider._(create: create); } @override - String create(CityRef ref) { + String create(Ref ref) { final _$cb = _createCb ?? city; return _$cb(ref); } } -String _$cityHash() => r'2ccdee096b5d5c1cafa736b3e52b788431b9af38'; - -typedef CountryRef = Ref; +String _$cityHash() => r'6a5023a3aba119f1ecaee6c7db44b3f519e72759'; @ProviderFor(country) const countryProvider = CountryProvider._(); final class CountryProvider extends $FunctionalProvider - with $Provider { + with $Provider { const CountryProvider._( {String Function( - CountryRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -91,7 +87,7 @@ final class CountryProvider extends $FunctionalProvider ); final String Function( - CountryRef ref, + Ref ref, )? _createCb; @override @@ -113,20 +109,20 @@ final class CountryProvider extends $FunctionalProvider @override CountryProvider $copyWithCreate( String Function( - CountryRef ref, + Ref ref, ) create, ) { return CountryProvider._(create: create); } @override - String create(CountryRef ref) { + String create(Ref ref) { final _$cb = _createCb ?? country; return _$cb(ref); } } -String _$countryHash() => r'd1513349c3bc0c99763cb4fb29eb012f2351bc4c'; +String _$countryHash() => r'9fabd1cffe35f15a0a03339193da2d646c260137'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/concepts/reading/counter/codegen.dart b/website/docs/concepts/reading/counter/codegen.dart index a23405835..2b464eb1d 100644 --- a/website/docs/concepts/reading/counter/codegen.dart +++ b/website/docs/concepts/reading/counter/codegen.dart @@ -3,7 +3,7 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'codegen.g.dart'; @riverpod -Repository repository(RepositoryRef ref) => Repository(); +Repository repository(Ref ref) => Repository(); class Repository { Future post(String url) async {} diff --git a/website/docs/concepts/reading/counter/codegen.g.dart b/website/docs/concepts/reading/counter/codegen.g.dart index 862a2f9e3..49c218644 100644 --- a/website/docs/concepts/reading/counter/codegen.g.dart +++ b/website/docs/concepts/reading/counter/codegen.g.dart @@ -8,17 +8,15 @@ part of 'codegen.dart'; // RiverpodGenerator // ************************************************************************** -typedef RepositoryRef = Ref; - @ProviderFor(repository) const repositoryProvider = RepositoryProvider._(); final class RepositoryProvider extends $FunctionalProvider - with $Provider { + with $Provider { const RepositoryProvider._( {Repository Function( - RepositoryRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -32,7 +30,7 @@ final class RepositoryProvider ); final Repository Function( - RepositoryRef ref, + Ref ref, )? _createCb; @override @@ -54,20 +52,20 @@ final class RepositoryProvider @override RepositoryProvider $copyWithCreate( Repository Function( - RepositoryRef ref, + Ref ref, ) create, ) { return RepositoryProvider._(create: create); } @override - Repository create(RepositoryRef ref) { + Repository create(Ref ref) { final _$cb = _createCb ?? repository; return _$cb(ref); } } -String _$repositoryHash() => r'c6dc3b5b727028966b5b850b27ffc7294b485273'; +String _$repositoryHash() => r'6f859a9d70c3112139aaf826ee2bd541a4c001cb'; @ProviderFor(Counter) const counterProvider = CounterProvider._(); @@ -115,7 +113,7 @@ final class CounterProvider extends $NotifierProvider { @override CounterProvider $copyWithBuild( int Function( - Ref, + Ref, Counter, ) build, ) { @@ -139,4 +137,4 @@ abstract class _$Counter extends $Notifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/concepts/reading/counter/raw.dart b/website/docs/concepts/reading/counter/raw.dart index 5d248ab57..579d682a9 100644 --- a/website/docs/concepts/reading/counter/raw.dart +++ b/website/docs/concepts/reading/counter/raw.dart @@ -16,7 +16,7 @@ final counterProvider = StateNotifierProvider((ref) { class Counter extends StateNotifier { Counter(this.ref) : super(0); - final Ref ref; + final Ref ref; void increment() { // Counter can use the "ref" to read other providers diff --git a/website/docs/concepts/reading/listen/codegen.dart b/website/docs/concepts/reading/listen/codegen.dart index 0037c4c8d..b4531515a 100644 --- a/website/docs/concepts/reading/listen/codegen.dart +++ b/website/docs/concepts/reading/listen/codegen.dart @@ -8,7 +8,7 @@ part 'codegen.g.dart'; /* SNIPPET START */ @riverpod -void another(AnotherRef ref) { +void another(Ref ref) { ref.listen(counterProvider, (int? previousCount, int newCount) { print('The counter changed $newCount'); }); diff --git a/website/docs/concepts/reading/listen/codegen.g.dart b/website/docs/concepts/reading/listen/codegen.g.dart index 18edca4f4..b3034258c 100644 --- a/website/docs/concepts/reading/listen/codegen.g.dart +++ b/website/docs/concepts/reading/listen/codegen.g.dart @@ -8,16 +8,14 @@ part of 'codegen.dart'; // RiverpodGenerator // ************************************************************************** -typedef AnotherRef = Ref; - @ProviderFor(another) const anotherProvider = AnotherProvider._(); final class AnotherProvider extends $FunctionalProvider - with $Provider { + with $Provider { const AnotherProvider._( {void Function( - AnotherRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -31,7 +29,7 @@ final class AnotherProvider extends $FunctionalProvider ); final void Function( - AnotherRef ref, + Ref ref, )? _createCb; @override @@ -53,20 +51,20 @@ final class AnotherProvider extends $FunctionalProvider @override AnotherProvider $copyWithCreate( void Function( - AnotherRef ref, + Ref ref, ) create, ) { return AnotherProvider._(create: create); } @override - void create(AnotherRef ref) { + void create(Ref ref) { final _$cb = _createCb ?? another; return _$cb(ref); } } -String _$anotherHash() => r'2208f9221f3d898305609874d4f43c28bdfff2b4'; +String _$anotherHash() => r'1901cd6ee57ea427f82e6d5bbee79e91ddf71065'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/concepts/reading/listen_build/codegen.g.dart b/website/docs/concepts/reading/listen_build/codegen.g.dart index cca0f2498..a8fbbd8c7 100644 --- a/website/docs/concepts/reading/listen_build/codegen.g.dart +++ b/website/docs/concepts/reading/listen_build/codegen.g.dart @@ -54,7 +54,7 @@ final class CounterProvider extends $NotifierProvider { @override CounterProvider $copyWithBuild( int Function( - Ref, + Ref, Counter, ) build, ) { @@ -78,4 +78,4 @@ abstract class _$Counter extends $Notifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/concepts/reading/listen_build/codegen_hooks.g.dart b/website/docs/concepts/reading/listen_build/codegen_hooks.g.dart index 37350b911..ae33ca0fd 100644 --- a/website/docs/concepts/reading/listen_build/codegen_hooks.g.dart +++ b/website/docs/concepts/reading/listen_build/codegen_hooks.g.dart @@ -54,7 +54,7 @@ final class CounterProvider extends $NotifierProvider { @override CounterProvider $copyWithBuild( int Function( - Ref, + Ref, Counter, ) build, ) { @@ -78,4 +78,4 @@ abstract class _$Counter extends $Notifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/concepts/reading/provider/codegen.dart b/website/docs/concepts/reading/provider/codegen.dart index 201c92f91..954941a9b 100644 --- a/website/docs/concepts/reading/provider/codegen.dart +++ b/website/docs/concepts/reading/provider/codegen.dart @@ -8,12 +8,12 @@ class Repository { } @riverpod -Repository repository(RepositoryRef ref) => Repository(); +Repository repository(Ref ref) => Repository(); /* SNIPPET START */ @riverpod -String value(ValueRef ref) { +String value(Ref ref) { // use ref to obtain other providers final repository = ref.watch(repositoryProvider); return repository.get(); diff --git a/website/docs/concepts/reading/provider/codegen.g.dart b/website/docs/concepts/reading/provider/codegen.g.dart index 5a44b7459..061312636 100644 --- a/website/docs/concepts/reading/provider/codegen.g.dart +++ b/website/docs/concepts/reading/provider/codegen.g.dart @@ -8,17 +8,15 @@ part of 'codegen.dart'; // RiverpodGenerator // ************************************************************************** -typedef RepositoryRef = Ref; - @ProviderFor(repository) const repositoryProvider = RepositoryProvider._(); final class RepositoryProvider extends $FunctionalProvider - with $Provider { + with $Provider { const RepositoryProvider._( {Repository Function( - RepositoryRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -32,7 +30,7 @@ final class RepositoryProvider ); final Repository Function( - RepositoryRef ref, + Ref ref, )? _createCb; @override @@ -54,31 +52,29 @@ final class RepositoryProvider @override RepositoryProvider $copyWithCreate( Repository Function( - RepositoryRef ref, + Ref ref, ) create, ) { return RepositoryProvider._(create: create); } @override - Repository create(RepositoryRef ref) { + Repository create(Ref ref) { final _$cb = _createCb ?? repository; return _$cb(ref); } } -String _$repositoryHash() => r'c6dc3b5b727028966b5b850b27ffc7294b485273'; - -typedef ValueRef = Ref; +String _$repositoryHash() => r'6f859a9d70c3112139aaf826ee2bd541a4c001cb'; @ProviderFor(value) const valueProvider = ValueProvider._(); final class ValueProvider extends $FunctionalProvider - with $Provider { + with $Provider { const ValueProvider._( {String Function( - ValueRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -92,7 +88,7 @@ final class ValueProvider extends $FunctionalProvider ); final String Function( - ValueRef ref, + Ref ref, )? _createCb; @override @@ -114,20 +110,20 @@ final class ValueProvider extends $FunctionalProvider @override ValueProvider $copyWithCreate( String Function( - ValueRef ref, + Ref ref, ) create, ) { return ValueProvider._(create: create); } @override - String create(ValueRef ref) { + String create(Ref ref) { final _$cb = _createCb ?? value; return _$cb(ref); } } -String _$valueHash() => r'8c26f7aaa911af815cff9e513a18e4d8dcc6d1df'; +String _$valueHash() => r'fcb38a2d2c3755f3691e73cd163e8c895d1af4b5'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/concepts/reading/read/codegen.g.dart b/website/docs/concepts/reading/read/codegen.g.dart index afde0445a..43d8edd39 100644 --- a/website/docs/concepts/reading/read/codegen.g.dart +++ b/website/docs/concepts/reading/read/codegen.g.dart @@ -54,7 +54,7 @@ final class CounterProvider extends $NotifierProvider { @override CounterProvider $copyWithBuild( int Function( - Ref, + Ref, Counter, ) build, ) { @@ -78,4 +78,4 @@ abstract class _$Counter extends $Notifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/concepts/reading/read/codegen_hooks.g.dart b/website/docs/concepts/reading/read/codegen_hooks.g.dart index b47bde380..ba15f2c85 100644 --- a/website/docs/concepts/reading/read/codegen_hooks.g.dart +++ b/website/docs/concepts/reading/read/codegen_hooks.g.dart @@ -54,7 +54,7 @@ final class CounterProvider extends $NotifierProvider { @override CounterProvider $copyWithBuild( int Function( - Ref, + Ref, Counter, ) build, ) { @@ -78,4 +78,4 @@ abstract class _$Counter extends $Notifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/concepts/reading/read_build/codegen.g.dart b/website/docs/concepts/reading/read_build/codegen.g.dart index afde0445a..43d8edd39 100644 --- a/website/docs/concepts/reading/read_build/codegen.g.dart +++ b/website/docs/concepts/reading/read_build/codegen.g.dart @@ -54,7 +54,7 @@ final class CounterProvider extends $NotifierProvider { @override CounterProvider $copyWithBuild( int Function( - Ref, + Ref, Counter, ) build, ) { @@ -78,4 +78,4 @@ abstract class _$Counter extends $Notifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/concepts/reading/read_notifier_build/codegen.g.dart b/website/docs/concepts/reading/read_notifier_build/codegen.g.dart index afde0445a..43d8edd39 100644 --- a/website/docs/concepts/reading/read_notifier_build/codegen.g.dart +++ b/website/docs/concepts/reading/read_notifier_build/codegen.g.dart @@ -54,7 +54,7 @@ final class CounterProvider extends $NotifierProvider { @override CounterProvider $copyWithBuild( int Function( - Ref, + Ref, Counter, ) build, ) { @@ -78,4 +78,4 @@ abstract class _$Counter extends $Notifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/concepts/reading/watch/codegen.dart b/website/docs/concepts/reading/watch/codegen.dart index 31de6da74..947af2a51 100644 --- a/website/docs/concepts/reading/watch/codegen.dart +++ b/website/docs/concepts/reading/watch/codegen.dart @@ -16,7 +16,7 @@ abstract class Todo { /* SNIPPET START */ @riverpod -FilterType filterType(FilterTypeRef ref) { +FilterType filterType(Ref ref) { return FilterType.none; } @@ -29,7 +29,7 @@ class Todos extends _$Todos { } @riverpod -List filteredTodoList(FilteredTodoListRef ref) { +List filteredTodoList(Ref ref) { // obtains both the filter and the list of todos final FilterType filter = ref.watch(filterTypeProvider); final List todos = ref.watch(todosProvider); diff --git a/website/docs/concepts/reading/watch/codegen.g.dart b/website/docs/concepts/reading/watch/codegen.g.dart index a24d2c9f7..185d3178b 100644 --- a/website/docs/concepts/reading/watch/codegen.g.dart +++ b/website/docs/concepts/reading/watch/codegen.g.dart @@ -8,17 +8,15 @@ part of 'codegen.dart'; // RiverpodGenerator // ************************************************************************** -typedef FilterTypeRef = Ref; - @ProviderFor(filterType) const filterTypeProvider = FilterTypeProvider._(); final class FilterTypeProvider extends $FunctionalProvider - with $Provider { + with $Provider { const FilterTypeProvider._( {FilterType Function( - FilterTypeRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -32,7 +30,7 @@ final class FilterTypeProvider ); final FilterType Function( - FilterTypeRef ref, + Ref ref, )? _createCb; @override @@ -54,20 +52,20 @@ final class FilterTypeProvider @override FilterTypeProvider $copyWithCreate( FilterType Function( - FilterTypeRef ref, + Ref ref, ) create, ) { return FilterTypeProvider._(create: create); } @override - FilterType create(FilterTypeRef ref) { + FilterType create(Ref ref) { final _$cb = _createCb ?? filterType; return _$cb(ref); } } -String _$filterTypeHash() => r'42b68b163daecff7a0b9b069b16025a89910b4fb'; +String _$filterTypeHash() => r'68d61a593d49306927c26fbcc66ea9fffa7c52f5'; @ProviderFor(Todos) const todosProvider = TodosProvider._(); @@ -115,7 +113,7 @@ final class TodosProvider extends $NotifierProvider> { @override TodosProvider $copyWithBuild( List Function( - Ref>, + Ref, Todos, ) build, ) { @@ -138,17 +136,15 @@ abstract class _$Todos extends $Notifier> { List runBuild() => build(); } -typedef FilteredTodoListRef = Ref>; - @ProviderFor(filteredTodoList) const filteredTodoListProvider = FilteredTodoListProvider._(); final class FilteredTodoListProvider extends $FunctionalProvider, List> - with $Provider, FilteredTodoListRef> { + with $Provider> { const FilteredTodoListProvider._( {List Function( - FilteredTodoListRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -162,7 +158,7 @@ final class FilteredTodoListProvider ); final List Function( - FilteredTodoListRef ref, + Ref ref, )? _createCb; @override @@ -184,20 +180,20 @@ final class FilteredTodoListProvider @override FilteredTodoListProvider $copyWithCreate( List Function( - FilteredTodoListRef ref, + Ref ref, ) create, ) { return FilteredTodoListProvider._(create: create); } @override - List create(FilteredTodoListRef ref) { + List create(Ref ref) { final _$cb = _createCb ?? filteredTodoList; return _$cb(ref); } } -String _$filteredTodoListHash() => r'34f1e929a9e7850946ea8634d9f3e8f38ae5687d'; +String _$filteredTodoListHash() => r'0508935737f2cb9718bd8150111135cb433bfaeb'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/concepts/reading/watch_build/codegen.dart b/website/docs/concepts/reading/watch_build/codegen.dart index 80b63d216..7224d1a33 100644 --- a/website/docs/concepts/reading/watch_build/codegen.dart +++ b/website/docs/concepts/reading/watch_build/codegen.dart @@ -24,7 +24,7 @@ class TodoList extends _$TodoList { /* SNIPPET START */ @riverpod -int counter(CounterRef ref) => 0; +int counter(Ref ref) => 0; class HomeView extends ConsumerWidget { const HomeView({super.key}); diff --git a/website/docs/concepts/reading/watch_build/codegen.g.dart b/website/docs/concepts/reading/watch_build/codegen.g.dart index 9c9fc7911..03595dcf0 100644 --- a/website/docs/concepts/reading/watch_build/codegen.g.dart +++ b/website/docs/concepts/reading/watch_build/codegen.g.dart @@ -54,7 +54,7 @@ final class TodoListProvider extends $NotifierProvider> { @override TodoListProvider $copyWithBuild( List Function( - Ref>, + Ref, TodoList, ) build, ) { @@ -77,16 +77,14 @@ abstract class _$TodoList extends $Notifier> { List runBuild() => build(); } -typedef CounterRef = Ref; - @ProviderFor(counter) const counterProvider = CounterProvider._(); final class CounterProvider extends $FunctionalProvider - with $Provider { + with $Provider { const CounterProvider._( {int Function( - CounterRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -100,7 +98,7 @@ final class CounterProvider extends $FunctionalProvider ); final int Function( - CounterRef ref, + Ref ref, )? _createCb; @override @@ -122,20 +120,20 @@ final class CounterProvider extends $FunctionalProvider @override CounterProvider $copyWithCreate( int Function( - CounterRef ref, + Ref ref, ) create, ) { return CounterProvider._(create: create); } @override - int create(CounterRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? counter; return _$cb(ref); } } -String _$counterHash() => r'9b0db44ecc47057e79891e5ecd92d34b08637679'; +String _$counterHash() => r'784ece48cb20fcfdec1553774ecfbd381d1e081f'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/concepts/reading/watch_build/codegen_hooks.dart b/website/docs/concepts/reading/watch_build/codegen_hooks.dart index c82698304..f9d721a17 100644 --- a/website/docs/concepts/reading/watch_build/codegen_hooks.dart +++ b/website/docs/concepts/reading/watch_build/codegen_hooks.dart @@ -25,7 +25,7 @@ class TodoList extends _$TodoList { /* SNIPPET START */ @riverpod -int counter(CounterRef ref) => 0; +int counter(Ref ref) => 0; class HomeView extends HookConsumerWidget { const HomeView({super.key}); diff --git a/website/docs/concepts/reading/watch_build/codegen_hooks.g.dart b/website/docs/concepts/reading/watch_build/codegen_hooks.g.dart index 3a2f0b18c..7ba745f62 100644 --- a/website/docs/concepts/reading/watch_build/codegen_hooks.g.dart +++ b/website/docs/concepts/reading/watch_build/codegen_hooks.g.dart @@ -54,7 +54,7 @@ final class TodoListProvider extends $NotifierProvider> { @override TodoListProvider $copyWithBuild( List Function( - Ref>, + Ref, TodoList, ) build, ) { @@ -77,16 +77,14 @@ abstract class _$TodoList extends $Notifier> { List runBuild() => build(); } -typedef CounterRef = Ref; - @ProviderFor(counter) const counterProvider = CounterProvider._(); final class CounterProvider extends $FunctionalProvider - with $Provider { + with $Provider { const CounterProvider._( {int Function( - CounterRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -100,7 +98,7 @@ final class CounterProvider extends $FunctionalProvider ); final int Function( - CounterRef ref, + Ref ref, )? _createCb; @override @@ -122,20 +120,20 @@ final class CounterProvider extends $FunctionalProvider @override CounterProvider $copyWithCreate( int Function( - CounterRef ref, + Ref ref, ) create, ) { return CounterProvider._(create: create); } @override - int create(CounterRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? counter; return _$cb(ref); } } -String _$counterHash() => r'9b0db44ecc47057e79891e5ecd92d34b08637679'; +String _$counterHash() => r'784ece48cb20fcfdec1553774ecfbd381d1e081f'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/concepts/reading/watch_notifier_build/codegen.g.dart b/website/docs/concepts/reading/watch_notifier_build/codegen.g.dart index afde0445a..43d8edd39 100644 --- a/website/docs/concepts/reading/watch_notifier_build/codegen.g.dart +++ b/website/docs/concepts/reading/watch_notifier_build/codegen.g.dart @@ -54,7 +54,7 @@ final class CounterProvider extends $NotifierProvider { @override CounterProvider $copyWithBuild( int Function( - Ref, + Ref, Counter, ) build, ) { @@ -78,4 +78,4 @@ abstract class _$Counter extends $Notifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/concepts/scopes.mdx b/website/docs/concepts/scopes.mdx index ec97f6ec6..4faf0541b 100644 --- a/website/docs/concepts/scopes.mdx +++ b/website/docs/concepts/scopes.mdx @@ -1,6 +1,6 @@ --- title: Scopes -version: 1 +version: 2 --- import CodeBlock from "@theme/CodeBlock"; diff --git a/website/docs/concepts/why_immutability/codegen.g.dart b/website/docs/concepts/why_immutability/codegen.g.dart index b73742a3e..f088cdf2c 100644 --- a/website/docs/concepts/why_immutability/codegen.g.dart +++ b/website/docs/concepts/why_immutability/codegen.g.dart @@ -55,7 +55,7 @@ final class ThemeNotifierProvider @override ThemeNotifierProvider $copyWithBuild( ThemeSettings Function( - Ref, + Ref, ThemeNotifier, ) build, ) { @@ -79,4 +79,4 @@ abstract class _$ThemeNotifier extends $Notifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/essentials/auto_dispose/cache_for_extension.dart b/website/docs/essentials/auto_dispose/cache_for_extension.dart index 9acb4b558..7e6a4e00d 100644 --- a/website/docs/essentials/auto_dispose/cache_for_extension.dart +++ b/website/docs/essentials/auto_dispose/cache_for_extension.dart @@ -3,7 +3,7 @@ import 'dart:async'; import 'package:hooks_riverpod/hooks_riverpod.dart'; /* SNIPPET START */ -extension CacheForExtension on Ref { +extension CacheForExtension on Ref { // {@template cacheFor} /// Keeps the provider alive for [duration]. // {@endtemplate} diff --git a/website/docs/essentials/auto_dispose/cache_for_usage/codegen.dart b/website/docs/essentials/auto_dispose/cache_for_usage/codegen.dart index 7775e7930..a19f6a897 100644 --- a/website/docs/essentials/auto_dispose/cache_for_usage/codegen.dart +++ b/website/docs/essentials/auto_dispose/cache_for_usage/codegen.dart @@ -9,7 +9,7 @@ part 'codegen.g.dart'; /* SNIPPET START */ @riverpod -Future example(ExampleRef ref) async { +Future example(Ref ref) async { // {@template cacheFor} /// Keeps the state alive for 5 minutes // {@endtemplate} diff --git a/website/docs/essentials/auto_dispose/cache_for_usage/codegen.g.dart b/website/docs/essentials/auto_dispose/cache_for_usage/codegen.g.dart index 00844f23c..4544d0d25 100644 --- a/website/docs/essentials/auto_dispose/cache_for_usage/codegen.g.dart +++ b/website/docs/essentials/auto_dispose/cache_for_usage/codegen.g.dart @@ -8,17 +8,15 @@ part of 'codegen.dart'; // RiverpodGenerator // ************************************************************************** -typedef ExampleRef = Ref>; - @ProviderFor(example) const exampleProvider = ExampleProvider._(); final class ExampleProvider extends $FunctionalProvider, FutureOr> - with $FutureModifier, $FutureProvider { + with $FutureModifier, $FutureProvider { const ExampleProvider._( {FutureOr Function( - ExampleRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -32,7 +30,7 @@ final class ExampleProvider ); final FutureOr Function( - ExampleRef ref, + Ref ref, )? _createCb; @override @@ -46,20 +44,20 @@ final class ExampleProvider @override ExampleProvider $copyWithCreate( FutureOr Function( - ExampleRef ref, + Ref ref, ) create, ) { return ExampleProvider._(create: create); } @override - FutureOr create(ExampleRef ref) { + FutureOr create(Ref ref) { final _$cb = _createCb ?? example; return _$cb(ref); } } -String _$exampleHash() => r'3ff29b1cd8fa864286a2a04e39adf1c8589b4275'; +String _$exampleHash() => r'7721b15eade2919325624bb7c4fd0bfb0cfc3e68'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/essentials/auto_dispose/codegen_keep_alive.dart b/website/docs/essentials/auto_dispose/codegen_keep_alive.dart index 67b34d0bf..74af13186 100644 --- a/website/docs/essentials/auto_dispose/codegen_keep_alive.dart +++ b/website/docs/essentials/auto_dispose/codegen_keep_alive.dart @@ -8,6 +8,6 @@ part 'codegen_keep_alive.g.dart'; // the automatic state destruction // {@endtemplate} @Riverpod(keepAlive: true) -int example(ExampleRef ref) { +int example(Ref ref) { return 0; } diff --git a/website/docs/essentials/auto_dispose/codegen_keep_alive.g.dart b/website/docs/essentials/auto_dispose/codegen_keep_alive.g.dart index cf88fefa9..575faac55 100644 --- a/website/docs/essentials/auto_dispose/codegen_keep_alive.g.dart +++ b/website/docs/essentials/auto_dispose/codegen_keep_alive.g.dart @@ -8,16 +8,14 @@ part of 'codegen_keep_alive.dart'; // RiverpodGenerator // ************************************************************************** -typedef ExampleRef = Ref; - @ProviderFor(example) const exampleProvider = ExampleProvider._(); final class ExampleProvider extends $FunctionalProvider - with $Provider { + with $Provider { const ExampleProvider._( {int Function( - ExampleRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -31,7 +29,7 @@ final class ExampleProvider extends $FunctionalProvider ); final int Function( - ExampleRef ref, + Ref ref, )? _createCb; @override @@ -53,20 +51,20 @@ final class ExampleProvider extends $FunctionalProvider @override ExampleProvider $copyWithCreate( int Function( - ExampleRef ref, + Ref ref, ) create, ) { return ExampleProvider._(create: create); } @override - int create(ExampleRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? example; return _$cb(ref); } } -String _$exampleHash() => r'78f9426f6cbda80564387a9db8cd02368d890a85'; +String _$exampleHash() => r'd11e74682b7fd8010a0c2815b780a44a15b7a3da'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/essentials/auto_dispose/invalidate_family_example/codegen.dart b/website/docs/essentials/auto_dispose/invalidate_family_example/codegen.dart index 73f432104..fd347f6e4 100644 --- a/website/docs/essentials/auto_dispose/invalidate_family_example/codegen.dart +++ b/website/docs/essentials/auto_dispose/invalidate_family_example/codegen.dart @@ -9,7 +9,7 @@ late WidgetRef ref; /* SNIPPET START */ @riverpod -String label(LabelRef ref, String userName) { +String label(Ref ref, String userName) { return 'Hello $userName'; } diff --git a/website/docs/essentials/auto_dispose/invalidate_family_example/codegen.g.dart b/website/docs/essentials/auto_dispose/invalidate_family_example/codegen.g.dart index 875115020..f63db73da 100644 --- a/website/docs/essentials/auto_dispose/invalidate_family_example/codegen.g.dart +++ b/website/docs/essentials/auto_dispose/invalidate_family_example/codegen.g.dart @@ -8,18 +8,16 @@ part of 'codegen.dart'; // RiverpodGenerator // ************************************************************************** -typedef LabelRef = Ref; - @ProviderFor(label) const labelProvider = LabelFamily._(); final class LabelProvider extends $FunctionalProvider - with $Provider { + with $Provider { const LabelProvider._( {required LabelFamily super.from, required String super.argument, String Function( - LabelRef ref, + Ref ref, String userName, )? create}) : _createCb = create, @@ -32,7 +30,7 @@ final class LabelProvider extends $FunctionalProvider ); final String Function( - LabelRef ref, + Ref ref, String userName, )? _createCb; @@ -62,7 +60,7 @@ final class LabelProvider extends $FunctionalProvider @override LabelProvider $copyWithCreate( String Function( - LabelRef ref, + Ref ref, ) create, ) { return LabelProvider._( @@ -76,7 +74,7 @@ final class LabelProvider extends $FunctionalProvider } @override - String create(LabelRef ref) { + String create(Ref ref) { final _$cb = _createCb ?? label; final argument = this.argument as String; return _$cb( @@ -96,7 +94,7 @@ final class LabelProvider extends $FunctionalProvider } } -String _$labelHash() => r'20aa8ce0231205540f466f91259732bd86953c64'; +String _$labelHash() => r'c53d17dd111313633bd7ca6d6cf6b48dded58ca5'; final class LabelFamily extends Family { const LabelFamily._() @@ -122,7 +120,7 @@ final class LabelFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( String Function( - LabelRef ref, + Ref ref, String args, ) create, ) { @@ -141,4 +139,4 @@ final class LabelFamily extends Family { } } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/essentials/auto_dispose/keep_alive/codegen.dart b/website/docs/essentials/auto_dispose/keep_alive/codegen.dart index 83f4c8a59..a3f17cc7c 100644 --- a/website/docs/essentials/auto_dispose/keep_alive/codegen.dart +++ b/website/docs/essentials/auto_dispose/keep_alive/codegen.dart @@ -7,7 +7,7 @@ part 'codegen.g.dart'; /* SNIPPET START */ @riverpod -Future example(ExampleRef ref) async { +Future example(Ref ref) async { final response = await http.get(Uri.parse('https://example.com')); // {@template keepAlive} // We keep the provider alive only after the request has successfully completed. diff --git a/website/docs/essentials/auto_dispose/keep_alive/codegen.g.dart b/website/docs/essentials/auto_dispose/keep_alive/codegen.g.dart index 4a1969448..79e5e3df4 100644 --- a/website/docs/essentials/auto_dispose/keep_alive/codegen.g.dart +++ b/website/docs/essentials/auto_dispose/keep_alive/codegen.g.dart @@ -8,17 +8,15 @@ part of 'codegen.dart'; // RiverpodGenerator // ************************************************************************** -typedef ExampleRef = Ref>; - @ProviderFor(example) const exampleProvider = ExampleProvider._(); final class ExampleProvider extends $FunctionalProvider, FutureOr> - with $FutureModifier, $FutureProvider { + with $FutureModifier, $FutureProvider { const ExampleProvider._( {FutureOr Function( - ExampleRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -32,7 +30,7 @@ final class ExampleProvider ); final FutureOr Function( - ExampleRef ref, + Ref ref, )? _createCb; @override @@ -46,20 +44,20 @@ final class ExampleProvider @override ExampleProvider $copyWithCreate( FutureOr Function( - ExampleRef ref, + Ref ref, ) create, ) { return ExampleProvider._(create: create); } @override - FutureOr create(ExampleRef ref) { + FutureOr create(Ref ref) { final _$cb = _createCb ?? example; return _$cb(ref); } } -String _$exampleHash() => r'4fa856c55e84da9525dcecfab1c897e61456325b'; +String _$exampleHash() => r'47fbbb04e2e5aef4d37c361939a7df40ef05e851'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/essentials/auto_dispose/on_dispose_example/codegen.dart b/website/docs/essentials/auto_dispose/on_dispose_example/codegen.dart index 3f586a185..a7eafb658 100644 --- a/website/docs/essentials/auto_dispose/on_dispose_example/codegen.dart +++ b/website/docs/essentials/auto_dispose/on_dispose_example/codegen.dart @@ -7,11 +7,11 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'codegen.g.dart'; @riverpod -int other(OtherRef ref) => 0; +int other(Ref ref) => 0; /* SNIPPET START */ @riverpod -Stream example(ExampleRef ref) { +Stream example(Ref ref) { final controller = StreamController(); // {@template onDispose} diff --git a/website/docs/essentials/auto_dispose/on_dispose_example/codegen.g.dart b/website/docs/essentials/auto_dispose/on_dispose_example/codegen.g.dart index 2b3a36b69..9e4f5ef90 100644 --- a/website/docs/essentials/auto_dispose/on_dispose_example/codegen.g.dart +++ b/website/docs/essentials/auto_dispose/on_dispose_example/codegen.g.dart @@ -8,16 +8,14 @@ part of 'codegen.dart'; // RiverpodGenerator // ************************************************************************** -typedef OtherRef = Ref; - @ProviderFor(other) const otherProvider = OtherProvider._(); final class OtherProvider extends $FunctionalProvider - with $Provider { + with $Provider { const OtherProvider._( {int Function( - OtherRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -31,7 +29,7 @@ final class OtherProvider extends $FunctionalProvider ); final int Function( - OtherRef ref, + Ref ref, )? _createCb; @override @@ -53,32 +51,30 @@ final class OtherProvider extends $FunctionalProvider @override OtherProvider $copyWithCreate( int Function( - OtherRef ref, + Ref ref, ) create, ) { return OtherProvider._(create: create); } @override - int create(OtherRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? other; return _$cb(ref); } } -String _$otherHash() => r'b23696171643dfbab23d167ed9b5ab0639e6a86c'; - -typedef ExampleRef = Ref>; +String _$otherHash() => r'5d27b2b1b1c6bd17ba0844f74ade2088611be371'; @ProviderFor(example) const exampleProvider = ExampleProvider._(); final class ExampleProvider extends $FunctionalProvider, Stream> - with $FutureModifier, $StreamProvider { + with $FutureModifier, $StreamProvider { const ExampleProvider._( {Stream Function( - ExampleRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -92,7 +88,7 @@ final class ExampleProvider ); final Stream Function( - ExampleRef ref, + Ref ref, )? _createCb; @override @@ -106,20 +102,20 @@ final class ExampleProvider @override ExampleProvider $copyWithCreate( Stream Function( - ExampleRef ref, + Ref ref, ) create, ) { return ExampleProvider._(create: create); } @override - Stream create(ExampleRef ref) { + Stream create(Ref ref) { final _$cb = _createCb ?? example; return _$cb(ref); } } -String _$exampleHash() => r'29f92958e0d0e3f13ac033e92cd2e4072339c7db'; +String _$exampleHash() => r'012c40f45aaeb96633a857d1407f04d25255f32f'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/essentials/combining_requests.mdx b/website/docs/essentials/combining_requests.mdx index ccd32c941..c629dfbd7 100644 --- a/website/docs/essentials/combining_requests.mdx +++ b/website/docs/essentials/combining_requests.mdx @@ -1,6 +1,6 @@ --- title: Combining requests -version: 2 +version: 3 --- import { Link } from "/src/components/Link"; @@ -104,7 +104,7 @@ phase of the provider. This includes "listener" callbacks or methods on Notifier ::: -## The `ref.listen`/`listenSelf` methods. +## The `ref.listen` methods. The `ref.listen` method is an alternative to `ref.watch`. It is similar to your traditional "listen"/"addListener" method. It takes a provider diff --git a/website/docs/essentials/combining_requests/functional_ref/codegen.dart b/website/docs/essentials/combining_requests/functional_ref/codegen.dart index f51c3c34b..e776d8c31 100644 --- a/website/docs/essentials/combining_requests/functional_ref/codegen.dart +++ b/website/docs/essentials/combining_requests/functional_ref/codegen.dart @@ -5,11 +5,11 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'codegen.g.dart'; @riverpod -int other(OtherRef ref) => 0; +int other(Ref ref) => 0; /* SNIPPET START */ @riverpod -int example(ExampleRef ref) { +int example(Ref ref) { // {@template provider} // "Ref" can be used here to read other providers // {@endtemplate} diff --git a/website/docs/essentials/combining_requests/functional_ref/codegen.g.dart b/website/docs/essentials/combining_requests/functional_ref/codegen.g.dart index fa3bc6d72..c4f8ef7f1 100644 --- a/website/docs/essentials/combining_requests/functional_ref/codegen.g.dart +++ b/website/docs/essentials/combining_requests/functional_ref/codegen.g.dart @@ -8,16 +8,14 @@ part of 'codegen.dart'; // RiverpodGenerator // ************************************************************************** -typedef OtherRef = Ref; - @ProviderFor(other) const otherProvider = OtherProvider._(); final class OtherProvider extends $FunctionalProvider - with $Provider { + with $Provider { const OtherProvider._( {int Function( - OtherRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -31,7 +29,7 @@ final class OtherProvider extends $FunctionalProvider ); final int Function( - OtherRef ref, + Ref ref, )? _createCb; @override @@ -53,31 +51,29 @@ final class OtherProvider extends $FunctionalProvider @override OtherProvider $copyWithCreate( int Function( - OtherRef ref, + Ref ref, ) create, ) { return OtherProvider._(create: create); } @override - int create(OtherRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? other; return _$cb(ref); } } -String _$otherHash() => r'b23696171643dfbab23d167ed9b5ab0639e6a86c'; - -typedef ExampleRef = Ref; +String _$otherHash() => r'5d27b2b1b1c6bd17ba0844f74ade2088611be371'; @ProviderFor(example) const exampleProvider = ExampleProvider._(); final class ExampleProvider extends $FunctionalProvider - with $Provider { + with $Provider { const ExampleProvider._( {int Function( - ExampleRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -91,7 +87,7 @@ final class ExampleProvider extends $FunctionalProvider ); final int Function( - ExampleRef ref, + Ref ref, )? _createCb; @override @@ -113,20 +109,20 @@ final class ExampleProvider extends $FunctionalProvider @override ExampleProvider $copyWithCreate( int Function( - ExampleRef ref, + Ref ref, ) create, ) { return ExampleProvider._(create: create); } @override - int create(ExampleRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? example; return _$cb(ref); } } -String _$exampleHash() => r'4429d7d3bb2b31fea4cc42c2f2af02d3f3d10693'; +String _$exampleHash() => r'6115819b119e2f16f22c69aae827632e3b585775'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/essentials/combining_requests/listen_example/codegen.dart b/website/docs/essentials/combining_requests/listen_example/codegen.dart index 7a417d13b..8de5958a6 100644 --- a/website/docs/essentials/combining_requests/listen_example/codegen.dart +++ b/website/docs/essentials/combining_requests/listen_example/codegen.dart @@ -5,11 +5,11 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'codegen.g.dart'; @riverpod -int other(OtherRef ref) => 0; +int other(Ref ref) => 0; /* SNIPPET START */ @riverpod -int example(ExampleRef ref) { +int example(Ref ref) { ref.listen(otherProvider, (previous, next) { print('Changed from: $previous, next: $next'); }); diff --git a/website/docs/essentials/combining_requests/listen_example/codegen.g.dart b/website/docs/essentials/combining_requests/listen_example/codegen.g.dart index 164310b3c..1e04eee5a 100644 --- a/website/docs/essentials/combining_requests/listen_example/codegen.g.dart +++ b/website/docs/essentials/combining_requests/listen_example/codegen.g.dart @@ -8,16 +8,14 @@ part of 'codegen.dart'; // RiverpodGenerator // ************************************************************************** -typedef OtherRef = Ref; - @ProviderFor(other) const otherProvider = OtherProvider._(); final class OtherProvider extends $FunctionalProvider - with $Provider { + with $Provider { const OtherProvider._( {int Function( - OtherRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -31,7 +29,7 @@ final class OtherProvider extends $FunctionalProvider ); final int Function( - OtherRef ref, + Ref ref, )? _createCb; @override @@ -53,31 +51,29 @@ final class OtherProvider extends $FunctionalProvider @override OtherProvider $copyWithCreate( int Function( - OtherRef ref, + Ref ref, ) create, ) { return OtherProvider._(create: create); } @override - int create(OtherRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? other; return _$cb(ref); } } -String _$otherHash() => r'b23696171643dfbab23d167ed9b5ab0639e6a86c'; - -typedef ExampleRef = Ref; +String _$otherHash() => r'5d27b2b1b1c6bd17ba0844f74ade2088611be371'; @ProviderFor(example) const exampleProvider = ExampleProvider._(); final class ExampleProvider extends $FunctionalProvider - with $Provider { + with $Provider { const ExampleProvider._( {int Function( - ExampleRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -91,7 +87,7 @@ final class ExampleProvider extends $FunctionalProvider ); final int Function( - ExampleRef ref, + Ref ref, )? _createCb; @override @@ -113,20 +109,20 @@ final class ExampleProvider extends $FunctionalProvider @override ExampleProvider $copyWithCreate( int Function( - ExampleRef ref, + Ref ref, ) create, ) { return ExampleProvider._(create: create); } @override - int create(ExampleRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? example; return _$cb(ref); } } -String _$exampleHash() => r'd614303f372e06e6ab96035affc4c07a53b28741'; +String _$exampleHash() => r'42a795719de4bd2ec79f315aaaf87d1c89ebf063'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/essentials/combining_requests/notifier_ref/codegen.dart b/website/docs/essentials/combining_requests/notifier_ref/codegen.dart index 1f9922ff4..c184574c3 100644 --- a/website/docs/essentials/combining_requests/notifier_ref/codegen.dart +++ b/website/docs/essentials/combining_requests/notifier_ref/codegen.dart @@ -5,7 +5,7 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'codegen.g.dart'; @riverpod -int other(OtherRef ref) => 0; +int other(Ref ref) => 0; /* SNIPPET START */ @riverpod diff --git a/website/docs/essentials/combining_requests/notifier_ref/codegen.g.dart b/website/docs/essentials/combining_requests/notifier_ref/codegen.g.dart index 04806fe6d..6ac7315d9 100644 --- a/website/docs/essentials/combining_requests/notifier_ref/codegen.g.dart +++ b/website/docs/essentials/combining_requests/notifier_ref/codegen.g.dart @@ -8,16 +8,14 @@ part of 'codegen.dart'; // RiverpodGenerator // ************************************************************************** -typedef OtherRef = Ref; - @ProviderFor(other) const otherProvider = OtherProvider._(); final class OtherProvider extends $FunctionalProvider - with $Provider { + with $Provider { const OtherProvider._( {int Function( - OtherRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -31,7 +29,7 @@ final class OtherProvider extends $FunctionalProvider ); final int Function( - OtherRef ref, + Ref ref, )? _createCb; @override @@ -53,20 +51,20 @@ final class OtherProvider extends $FunctionalProvider @override OtherProvider $copyWithCreate( int Function( - OtherRef ref, + Ref ref, ) create, ) { return OtherProvider._(create: create); } @override - int create(OtherRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? other; return _$cb(ref); } } -String _$otherHash() => r'b23696171643dfbab23d167ed9b5ab0639e6a86c'; +String _$otherHash() => r'5d27b2b1b1c6bd17ba0844f74ade2088611be371'; @ProviderFor(Example) const exampleProvider = ExampleProvider._(); @@ -114,7 +112,7 @@ final class ExampleProvider extends $NotifierProvider { @override ExampleProvider $copyWithBuild( int Function( - Ref, + Ref, Example, ) build, ) { @@ -138,4 +136,4 @@ abstract class _$Example extends $Notifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/essentials/combining_requests/read_example/codegen.dart b/website/docs/essentials/combining_requests/read_example/codegen.dart index 8ae074d63..0e3e09226 100644 --- a/website/docs/essentials/combining_requests/read_example/codegen.dart +++ b/website/docs/essentials/combining_requests/read_example/codegen.dart @@ -5,7 +5,7 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'codegen.g.dart'; @riverpod -int other(OtherRef ref) => 0; +int other(Ref ref) => 0; /* SNIPPET START */ @riverpod diff --git a/website/docs/essentials/combining_requests/read_example/codegen.g.dart b/website/docs/essentials/combining_requests/read_example/codegen.g.dart index 21ea570da..e34ca3d31 100644 --- a/website/docs/essentials/combining_requests/read_example/codegen.g.dart +++ b/website/docs/essentials/combining_requests/read_example/codegen.g.dart @@ -8,16 +8,14 @@ part of 'codegen.dart'; // RiverpodGenerator // ************************************************************************** -typedef OtherRef = Ref; - @ProviderFor(other) const otherProvider = OtherProvider._(); final class OtherProvider extends $FunctionalProvider - with $Provider { + with $Provider { const OtherProvider._( {int Function( - OtherRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -31,7 +29,7 @@ final class OtherProvider extends $FunctionalProvider ); final int Function( - OtherRef ref, + Ref ref, )? _createCb; @override @@ -53,20 +51,20 @@ final class OtherProvider extends $FunctionalProvider @override OtherProvider $copyWithCreate( int Function( - OtherRef ref, + Ref ref, ) create, ) { return OtherProvider._(create: create); } @override - int create(OtherRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? other; return _$cb(ref); } } -String _$otherHash() => r'b23696171643dfbab23d167ed9b5ab0639e6a86c'; +String _$otherHash() => r'5d27b2b1b1c6bd17ba0844f74ade2088611be371'; @ProviderFor(MyNotifier) const myNotifierProvider = MyNotifierProvider._(); @@ -114,7 +112,7 @@ final class MyNotifierProvider extends $NotifierProvider { @override MyNotifierProvider $copyWithBuild( int Function( - Ref, + Ref, MyNotifier, ) build, ) { @@ -138,4 +136,4 @@ abstract class _$MyNotifier extends $Notifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/essentials/combining_requests/watch_example/codegen.dart b/website/docs/essentials/combining_requests/watch_example/codegen.dart index c800279d4..55a72d895 100644 --- a/website/docs/essentials/combining_requests/watch_example/codegen.dart +++ b/website/docs/essentials/combining_requests/watch_example/codegen.dart @@ -2,6 +2,7 @@ import 'dart:convert'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:http/http.dart' as http; import 'package:riverpod/riverpod.dart'; import 'package:riverpod_annotation/riverpod_annotation.dart'; @@ -14,7 +15,7 @@ const someStream = Stream<({double longitude, double latitude})>.empty(); /* SNIPPET START */ @riverpod -Stream<({double longitude, double latitude})> location(LocationRef ref) { +Stream<({double longitude, double latitude})> location(Ref ref) { // {@template provider} // TO-DO: Return a stream which obtains the current location // {@endtemplate} @@ -22,7 +23,7 @@ Stream<({double longitude, double latitude})> location(LocationRef ref) { } @riverpod -Future> restaurantsNearMe(RestaurantsNearMeRef ref) async { +Future> restaurantsNearMe(Ref ref) async { // {@template watch} // We use "ref.watch" to obtain the latest location. // By specifying that ".future" after the provider, our code will wait diff --git a/website/docs/essentials/combining_requests/watch_example/codegen.g.dart b/website/docs/essentials/combining_requests/watch_example/codegen.g.dart index f2c48aa58..9fb17601e 100644 --- a/website/docs/essentials/combining_requests/watch_example/codegen.g.dart +++ b/website/docs/essentials/combining_requests/watch_example/codegen.g.dart @@ -8,8 +8,6 @@ part of 'codegen.dart'; // RiverpodGenerator // ************************************************************************** -typedef LocationRef = Ref>; - @ProviderFor(location) const locationProvider = LocationProvider._(); @@ -18,10 +16,10 @@ final class LocationProvider extends $FunctionalProvider< Stream<({double longitude, double latitude})>> with $FutureModifier<({double longitude, double latitude})>, - $StreamProvider<({double longitude, double latitude}), LocationRef> { + $StreamProvider<({double longitude, double latitude})> { const LocationProvider._( {Stream<({double longitude, double latitude})> Function( - LocationRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -35,7 +33,7 @@ final class LocationProvider extends $FunctionalProvider< ); final Stream<({double longitude, double latitude})> Function( - LocationRef ref, + Ref ref, )? _createCb; @override @@ -50,34 +48,30 @@ final class LocationProvider extends $FunctionalProvider< @override LocationProvider $copyWithCreate( Stream<({double longitude, double latitude})> Function( - LocationRef ref, + Ref ref, ) create, ) { return LocationProvider._(create: create); } @override - Stream<({double longitude, double latitude})> create(LocationRef ref) { + Stream<({double longitude, double latitude})> create(Ref ref) { final _$cb = _createCb ?? location; return _$cb(ref); } } -String _$locationHash() => r'22e666f1e1ce04ce03d8f8d5652e25b54c1d1af3'; - -typedef RestaurantsNearMeRef = Ref>>; +String _$locationHash() => r'39328e5d0ec2b97acec14f1aba6c8db3f24f46a8'; @ProviderFor(restaurantsNearMe) const restaurantsNearMeProvider = RestaurantsNearMeProvider._(); final class RestaurantsNearMeProvider extends $FunctionalProvider< AsyncValue>, FutureOr>> - with - $FutureModifier>, - $FutureProvider, RestaurantsNearMeRef> { + with $FutureModifier>, $FutureProvider> { const RestaurantsNearMeProvider._( {FutureOr> Function( - RestaurantsNearMeRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -91,7 +85,7 @@ final class RestaurantsNearMeProvider extends $FunctionalProvider< ); final FutureOr> Function( - RestaurantsNearMeRef ref, + Ref ref, )? _createCb; @override @@ -106,20 +100,20 @@ final class RestaurantsNearMeProvider extends $FunctionalProvider< @override RestaurantsNearMeProvider $copyWithCreate( FutureOr> Function( - RestaurantsNearMeRef ref, + Ref ref, ) create, ) { return RestaurantsNearMeProvider._(create: create); } @override - FutureOr> create(RestaurantsNearMeRef ref) { + FutureOr> create(Ref ref) { final _$cb = _createCb ?? restaurantsNearMe; return _$cb(ref); } } -String _$restaurantsNearMeHash() => r'dd49cc1e6f16abb34dd15286d171e322c06b93b8'; +String _$restaurantsNearMeHash() => r'f577a4362db45208cd34f499d73f39f284807d13'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/essentials/combining_requests/watch_placement/codegen.dart b/website/docs/essentials/combining_requests/watch_placement/codegen.dart index 36f97a531..d5a9cd653 100644 --- a/website/docs/essentials/combining_requests/watch_placement/codegen.dart +++ b/website/docs/essentials/combining_requests/watch_placement/codegen.dart @@ -6,11 +6,11 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'codegen.g.dart'; @riverpod -int other(OtherRef ref) => 0; +int other(Ref ref) => 0; /* SNIPPET START */ @riverpod -int example(ExampleRef ref) { +int example(Ref ref) { ref.watch(otherProvider); // Good! ref.onDispose(() => ref.watch(otherProvider)); // Bad! diff --git a/website/docs/essentials/combining_requests/watch_placement/codegen.g.dart b/website/docs/essentials/combining_requests/watch_placement/codegen.g.dart index 88dd570d3..2647a21b1 100644 --- a/website/docs/essentials/combining_requests/watch_placement/codegen.g.dart +++ b/website/docs/essentials/combining_requests/watch_placement/codegen.g.dart @@ -8,16 +8,14 @@ part of 'codegen.dart'; // RiverpodGenerator // ************************************************************************** -typedef OtherRef = Ref; - @ProviderFor(other) const otherProvider = OtherProvider._(); final class OtherProvider extends $FunctionalProvider - with $Provider { + with $Provider { const OtherProvider._( {int Function( - OtherRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -31,7 +29,7 @@ final class OtherProvider extends $FunctionalProvider ); final int Function( - OtherRef ref, + Ref ref, )? _createCb; @override @@ -53,31 +51,29 @@ final class OtherProvider extends $FunctionalProvider @override OtherProvider $copyWithCreate( int Function( - OtherRef ref, + Ref ref, ) create, ) { return OtherProvider._(create: create); } @override - int create(OtherRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? other; return _$cb(ref); } } -String _$otherHash() => r'b23696171643dfbab23d167ed9b5ab0639e6a86c'; - -typedef ExampleRef = Ref; +String _$otherHash() => r'5d27b2b1b1c6bd17ba0844f74ade2088611be371'; @ProviderFor(example) const exampleProvider = ExampleProvider._(); final class ExampleProvider extends $FunctionalProvider - with $Provider { + with $Provider { const ExampleProvider._( {int Function( - ExampleRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -91,7 +87,7 @@ final class ExampleProvider extends $FunctionalProvider ); final int Function( - ExampleRef ref, + Ref ref, )? _createCb; @override @@ -113,20 +109,20 @@ final class ExampleProvider extends $FunctionalProvider @override ExampleProvider $copyWithCreate( int Function( - ExampleRef ref, + Ref ref, ) create, ) { return ExampleProvider._(create: create); } @override - int create(ExampleRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? example; return _$cb(ref); } } -String _$exampleHash() => r'd4d63f5cf1aaec5b7c6a19e6fee18ddf070147ec'; +String _$exampleHash() => r'fed2d2be4787bc4a715efa198a89a297967b54a1'; @ProviderFor(MyNotifier) const myNotifierProvider = MyNotifierProvider._(); @@ -174,7 +170,7 @@ final class MyNotifierProvider extends $NotifierProvider { @override MyNotifierProvider $copyWithBuild( int Function( - Ref, + Ref, MyNotifier, ) build, ) { @@ -198,4 +194,4 @@ abstract class _$MyNotifier extends $Notifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/essentials/eager_initialization/require_value/codegen.dart b/website/docs/essentials/eager_initialization/require_value/codegen.dart index 287f18063..314f78b23 100644 --- a/website/docs/essentials/eager_initialization/require_value/codegen.dart +++ b/website/docs/essentials/eager_initialization/require_value/codegen.dart @@ -11,7 +11,7 @@ part 'codegen.g.dart'; // An eagerly initialized provider. // {@endtemplate} @riverpod -Future example(ExampleRef ref) async => 'Hello world'; +Future example(Ref ref) async => 'Hello world'; class MyConsumer extends ConsumerWidget { @override diff --git a/website/docs/essentials/eager_initialization/require_value/codegen.g.dart b/website/docs/essentials/eager_initialization/require_value/codegen.g.dart index 4eaf1bcf3..d317584cf 100644 --- a/website/docs/essentials/eager_initialization/require_value/codegen.g.dart +++ b/website/docs/essentials/eager_initialization/require_value/codegen.g.dart @@ -8,17 +8,15 @@ part of 'codegen.dart'; // RiverpodGenerator // ************************************************************************** -typedef ExampleRef = Ref>; - @ProviderFor(example) const exampleProvider = ExampleProvider._(); final class ExampleProvider extends $FunctionalProvider, FutureOr> - with $FutureModifier, $FutureProvider { + with $FutureModifier, $FutureProvider { const ExampleProvider._( {FutureOr Function( - ExampleRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -32,7 +30,7 @@ final class ExampleProvider ); final FutureOr Function( - ExampleRef ref, + Ref ref, )? _createCb; @override @@ -46,20 +44,20 @@ final class ExampleProvider @override ExampleProvider $copyWithCreate( FutureOr Function( - ExampleRef ref, + Ref ref, ) create, ) { return ExampleProvider._(create: create); } @override - FutureOr create(ExampleRef ref) { + FutureOr create(Ref ref) { final _$cb = _createCb ?? example; return _$cb(ref); } } -String _$exampleHash() => r'd421d08db0ee9d10af5521159561135d8c5fa57c'; +String _$exampleHash() => r'8768b72378809f5cb6ae94b65493cbb49bd23b77'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/essentials/first_request.mdx b/website/docs/essentials/first_request.mdx index 8d52f4205..9b64ad3d7 100644 --- a/website/docs/essentials/first_request.mdx +++ b/website/docs/essentials/first_request.mdx @@ -179,7 +179,7 @@ Subsequent reads will not call the function again, but instead return the cached } `} @@ -219,7 +219,7 @@ Subsequent reads will not call the function again, but instead return the cached }, { offset: 28, - length: 17, + length: 7, label: "Ref", description: <> diff --git a/website/docs/essentials/first_request/codegen/provider.dart b/website/docs/essentials/first_request/codegen/provider.dart index 0ba64ec53..9a68b34be 100644 --- a/website/docs/essentials/first_request/codegen/provider.dart +++ b/website/docs/essentials/first_request/codegen/provider.dart @@ -15,7 +15,7 @@ part 'provider.g.dart'; /// which will cache the result of this function. // {@endtemplate} @riverpod -Future activity(ActivityRef ref) async { +Future activity(Ref ref) async { // {@template response} // Using package:http, we fetch a random activity from the Bored API. // {@endtemplate} diff --git a/website/docs/essentials/first_request/codegen/provider.g.dart b/website/docs/essentials/first_request/codegen/provider.g.dart index 466fbdd3f..f507b27f8 100644 --- a/website/docs/essentials/first_request/codegen/provider.g.dart +++ b/website/docs/essentials/first_request/codegen/provider.g.dart @@ -8,11 +8,6 @@ part of 'provider.dart'; // RiverpodGenerator // ************************************************************************** -/// This will create a provider named `activityProvider` -/// which will cache the result of this function. -// {@endtemplate} -typedef ActivityRef = Ref>; - /// This will create a provider named `activityProvider` /// which will cache the result of this function. // {@endtemplate} @@ -24,13 +19,13 @@ const activityProvider = ActivityProvider._(); // {@endtemplate} final class ActivityProvider extends $FunctionalProvider, FutureOr> - with $FutureModifier, $FutureProvider { + with $FutureModifier, $FutureProvider { /// This will create a provider named `activityProvider` /// which will cache the result of this function. // {@endtemplate} const ActivityProvider._( {FutureOr Function( - ActivityRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -44,7 +39,7 @@ final class ActivityProvider ); final FutureOr Function( - ActivityRef ref, + Ref ref, )? _createCb; @override @@ -58,20 +53,20 @@ final class ActivityProvider @override ActivityProvider $copyWithCreate( FutureOr Function( - ActivityRef ref, + Ref ref, ) create, ) { return ActivityProvider._(create: create); } @override - FutureOr create(ActivityRef ref) { + FutureOr create(Ref ref) { final _$cb = _createCb ?? activity; return _$cb(ref); } } -String _$activityHash() => r'636cd5510e09cbfc46f31b74a70d9e98c89e95a4'; +String _$activityHash() => r'c90b5d6502e5e4c31a2fa8c974683171cad8f38f'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/essentials/passing_args/family/codegen.dart b/website/docs/essentials/passing_args/family/codegen.dart index b5e4cee05..ab4743a20 100644 --- a/website/docs/essentials/passing_args/family/codegen.dart +++ b/website/docs/essentials/passing_args/family/codegen.dart @@ -12,7 +12,7 @@ Future fetchActivity() => throw UnimplementedError(); /* SNIPPET START */ @riverpod Future activity( - ActivityRef ref, + Ref ref, // {@template codegen_activityType} // We can add arguments to the provider. // The type of the parameter can be whatever you wish. diff --git a/website/docs/essentials/passing_args/family/codegen.g.dart b/website/docs/essentials/passing_args/family/codegen.g.dart index 46a54342a..51bf760fb 100644 --- a/website/docs/essentials/passing_args/family/codegen.g.dart +++ b/website/docs/essentials/passing_args/family/codegen.g.dart @@ -8,19 +8,17 @@ part of 'codegen.dart'; // RiverpodGenerator // ************************************************************************** -typedef ActivityRef = Ref>; - @ProviderFor(activity) const activityProvider = ActivityFamily._(); final class ActivityProvider extends $FunctionalProvider, FutureOr> - with $FutureModifier, $FutureProvider { + with $FutureModifier, $FutureProvider { const ActivityProvider._( {required ActivityFamily super.from, required String super.argument, FutureOr Function( - ActivityRef ref, + Ref ref, String activityType, )? create}) : _createCb = create, @@ -33,7 +31,7 @@ final class ActivityProvider ); final FutureOr Function( - ActivityRef ref, + Ref ref, String activityType, )? _createCb; @@ -55,7 +53,7 @@ final class ActivityProvider @override ActivityProvider $copyWithCreate( FutureOr Function( - ActivityRef ref, + Ref ref, ) create, ) { return ActivityProvider._( @@ -69,7 +67,7 @@ final class ActivityProvider } @override - FutureOr create(ActivityRef ref) { + FutureOr create(Ref ref) { final _$cb = _createCb ?? activity; final argument = this.argument as String; return _$cb( @@ -89,7 +87,7 @@ final class ActivityProvider } } -String _$activityHash() => r'cb76e67cd45f1823d3ed497a235be53819ce2eaf'; +String _$activityHash() => r'6c815736c0d2b40a92695adcd78516534d7ac2fc'; final class ActivityFamily extends Family { const ActivityFamily._() @@ -115,7 +113,7 @@ final class ActivityFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( FutureOr Function( - ActivityRef ref, + Ref ref, String args, ) create, ) { @@ -184,7 +182,7 @@ final class ActivityNotifier2Provider @override ActivityNotifier2Provider $copyWithBuild( FutureOr Function( - Ref>, + Ref, ActivityNotifier2, ) build, ) { @@ -256,8 +254,8 @@ final class ActivityNotifier2Family extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( - FutureOr Function(Ref> ref, - ActivityNotifier2 notifier, String argument) + FutureOr Function( + Ref ref, ActivityNotifier2 notifier, String argument) build, ) { return $FamilyOverride( @@ -290,4 +288,4 @@ abstract class _$ActivityNotifier2 extends $AsyncNotifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/essentials/passing_args/no_arg_provider/codegen.dart b/website/docs/essentials/passing_args/no_arg_provider/codegen.dart index 7e2f1ded9..da1c34adb 100644 --- a/website/docs/essentials/passing_args/no_arg_provider/codegen.dart +++ b/website/docs/essentials/passing_args/no_arg_provider/codegen.dart @@ -13,7 +13,7 @@ FutureOr fetchActivity() => throw UnimplementedError(); // A "functional" provider // {@endtemplate} @riverpod -Future activity(ActivityRef ref) async { +Future activity(Ref ref) async { // {@template fetchActivity} // TODO: perform a network request to fetch an activity // {@endtemplate} diff --git a/website/docs/essentials/passing_args/no_arg_provider/codegen.g.dart b/website/docs/essentials/passing_args/no_arg_provider/codegen.g.dart index 56192f6e8..3dae20276 100644 --- a/website/docs/essentials/passing_args/no_arg_provider/codegen.g.dart +++ b/website/docs/essentials/passing_args/no_arg_provider/codegen.g.dart @@ -8,17 +8,15 @@ part of 'codegen.dart'; // RiverpodGenerator // ************************************************************************** -typedef ActivityRef = Ref>; - @ProviderFor(activity) const activityProvider = ActivityProvider._(); final class ActivityProvider extends $FunctionalProvider, FutureOr> - with $FutureModifier, $FutureProvider { + with $FutureModifier, $FutureProvider { const ActivityProvider._( {FutureOr Function( - ActivityRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -32,7 +30,7 @@ final class ActivityProvider ); final FutureOr Function( - ActivityRef ref, + Ref ref, )? _createCb; @override @@ -46,20 +44,20 @@ final class ActivityProvider @override ActivityProvider $copyWithCreate( FutureOr Function( - ActivityRef ref, + Ref ref, ) create, ) { return ActivityProvider._(create: create); } @override - FutureOr create(ActivityRef ref) { + FutureOr create(Ref ref) { final _$cb = _createCb ?? activity; return _$cb(ref); } } -String _$activityHash() => r'2f9496c5d70de9314c67e5c48ac44d8b149bc471'; +String _$activityHash() => r'7b532e70a92d6bc198900ca61f0e714c5484c34d'; @ProviderFor(ActivityNotifier2) const activityNotifier2Provider = ActivityNotifier2Provider._(); @@ -100,7 +98,7 @@ final class ActivityNotifier2Provider @override ActivityNotifier2Provider $copyWithBuild( FutureOr Function( - Ref>, + Ref, ActivityNotifier2, ) build, ) { @@ -124,4 +122,4 @@ abstract class _$ActivityNotifier2 extends $AsyncNotifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/essentials/side_effects/codegen/todo_list_notifier.g.dart b/website/docs/essentials/side_effects/codegen/todo_list_notifier.g.dart index 4e3b431dd..c2f3d90b1 100644 --- a/website/docs/essentials/side_effects/codegen/todo_list_notifier.g.dart +++ b/website/docs/essentials/side_effects/codegen/todo_list_notifier.g.dart @@ -62,7 +62,7 @@ final class TodoListProvider @override TodoListProvider $copyWithBuild( FutureOr> Function( - Ref>>, + Ref, TodoList, ) build, ) { @@ -86,4 +86,4 @@ abstract class _$TodoList extends $AsyncNotifier> { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/essentials/side_effects/codegen/todo_list_notifier_add_todo.g.dart b/website/docs/essentials/side_effects/codegen/todo_list_notifier_add_todo.g.dart index e42591301..6d57aa996 100644 --- a/website/docs/essentials/side_effects/codegen/todo_list_notifier_add_todo.g.dart +++ b/website/docs/essentials/side_effects/codegen/todo_list_notifier_add_todo.g.dart @@ -47,7 +47,7 @@ final class TodoListProvider @override TodoListProvider $copyWithBuild( FutureOr> Function( - Ref>>, + Ref, TodoList, ) build, ) { @@ -71,4 +71,4 @@ abstract class _$TodoList extends $AsyncNotifier> { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/essentials/side_effects/codegen/todo_list_provider.dart b/website/docs/essentials/side_effects/codegen/todo_list_provider.dart index 8e1b799e1..f0a84c83a 100644 --- a/website/docs/essentials/side_effects/codegen/todo_list_provider.dart +++ b/website/docs/essentials/side_effects/codegen/todo_list_provider.dart @@ -14,7 +14,7 @@ class Todo with _$Todo { /* SNIPPET START */ @riverpod -Future> todoList(TodoListRef ref) async { +Future> todoList(Ref ref) async { // {@template note} // Simulate a network request. This would normally come from a real API // {@endtemplate} diff --git a/website/docs/essentials/side_effects/codegen/todo_list_provider.g.dart b/website/docs/essentials/side_effects/codegen/todo_list_provider.g.dart index 811989448..2ac49cc27 100644 --- a/website/docs/essentials/side_effects/codegen/todo_list_provider.g.dart +++ b/website/docs/essentials/side_effects/codegen/todo_list_provider.g.dart @@ -8,17 +8,15 @@ part of 'todo_list_provider.dart'; // RiverpodGenerator // ************************************************************************** -typedef TodoListRef = Ref>>; - @ProviderFor(todoList) const todoListProvider = TodoListProvider._(); final class TodoListProvider extends $FunctionalProvider>, FutureOr>> - with $FutureModifier>, $FutureProvider, TodoListRef> { + with $FutureModifier>, $FutureProvider> { const TodoListProvider._( {FutureOr> Function( - TodoListRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -32,7 +30,7 @@ final class TodoListProvider ); final FutureOr> Function( - TodoListRef ref, + Ref ref, )? _createCb; @override @@ -46,20 +44,20 @@ final class TodoListProvider @override TodoListProvider $copyWithCreate( FutureOr> Function( - TodoListRef ref, + Ref ref, ) create, ) { return TodoListProvider._(create: create); } @override - FutureOr> create(TodoListRef ref) { + FutureOr> create(Ref ref) { final _$cb = _createCb ?? todoList; return _$cb(ref); } } -String _$todoListHash() => r'26b30307668c8feefa7cbe3c400b73e6edccbc39'; +String _$todoListHash() => r'79ea254a2b6239c9fbcc2b5e6f075a3e5b72598e'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/essentials/testing/notifier_mock/codegen.g.dart b/website/docs/essentials/testing/notifier_mock/codegen.g.dart index 860998b23..cdf362639 100644 --- a/website/docs/essentials/testing/notifier_mock/codegen.g.dart +++ b/website/docs/essentials/testing/notifier_mock/codegen.g.dart @@ -54,7 +54,7 @@ final class MyNotifierProvider extends $NotifierProvider { @override MyNotifierProvider $copyWithBuild( int Function( - Ref, + Ref, MyNotifier, ) build, ) { @@ -78,4 +78,4 @@ abstract class _$MyNotifier extends $Notifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/essentials/testing/provider_to_mock/codegen.dart b/website/docs/essentials/testing/provider_to_mock/codegen.dart index 9811c1ed9..073779b2d 100644 --- a/website/docs/essentials/testing/provider_to_mock/codegen.dart +++ b/website/docs/essentials/testing/provider_to_mock/codegen.dart @@ -7,5 +7,5 @@ part 'codegen.g.dart'; // An eagerly initialized provider. // {@endtemplate} @riverpod -Future example(ExampleRef ref) async => 'Hello world'; +Future example(Ref ref) async => 'Hello world'; /* SNIPPET END */ diff --git a/website/docs/essentials/testing/provider_to_mock/codegen.g.dart b/website/docs/essentials/testing/provider_to_mock/codegen.g.dart index 4eaf1bcf3..d317584cf 100644 --- a/website/docs/essentials/testing/provider_to_mock/codegen.g.dart +++ b/website/docs/essentials/testing/provider_to_mock/codegen.g.dart @@ -8,17 +8,15 @@ part of 'codegen.dart'; // RiverpodGenerator // ************************************************************************** -typedef ExampleRef = Ref>; - @ProviderFor(example) const exampleProvider = ExampleProvider._(); final class ExampleProvider extends $FunctionalProvider, FutureOr> - with $FutureModifier, $FutureProvider { + with $FutureModifier, $FutureProvider { const ExampleProvider._( {FutureOr Function( - ExampleRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -32,7 +30,7 @@ final class ExampleProvider ); final FutureOr Function( - ExampleRef ref, + Ref ref, )? _createCb; @override @@ -46,20 +44,20 @@ final class ExampleProvider @override ExampleProvider $copyWithCreate( FutureOr Function( - ExampleRef ref, + Ref ref, ) create, ) { return ExampleProvider._(create: create); } @override - FutureOr create(ExampleRef ref) { + FutureOr create(Ref ref) { final _$cb = _createCb ?? example; return _$cb(ref); } } -String _$exampleHash() => r'd421d08db0ee9d10af5521159561135d8c5fa57c'; +String _$exampleHash() => r'8768b72378809f5cb6ae94b65493cbb49bd23b77'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/essentials/websockets_sync/pipe_change_notifier.dart b/website/docs/essentials/websockets_sync/pipe_change_notifier.dart index b9af5a491..0cc75bea6 100644 --- a/website/docs/essentials/websockets_sync/pipe_change_notifier.dart +++ b/website/docs/essentials/websockets_sync/pipe_change_notifier.dart @@ -11,7 +11,7 @@ part 'pipe_change_notifier.g.dart'; /// whenever the value changes. // {@endtemplate} @riverpod -Raw> myListenable(MyListenableRef ref) { +Raw> myListenable(Ref ref) { final notifier = ValueNotifier(0); // {@template onDispose} diff --git a/website/docs/essentials/websockets_sync/pipe_change_notifier.g.dart b/website/docs/essentials/websockets_sync/pipe_change_notifier.g.dart index f54e1dfc4..f4b759774 100644 --- a/website/docs/essentials/websockets_sync/pipe_change_notifier.g.dart +++ b/website/docs/essentials/websockets_sync/pipe_change_notifier.g.dart @@ -8,11 +8,6 @@ part of 'pipe_change_notifier.dart'; // RiverpodGenerator // ************************************************************************** -/// A provider which creates a ValueNotifier and update its listeners -/// whenever the value changes. -// {@endtemplate} -typedef MyListenableRef = Ref>>; - /// A provider which creates a ValueNotifier and update its listeners /// whenever the value changes. // {@endtemplate} @@ -23,14 +18,14 @@ const myListenableProvider = MyListenableProvider._(); /// whenever the value changes. // {@endtemplate} final class MyListenableProvider extends $FunctionalProvider< - Raw>, Raw>> - with $Provider>, MyListenableRef> { + Raw>, + Raw>> with $Provider>> { /// A provider which creates a ValueNotifier and update its listeners /// whenever the value changes. // {@endtemplate} const MyListenableProvider._( {Raw> Function( - MyListenableRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -44,7 +39,7 @@ final class MyListenableProvider extends $FunctionalProvider< ); final Raw> Function( - MyListenableRef ref, + Ref ref, )? _createCb; @override @@ -67,20 +62,20 @@ final class MyListenableProvider extends $FunctionalProvider< @override MyListenableProvider $copyWithCreate( Raw> Function( - MyListenableRef ref, + Ref ref, ) create, ) { return MyListenableProvider._(create: create); } @override - Raw> create(MyListenableRef ref) { + Raw> create(Ref ref) { final _$cb = _createCb ?? myListenable; return _$cb(ref); } } -String _$myListenableHash() => r'c80799a0224092668fca44187b98ccfcd2b33ae1'; +String _$myListenableHash() => r'11b973997ad9787b8f775746d7a87211df2cb6bb'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/essentials/websockets_sync/raw_usage.dart b/website/docs/essentials/websockets_sync/raw_usage.dart index b2fd409a6..a42bf0fc2 100644 --- a/website/docs/essentials/websockets_sync/raw_usage.dart +++ b/website/docs/essentials/websockets_sync/raw_usage.dart @@ -8,7 +8,7 @@ part 'raw_usage.g.dart'; /* SNIPPET START */ @riverpod -Raw> rawStream(RawStreamRef ref) { +Raw> rawStream(Ref ref) { // {@template provider} // "Raw" is a typedef. No need to wrap the return // value in a "Raw" constructor. diff --git a/website/docs/essentials/websockets_sync/raw_usage.g.dart b/website/docs/essentials/websockets_sync/raw_usage.g.dart index b184bb7e5..c971179f0 100644 --- a/website/docs/essentials/websockets_sync/raw_usage.g.dart +++ b/website/docs/essentials/websockets_sync/raw_usage.g.dart @@ -8,17 +8,15 @@ part of 'raw_usage.dart'; // RiverpodGenerator // ************************************************************************** -typedef RawStreamRef = Ref>>; - @ProviderFor(rawStream) const rawStreamProvider = RawStreamProvider._(); final class RawStreamProvider extends $FunctionalProvider>, Raw>> - with $Provider>, RawStreamRef> { + with $Provider>> { const RawStreamProvider._( {Raw> Function( - RawStreamRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -32,7 +30,7 @@ final class RawStreamProvider ); final Raw> Function( - RawStreamRef ref, + Ref ref, )? _createCb; @override @@ -54,20 +52,20 @@ final class RawStreamProvider @override RawStreamProvider $copyWithCreate( Raw> Function( - RawStreamRef ref, + Ref ref, ) create, ) { return RawStreamProvider._(create: create); } @override - Raw> create(RawStreamRef ref) { + Raw> create(Ref ref) { final _$cb = _createCb ?? rawStream; return _$cb(ref); } } -String _$rawStreamHash() => r'7e7c2e8f4f08d33a4d86d60449e143c419ca4822'; +String _$rawStreamHash() => r'9ce48e3afce64329958af139c77f5e271e0bf04f'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/essentials/websockets_sync/shared_pipe_change_notifier.dart b/website/docs/essentials/websockets_sync/shared_pipe_change_notifier.dart index f155f3403..8b94a0d55 100644 --- a/website/docs/essentials/websockets_sync/shared_pipe_change_notifier.dart +++ b/website/docs/essentials/websockets_sync/shared_pipe_change_notifier.dart @@ -6,7 +6,7 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'shared_pipe_change_notifier.g.dart'; /* SNIPPET START */ -extension on Ref { +extension on Ref { // {@template extension} // We can move the previous logic to a Ref extension. // This enables reusing the logic between providers @@ -22,11 +22,11 @@ extension on Ref { } @riverpod -Raw> myListenable(MyListenableRef ref) { +Raw> myListenable(Ref ref) { return ref.disposeAndListenChangeNotifier(ValueNotifier(0)); } @riverpod -Raw> anotherListenable(AnotherListenableRef ref) { +Raw> anotherListenable(Ref ref) { return ref.disposeAndListenChangeNotifier(ValueNotifier(42)); } diff --git a/website/docs/essentials/websockets_sync/shared_pipe_change_notifier.g.dart b/website/docs/essentials/websockets_sync/shared_pipe_change_notifier.g.dart index 55e808c20..59ea67a73 100644 --- a/website/docs/essentials/websockets_sync/shared_pipe_change_notifier.g.dart +++ b/website/docs/essentials/websockets_sync/shared_pipe_change_notifier.g.dart @@ -8,17 +8,15 @@ part of 'shared_pipe_change_notifier.dart'; // RiverpodGenerator // ************************************************************************** -typedef MyListenableRef = Ref>>; - @ProviderFor(myListenable) const myListenableProvider = MyListenableProvider._(); final class MyListenableProvider extends $FunctionalProvider< - Raw>, Raw>> - with $Provider>, MyListenableRef> { + Raw>, + Raw>> with $Provider>> { const MyListenableProvider._( {Raw> Function( - MyListenableRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -32,7 +30,7 @@ final class MyListenableProvider extends $FunctionalProvider< ); final Raw> Function( - MyListenableRef ref, + Ref ref, )? _createCb; @override @@ -55,32 +53,30 @@ final class MyListenableProvider extends $FunctionalProvider< @override MyListenableProvider $copyWithCreate( Raw> Function( - MyListenableRef ref, + Ref ref, ) create, ) { return MyListenableProvider._(create: create); } @override - Raw> create(MyListenableRef ref) { + Raw> create(Ref ref) { final _$cb = _createCb ?? myListenable; return _$cb(ref); } } -String _$myListenableHash() => r'90f4227ef5442f978d742115663e5f0869622a27'; - -typedef AnotherListenableRef = Ref>>; +String _$myListenableHash() => r'a28ce39430582e0d7be5f8303a31477569153193'; @ProviderFor(anotherListenable) const anotherListenableProvider = AnotherListenableProvider._(); final class AnotherListenableProvider extends $FunctionalProvider< - Raw>, Raw>> - with $Provider>, AnotherListenableRef> { + Raw>, + Raw>> with $Provider>> { const AnotherListenableProvider._( {Raw> Function( - AnotherListenableRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -94,7 +90,7 @@ final class AnotherListenableProvider extends $FunctionalProvider< ); final Raw> Function( - AnotherListenableRef ref, + Ref ref, )? _createCb; @override @@ -117,20 +113,20 @@ final class AnotherListenableProvider extends $FunctionalProvider< @override AnotherListenableProvider $copyWithCreate( Raw> Function( - AnotherListenableRef ref, + Ref ref, ) create, ) { return AnotherListenableProvider._(create: create); } @override - Raw> create(AnotherListenableRef ref) { + Raw> create(Ref ref) { final _$cb = _createCb ?? anotherListenable; return _$cb(ref); } } -String _$anotherListenableHash() => r'50dd36b21e07c50818944ec49f9e68d21fcae876'; +String _$anotherListenableHash() => r'49aab48c26d8596262c3d89e0190baeaf9d7ac4a'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/essentials/websockets_sync/stream_provider/codegen.dart b/website/docs/essentials/websockets_sync/stream_provider/codegen.dart index 1af14c68e..e80ec7478 100644 --- a/website/docs/essentials/websockets_sync/stream_provider/codegen.dart +++ b/website/docs/essentials/websockets_sync/stream_provider/codegen.dart @@ -8,7 +8,7 @@ part 'codegen.g.dart'; /* SNIPPET START */ @riverpod -Stream streamExample(StreamExampleRef ref) async* { +Stream streamExample(Ref ref) async* { // {@template provider} // Every 1 second, yield a number from 0 to 41. // This could be replaced with a Stream from Firestore or GraphQL or anything else. diff --git a/website/docs/essentials/websockets_sync/stream_provider/codegen.g.dart b/website/docs/essentials/websockets_sync/stream_provider/codegen.g.dart index 6306dcf86..0e31026e8 100644 --- a/website/docs/essentials/websockets_sync/stream_provider/codegen.g.dart +++ b/website/docs/essentials/websockets_sync/stream_provider/codegen.g.dart @@ -8,17 +8,15 @@ part of 'codegen.dart'; // RiverpodGenerator // ************************************************************************** -typedef StreamExampleRef = Ref>; - @ProviderFor(streamExample) const streamExampleProvider = StreamExampleProvider._(); final class StreamExampleProvider extends $FunctionalProvider, Stream> - with $FutureModifier, $StreamProvider { + with $FutureModifier, $StreamProvider { const StreamExampleProvider._( {Stream Function( - StreamExampleRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -32,7 +30,7 @@ final class StreamExampleProvider ); final Stream Function( - StreamExampleRef ref, + Ref ref, )? _createCb; @override @@ -46,20 +44,20 @@ final class StreamExampleProvider @override StreamExampleProvider $copyWithCreate( Stream Function( - StreamExampleRef ref, + Ref ref, ) create, ) { return StreamExampleProvider._(create: create); } @override - Stream create(StreamExampleRef ref) { + Stream create(Ref ref) { final _$cb = _createCb ?? streamExample; return _$cb(ref); } } -String _$streamExampleHash() => r'ca9993b22f6d587b20c041133cacd28d01933074'; +String _$streamExampleHash() => r'5f0e824562e820b85cc0d031a7fcce1d381023a5'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/essentials/websockets_sync/sync_definition/codegen.dart b/website/docs/essentials/websockets_sync/sync_definition/codegen.dart index dbccd14aa..cdddcb32d 100644 --- a/website/docs/essentials/websockets_sync/sync_definition/codegen.dart +++ b/website/docs/essentials/websockets_sync/sync_definition/codegen.dart @@ -4,7 +4,7 @@ part 'codegen.g.dart'; /* SNIPPET START */ @riverpod -int synchronousExample(SynchronousExampleRef ref) { +int synchronousExample(Ref ref) { return 0; } /* SNIPPET END */ diff --git a/website/docs/essentials/websockets_sync/sync_definition/codegen.g.dart b/website/docs/essentials/websockets_sync/sync_definition/codegen.g.dart index a16299830..287ae347d 100644 --- a/website/docs/essentials/websockets_sync/sync_definition/codegen.g.dart +++ b/website/docs/essentials/websockets_sync/sync_definition/codegen.g.dart @@ -8,16 +8,14 @@ part of 'codegen.dart'; // RiverpodGenerator // ************************************************************************** -typedef SynchronousExampleRef = Ref; - @ProviderFor(synchronousExample) const synchronousExampleProvider = SynchronousExampleProvider._(); final class SynchronousExampleProvider extends $FunctionalProvider - with $Provider { + with $Provider { const SynchronousExampleProvider._( {int Function( - SynchronousExampleRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -31,7 +29,7 @@ final class SynchronousExampleProvider extends $FunctionalProvider ); final int Function( - SynchronousExampleRef ref, + Ref ref, )? _createCb; @override @@ -53,21 +51,21 @@ final class SynchronousExampleProvider extends $FunctionalProvider @override SynchronousExampleProvider $copyWithCreate( int Function( - SynchronousExampleRef ref, + Ref ref, ) create, ) { return SynchronousExampleProvider._(create: create); } @override - int create(SynchronousExampleRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? synchronousExample; return _$cb(ref); } } String _$synchronousExampleHash() => - r'98df96e07d554683041f668c06b36f183ff534c1'; + r'a12577c395d5a639fdad88b28309f378a64bd2a7'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/from_provider/family/family.dart b/website/docs/from_provider/family/family.dart index 4d49c552a..61cf268fc 100644 --- a/website/docs/from_provider/family/family.dart +++ b/website/docs/from_provider/family/family.dart @@ -6,6 +6,6 @@ part 'family.g.dart'; /* SNIPPET START */ @riverpod -int random(RandomRef ref, {required int seed, required int max}) { +int random(Ref ref, {required int seed, required int max}) { return Random(seed).nextInt(max); } diff --git a/website/docs/from_provider/family/family.g.dart b/website/docs/from_provider/family/family.g.dart index 4e89b9640..8c2fc95a0 100644 --- a/website/docs/from_provider/family/family.g.dart +++ b/website/docs/from_provider/family/family.g.dart @@ -8,13 +8,11 @@ part of 'family.dart'; // RiverpodGenerator // ************************************************************************** -typedef RandomRef = Ref; - @ProviderFor(random) const randomProvider = RandomFamily._(); final class RandomProvider extends $FunctionalProvider - with $Provider { + with $Provider { const RandomProvider._( {required RandomFamily super.from, required ({ @@ -23,7 +21,7 @@ final class RandomProvider extends $FunctionalProvider }) super.argument, int Function( - RandomRef ref, { + Ref ref, { required int seed, required int max, })? create}) @@ -37,7 +35,7 @@ final class RandomProvider extends $FunctionalProvider ); final int Function( - RandomRef ref, { + Ref ref, { required int seed, required int max, })? _createCb; @@ -68,7 +66,7 @@ final class RandomProvider extends $FunctionalProvider @override RandomProvider $copyWithCreate( int Function( - RandomRef ref, + Ref ref, ) create, ) { return RandomProvider._( @@ -86,7 +84,7 @@ final class RandomProvider extends $FunctionalProvider } @override - int create(RandomRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? random; final argument = this.argument as ({ int seed, @@ -110,7 +108,7 @@ final class RandomProvider extends $FunctionalProvider } } -String _$randomHash() => r'517b12aad4df7b31f8872b89af74e7880377b2ea'; +String _$randomHash() => r'ab69799dce84746b22880feae0f1db6dea906f6a'; final class RandomFamily extends Family { const RandomFamily._() @@ -140,7 +138,7 @@ final class RandomFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( int Function( - RandomRef ref, + Ref ref, ({ int seed, int max, @@ -165,4 +163,4 @@ final class RandomFamily extends Family { } } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/from_provider/motivation/async_values/async_values.dart b/website/docs/from_provider/motivation/async_values/async_values.dart index 802a23150..0518dc0a7 100644 --- a/website/docs/from_provider/motivation/async_values/async_values.dart +++ b/website/docs/from_provider/motivation/async_values/async_values.dart @@ -10,7 +10,7 @@ part 'async_values.g.dart'; /* SNIPPET START */ @riverpod -Future> itemsApi(ItemsApiRef ref) async { +Future> itemsApi(Ref ref) async { final client = Dio(); final result = await client.get>('your-favorite-api'); final parsed = [...result.data!.map((e) => Item.fromJson(e as Json))]; @@ -18,7 +18,7 @@ Future> itemsApi(ItemsApiRef ref) async { } @riverpod -List evenItems(EvenItemsRef ref) { +List evenItems(Ref ref) { final asyncValue = ref.watch(itemsApiProvider); if (asyncValue.isReloading) return []; if (asyncValue.hasError) return const [Item(id: -1)]; diff --git a/website/docs/from_provider/motivation/async_values/async_values.g.dart b/website/docs/from_provider/motivation/async_values/async_values.g.dart index bb9202a05..1b78c2ed0 100644 --- a/website/docs/from_provider/motivation/async_values/async_values.g.dart +++ b/website/docs/from_provider/motivation/async_values/async_values.g.dart @@ -8,17 +8,15 @@ part of 'async_values.dart'; // RiverpodGenerator // ************************************************************************** -typedef ItemsApiRef = Ref>>; - @ProviderFor(itemsApi) const itemsApiProvider = ItemsApiProvider._(); final class ItemsApiProvider extends $FunctionalProvider>, FutureOr>> - with $FutureModifier>, $FutureProvider, ItemsApiRef> { + with $FutureModifier>, $FutureProvider> { const ItemsApiProvider._( {FutureOr> Function( - ItemsApiRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -32,7 +30,7 @@ final class ItemsApiProvider ); final FutureOr> Function( - ItemsApiRef ref, + Ref ref, )? _createCb; @override @@ -46,32 +44,30 @@ final class ItemsApiProvider @override ItemsApiProvider $copyWithCreate( FutureOr> Function( - ItemsApiRef ref, + Ref ref, ) create, ) { return ItemsApiProvider._(create: create); } @override - FutureOr> create(ItemsApiRef ref) { + FutureOr> create(Ref ref) { final _$cb = _createCb ?? itemsApi; return _$cb(ref); } } -String _$itemsApiHash() => r'b32ccb7b85305e361d8ed752cbe11d9524c96190'; - -typedef EvenItemsRef = Ref>; +String _$itemsApiHash() => r'fa5a8f7e93ac048d9bd5dfc1744749995cf154af'; @ProviderFor(evenItems) const evenItemsProvider = EvenItemsProvider._(); final class EvenItemsProvider extends $FunctionalProvider, List> - with $Provider, EvenItemsRef> { + with $Provider> { const EvenItemsProvider._( {List Function( - EvenItemsRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -85,7 +81,7 @@ final class EvenItemsProvider ); final List Function( - EvenItemsRef ref, + Ref ref, )? _createCb; @override @@ -107,20 +103,20 @@ final class EvenItemsProvider @override EvenItemsProvider $copyWithCreate( List Function( - EvenItemsRef ref, + Ref ref, ) create, ) { return EvenItemsProvider._(create: create); } @override - List create(EvenItemsRef ref) { + List create(Ref ref) { final _$cb = _createCb ?? evenItems; return _$cb(ref); } } -String _$evenItemsHash() => r'55ae98f9b6108203dfc4a139f1ade9fbd8ba8ddd'; +String _$evenItemsHash() => r'22297e33c5f55ff99fb49747c203be595a28fabf'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/from_provider/motivation/auto_dispose/auto_dispose.dart b/website/docs/from_provider/motivation/auto_dispose/auto_dispose.dart index 956d888f5..052686f61 100644 --- a/website/docs/from_provider/motivation/auto_dispose/auto_dispose.dart +++ b/website/docs/from_provider/motivation/auto_dispose/auto_dispose.dart @@ -10,7 +10,7 @@ part 'auto_dispose.g.dart'; // With code gen, .autoDispose is the default // {@endtemplate} @riverpod -int diceRoll(DiceRollRef ref) { +int diceRoll(Ref ref) { // {@template dice} // Since this provider is .autoDispose, un-listening to it will dispose // its current exposed state. @@ -22,7 +22,7 @@ int diceRoll(DiceRollRef ref) { } @riverpod -int cachedDiceRoll(CachedDiceRollRef ref) { +int cachedDiceRoll(Ref ref) { final coin = Random().nextInt(10); if (coin > 5) throw Exception('Way too large.'); // {@template keepAlive} diff --git a/website/docs/from_provider/motivation/auto_dispose/auto_dispose.g.dart b/website/docs/from_provider/motivation/auto_dispose/auto_dispose.g.dart index 47fdddd7f..2c1ffb3ea 100644 --- a/website/docs/from_provider/motivation/auto_dispose/auto_dispose.g.dart +++ b/website/docs/from_provider/motivation/auto_dispose/auto_dispose.g.dart @@ -8,16 +8,14 @@ part of 'auto_dispose.dart'; // RiverpodGenerator // ************************************************************************** -typedef DiceRollRef = Ref; - @ProviderFor(diceRoll) const diceRollProvider = DiceRollProvider._(); final class DiceRollProvider extends $FunctionalProvider - with $Provider { + with $Provider { const DiceRollProvider._( {int Function( - DiceRollRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -31,7 +29,7 @@ final class DiceRollProvider extends $FunctionalProvider ); final int Function( - DiceRollRef ref, + Ref ref, )? _createCb; @override @@ -53,31 +51,29 @@ final class DiceRollProvider extends $FunctionalProvider @override DiceRollProvider $copyWithCreate( int Function( - DiceRollRef ref, + Ref ref, ) create, ) { return DiceRollProvider._(create: create); } @override - int create(DiceRollRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? diceRoll; return _$cb(ref); } } -String _$diceRollHash() => r'dfd5ac8b74351a0076da9d131c10277f53ff11b9'; - -typedef CachedDiceRollRef = Ref; +String _$diceRollHash() => r'58d43e5143bb64e855939d55a3be3ee81d66c518'; @ProviderFor(cachedDiceRoll) const cachedDiceRollProvider = CachedDiceRollProvider._(); final class CachedDiceRollProvider extends $FunctionalProvider - with $Provider { + with $Provider { const CachedDiceRollProvider._( {int Function( - CachedDiceRollRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -91,7 +87,7 @@ final class CachedDiceRollProvider extends $FunctionalProvider ); final int Function( - CachedDiceRollRef ref, + Ref ref, )? _createCb; @override @@ -113,20 +109,20 @@ final class CachedDiceRollProvider extends $FunctionalProvider @override CachedDiceRollProvider $copyWithCreate( int Function( - CachedDiceRollRef ref, + Ref ref, ) create, ) { return CachedDiceRollProvider._(create: create); } @override - int create(CachedDiceRollRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? cachedDiceRoll; return _$cb(ref); } } -String _$cachedDiceRollHash() => r'fc31fcb804f10360d75362e56329976343ee7abb'; +String _$cachedDiceRollHash() => r'eaf5bb809278298f16e2eda8972b1876921f66f5'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/from_provider/motivation/combine/combine.dart b/website/docs/from_provider/motivation/combine/combine.dart index ecd1915da..521d231b7 100644 --- a/website/docs/from_provider/motivation/combine/combine.dart +++ b/website/docs/from_provider/motivation/combine/combine.dart @@ -7,12 +7,12 @@ part 'combine.g.dart'; /* SNIPPET START */ @riverpod -int number(NumberRef ref) { +int number(Ref ref) { return Random().nextInt(10); } @riverpod -int doubled(DoubledRef ref) { +int doubled(Ref ref) { final number = ref.watch(numberProvider); return number * 2; diff --git a/website/docs/from_provider/motivation/combine/combine.g.dart b/website/docs/from_provider/motivation/combine/combine.g.dart index 1c8a14477..d8ed187a2 100644 --- a/website/docs/from_provider/motivation/combine/combine.g.dart +++ b/website/docs/from_provider/motivation/combine/combine.g.dart @@ -8,16 +8,14 @@ part of 'combine.dart'; // RiverpodGenerator // ************************************************************************** -typedef NumberRef = Ref; - @ProviderFor(number) const numberProvider = NumberProvider._(); final class NumberProvider extends $FunctionalProvider - with $Provider { + with $Provider { const NumberProvider._( {int Function( - NumberRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -31,7 +29,7 @@ final class NumberProvider extends $FunctionalProvider ); final int Function( - NumberRef ref, + Ref ref, )? _createCb; @override @@ -53,31 +51,29 @@ final class NumberProvider extends $FunctionalProvider @override NumberProvider $copyWithCreate( int Function( - NumberRef ref, + Ref ref, ) create, ) { return NumberProvider._(create: create); } @override - int create(NumberRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? number; return _$cb(ref); } } -String _$numberHash() => r'725e25be57b9cc2bd914752f156e26a214596b63'; - -typedef DoubledRef = Ref; +String _$numberHash() => r'03ac91d5904c18f04321b140fd263ed6bc85d3c1'; @ProviderFor(doubled) const doubledProvider = DoubledProvider._(); final class DoubledProvider extends $FunctionalProvider - with $Provider { + with $Provider { const DoubledProvider._( {int Function( - DoubledRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -91,7 +87,7 @@ final class DoubledProvider extends $FunctionalProvider ); final int Function( - DoubledRef ref, + Ref ref, )? _createCb; @override @@ -113,20 +109,20 @@ final class DoubledProvider extends $FunctionalProvider @override DoubledProvider $copyWithCreate( int Function( - DoubledRef ref, + Ref ref, ) create, ) { return DoubledProvider._(create: create); } @override - int create(DoubledRef ref) { + int create(Ref ref) { final _$cb = _createCb ?? doubled; return _$cb(ref); } } -String _$doubledHash() => r'ddc640c876bdbe49fe72fe1632b5ff48687c9279'; +String _$doubledHash() => r'2a7f7fadb89e55d6adcf11aaa21943c66b10df5e'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/from_provider/motivation/same_type/same_type.dart b/website/docs/from_provider/motivation/same_type/same_type.dart index 94a4ab086..a46db40cf 100644 --- a/website/docs/from_provider/motivation/same_type/same_type.dart +++ b/website/docs/from_provider/motivation/same_type/same_type.dart @@ -8,12 +8,12 @@ part 'same_type.g.dart'; /* SNIPPET START */ @riverpod -List items(ItemsRef ref) { +List items(Ref ref) { return []; // ... } @riverpod -List evenItems(EvenItemsRef ref) { +List evenItems(Ref ref) { final items = ref.watch(itemsProvider); return [...items.whereIndexed((index, element) => index.isEven)]; } diff --git a/website/docs/from_provider/motivation/same_type/same_type.g.dart b/website/docs/from_provider/motivation/same_type/same_type.g.dart index 2d52f8876..30bc5f7ec 100644 --- a/website/docs/from_provider/motivation/same_type/same_type.g.dart +++ b/website/docs/from_provider/motivation/same_type/same_type.g.dart @@ -8,16 +8,14 @@ part of 'same_type.dart'; // RiverpodGenerator // ************************************************************************** -typedef ItemsRef = Ref>; - @ProviderFor(items) const itemsProvider = ItemsProvider._(); final class ItemsProvider extends $FunctionalProvider, List> - with $Provider, ItemsRef> { + with $Provider> { const ItemsProvider._( {List Function( - ItemsRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -31,7 +29,7 @@ final class ItemsProvider extends $FunctionalProvider, List> ); final List Function( - ItemsRef ref, + Ref ref, )? _createCb; @override @@ -53,32 +51,30 @@ final class ItemsProvider extends $FunctionalProvider, List> @override ItemsProvider $copyWithCreate( List Function( - ItemsRef ref, + Ref ref, ) create, ) { return ItemsProvider._(create: create); } @override - List create(ItemsRef ref) { + List create(Ref ref) { final _$cb = _createCb ?? items; return _$cb(ref); } } -String _$itemsHash() => r'f0a8fa6874f4868db9ead31e82c75d976f9d2033'; - -typedef EvenItemsRef = Ref>; +String _$itemsHash() => r'8dafed1afc3fc52651c24445640d8b57ff080f66'; @ProviderFor(evenItems) const evenItemsProvider = EvenItemsProvider._(); final class EvenItemsProvider extends $FunctionalProvider, List> - with $Provider, EvenItemsRef> { + with $Provider> { const EvenItemsProvider._( {List Function( - EvenItemsRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -92,7 +88,7 @@ final class EvenItemsProvider ); final List Function( - EvenItemsRef ref, + Ref ref, )? _createCb; @override @@ -114,20 +110,20 @@ final class EvenItemsProvider @override EvenItemsProvider $copyWithCreate( List Function( - EvenItemsRef ref, + Ref ref, ) create, ) { return EvenItemsProvider._(create: create); } @override - List create(EvenItemsRef ref) { + List create(Ref ref) { final _$cb = _createCb ?? evenItems; return _$cb(ref); } } -String _$evenItemsHash() => r'82b4525e91604745f2b4664531b32d4aff5717d4'; +String _$evenItemsHash() => r'83ef608e2e1ec6926495f7a4dd4bac3e6b1f16e1'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/from_provider/quickstart.mdx b/website/docs/from_provider/quickstart.mdx index 820d2e247..d11545fb6 100644 --- a/website/docs/from_provider/quickstart.mdx +++ b/website/docs/from_provider/quickstart.mdx @@ -167,7 +167,7 @@ And then, you can expose your `ChangeNotifier` with the following codegen syntax ```dart // ignore_for_file: unsupported_provider_value @riverpod -MyNotifier example(ExampleRef ref) { +MyNotifier example(Ref ref) { return ref.listenAndDisposeChangeNotifier(MyNotifier()); } ``` diff --git a/website/docs/introduction/getting_started/dart_hello_world/main.dart b/website/docs/introduction/getting_started/dart_hello_world/main.dart index 09380505c..c265b837a 100644 --- a/website/docs/introduction/getting_started/dart_hello_world/main.dart +++ b/website/docs/introduction/getting_started/dart_hello_world/main.dart @@ -11,7 +11,7 @@ part 'main.g.dart'; // By using a provider, this allows us to mock/override the value exposed. // {@endtemplate} @riverpod -String helloWorld(HelloWorldRef ref) { +String helloWorld(Ref ref) { return 'Hello world'; } diff --git a/website/docs/introduction/getting_started/dart_hello_world/main.g.dart b/website/docs/introduction/getting_started/dart_hello_world/main.g.dart index 82564d247..c197b77fe 100644 --- a/website/docs/introduction/getting_started/dart_hello_world/main.g.dart +++ b/website/docs/introduction/getting_started/dart_hello_world/main.g.dart @@ -8,16 +8,14 @@ part of 'main.dart'; // RiverpodGenerator // ************************************************************************** -typedef HelloWorldRef = Ref; - @ProviderFor(helloWorld) const helloWorldProvider = HelloWorldProvider._(); final class HelloWorldProvider extends $FunctionalProvider - with $Provider { + with $Provider { const HelloWorldProvider._( {String Function( - HelloWorldRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -31,7 +29,7 @@ final class HelloWorldProvider extends $FunctionalProvider ); final String Function( - HelloWorldRef ref, + Ref ref, )? _createCb; @override @@ -53,20 +51,20 @@ final class HelloWorldProvider extends $FunctionalProvider @override HelloWorldProvider $copyWithCreate( String Function( - HelloWorldRef ref, + Ref ref, ) create, ) { return HelloWorldProvider._(create: create); } @override - String create(HelloWorldRef ref) { + String create(Ref ref) { final _$cb = _createCb ?? helloWorld; return _$cb(ref); } } -String _$helloWorldHash() => r'8bbe6cff2b7b1f4e1f7be3d1820da793259f7bfc'; +String _$helloWorldHash() => r'9abaa5ab530c55186861f2debdaa218aceacb7eb'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/introduction/getting_started/hello_world/hooks_codegen/main.dart b/website/docs/introduction/getting_started/hello_world/hooks_codegen/main.dart index a3091e132..cb84e0e85 100644 --- a/website/docs/introduction/getting_started/hello_world/hooks_codegen/main.dart +++ b/website/docs/introduction/getting_started/hello_world/hooks_codegen/main.dart @@ -14,7 +14,7 @@ part 'main.g.dart'; // By using a provider, this allows us to mock/override the value exposed. // {@endtemplate} @riverpod -String helloWorld(HelloWorldRef ref) { +String helloWorld(Ref ref) { return 'Hello world'; } diff --git a/website/docs/introduction/getting_started/hello_world/hooks_codegen/main.g.dart b/website/docs/introduction/getting_started/hello_world/hooks_codegen/main.g.dart index 82564d247..c197b77fe 100644 --- a/website/docs/introduction/getting_started/hello_world/hooks_codegen/main.g.dart +++ b/website/docs/introduction/getting_started/hello_world/hooks_codegen/main.g.dart @@ -8,16 +8,14 @@ part of 'main.dart'; // RiverpodGenerator // ************************************************************************** -typedef HelloWorldRef = Ref; - @ProviderFor(helloWorld) const helloWorldProvider = HelloWorldProvider._(); final class HelloWorldProvider extends $FunctionalProvider - with $Provider { + with $Provider { const HelloWorldProvider._( {String Function( - HelloWorldRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -31,7 +29,7 @@ final class HelloWorldProvider extends $FunctionalProvider ); final String Function( - HelloWorldRef ref, + Ref ref, )? _createCb; @override @@ -53,20 +51,20 @@ final class HelloWorldProvider extends $FunctionalProvider @override HelloWorldProvider $copyWithCreate( String Function( - HelloWorldRef ref, + Ref ref, ) create, ) { return HelloWorldProvider._(create: create); } @override - String create(HelloWorldRef ref) { + String create(Ref ref) { final _$cb = _createCb ?? helloWorld; return _$cb(ref); } } -String _$helloWorldHash() => r'8bbe6cff2b7b1f4e1f7be3d1820da793259f7bfc'; +String _$helloWorldHash() => r'9abaa5ab530c55186861f2debdaa218aceacb7eb'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/introduction/getting_started/hello_world/main.dart b/website/docs/introduction/getting_started/hello_world/main.dart index 22b1e3eef..622956be6 100644 --- a/website/docs/introduction/getting_started/hello_world/main.dart +++ b/website/docs/introduction/getting_started/hello_world/main.dart @@ -13,7 +13,7 @@ part 'main.g.dart'; // By using a provider, this allows us to mock/override the value exposed. // {@endtemplate} @riverpod -String helloWorld(HelloWorldRef ref) { +String helloWorld(Ref ref) { return 'Hello world'; } diff --git a/website/docs/introduction/getting_started/hello_world/main.g.dart b/website/docs/introduction/getting_started/hello_world/main.g.dart index 82564d247..c197b77fe 100644 --- a/website/docs/introduction/getting_started/hello_world/main.g.dart +++ b/website/docs/introduction/getting_started/hello_world/main.g.dart @@ -8,16 +8,14 @@ part of 'main.dart'; // RiverpodGenerator // ************************************************************************** -typedef HelloWorldRef = Ref; - @ProviderFor(helloWorld) const helloWorldProvider = HelloWorldProvider._(); final class HelloWorldProvider extends $FunctionalProvider - with $Provider { + with $Provider { const HelloWorldProvider._( {String Function( - HelloWorldRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -31,7 +29,7 @@ final class HelloWorldProvider extends $FunctionalProvider ); final String Function( - HelloWorldRef ref, + Ref ref, )? _createCb; @override @@ -53,20 +51,20 @@ final class HelloWorldProvider extends $FunctionalProvider @override HelloWorldProvider $copyWithCreate( String Function( - HelloWorldRef ref, + Ref ref, ) create, ) { return HelloWorldProvider._(create: create); } @override - String create(HelloWorldRef ref) { + String create(Ref ref) { final _$cb = _createCb ?? helloWorld; return _$cb(ref); } } -String _$helloWorldHash() => r'8bbe6cff2b7b1f4e1f7be3d1820da793259f7bfc'; +String _$helloWorldHash() => r'9abaa5ab530c55186861f2debdaa218aceacb7eb'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/introduction/why_riverpod.mdx b/website/docs/introduction/why_riverpod.mdx index 51e880c03..8dffc3566 100644 --- a/website/docs/introduction/why_riverpod.mdx +++ b/website/docs/introduction/why_riverpod.mdx @@ -41,7 +41,7 @@ amount of features, such as: - Cancelling asynchronous requests when no-longer used - Optimistic UIs - Offline mode -- ... +- etc. These features can be tricky to implement, but are crucial for a good user experience. Yet few packages try to tackle those problems directly, and a lot of the work diff --git a/website/docs/introduction/why_riverpod/codegen.dart b/website/docs/introduction/why_riverpod/codegen.dart index e1f66c59b..bd784d449 100644 --- a/website/docs/introduction/why_riverpod/codegen.dart +++ b/website/docs/introduction/why_riverpod/codegen.dart @@ -18,7 +18,7 @@ class Package { // {@endtemplate} @riverpod Future> fetchPackages( - FetchPackagesRef ref, { + Ref ref, { required int page, String search = '', }) async { diff --git a/website/docs/introduction/why_riverpod/codegen.g.dart b/website/docs/introduction/why_riverpod/codegen.g.dart index e30a97e36..c95e4a048 100644 --- a/website/docs/introduction/why_riverpod/codegen.g.dart +++ b/website/docs/introduction/why_riverpod/codegen.g.dart @@ -8,16 +8,12 @@ part of 'codegen.dart'; // RiverpodGenerator // ************************************************************************** -typedef FetchPackagesRef = Ref>>; - @ProviderFor(fetchPackages) const fetchPackagesProvider = FetchPackagesFamily._(); final class FetchPackagesProvider extends $FunctionalProvider< AsyncValue>, FutureOr>> - with - $FutureModifier>, - $FutureProvider, FetchPackagesRef> { + with $FutureModifier>, $FutureProvider> { const FetchPackagesProvider._( {required FetchPackagesFamily super.from, required ({ @@ -26,7 +22,7 @@ final class FetchPackagesProvider extends $FunctionalProvider< }) super.argument, FutureOr> Function( - FetchPackagesRef ref, { + Ref ref, { required int page, String search, })? create}) @@ -40,7 +36,7 @@ final class FetchPackagesProvider extends $FunctionalProvider< ); final FutureOr> Function( - FetchPackagesRef ref, { + Ref ref, { required int page, String search, })? _createCb; @@ -64,7 +60,7 @@ final class FetchPackagesProvider extends $FunctionalProvider< @override FetchPackagesProvider $copyWithCreate( FutureOr> Function( - FetchPackagesRef ref, + Ref ref, ) create, ) { return FetchPackagesProvider._( @@ -82,7 +78,7 @@ final class FetchPackagesProvider extends $FunctionalProvider< } @override - FutureOr> create(FetchPackagesRef ref) { + FutureOr> create(Ref ref) { final _$cb = _createCb ?? fetchPackages; final argument = this.argument as ({ int page, @@ -106,7 +102,7 @@ final class FetchPackagesProvider extends $FunctionalProvider< } } -String _$fetchPackagesHash() => r'eebf7d838a57f493fffebfd2c8d8ab76d3233165'; +String _$fetchPackagesHash() => r'4b2c6ea2cd702ab0f9846ba19c945d2c43161605'; final class FetchPackagesFamily extends Family { const FetchPackagesFamily._() @@ -136,7 +132,7 @@ final class FetchPackagesFamily extends Family { /// {@macro riverpod.override_with} Override overrideWith( FutureOr> Function( - FetchPackagesRef ref, + Ref ref, ({ int page, String search, @@ -161,4 +157,4 @@ final class FetchPackagesFamily extends Family { } } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/migration/from_change_notifier/declaration/declaration.g.dart b/website/docs/migration/from_change_notifier/declaration/declaration.g.dart index e71a9d949..1632a0375 100644 --- a/website/docs/migration/from_change_notifier/declaration/declaration.g.dart +++ b/website/docs/migration/from_change_notifier/declaration/declaration.g.dart @@ -47,7 +47,7 @@ final class MyNotifierProvider @override MyNotifierProvider $copyWithBuild( FutureOr> Function( - Ref>>, + Ref, MyNotifier, ) build, ) { @@ -71,4 +71,4 @@ abstract class _$MyNotifier extends $AsyncNotifier> { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/migration/from_change_notifier/initialization/initialization.g.dart b/website/docs/migration/from_change_notifier/initialization/initialization.g.dart index 474896c77..52f915fbb 100644 --- a/website/docs/migration/from_change_notifier/initialization/initialization.g.dart +++ b/website/docs/migration/from_change_notifier/initialization/initialization.g.dart @@ -47,7 +47,7 @@ final class MyNotifierProvider @override MyNotifierProvider $copyWithBuild( FutureOr> Function( - Ref>>, + Ref, MyNotifier, ) build, ) { @@ -71,4 +71,4 @@ abstract class _$MyNotifier extends $AsyncNotifier> { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/migration/from_change_notifier/migrated/migrated.g.dart b/website/docs/migration/from_change_notifier/migrated/migrated.g.dart index 9fa60b6d3..49889dd55 100644 --- a/website/docs/migration/from_change_notifier/migrated/migrated.g.dart +++ b/website/docs/migration/from_change_notifier/migrated/migrated.g.dart @@ -47,7 +47,7 @@ final class MyNotifierProvider @override MyNotifierProvider $copyWithBuild( FutureOr> Function( - Ref>>, + Ref, MyNotifier, ) build, ) { @@ -71,4 +71,4 @@ abstract class _$MyNotifier extends $AsyncNotifier> { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/migration/from_state_notifier/add_listener/add_listener.dart b/website/docs/migration/from_state_notifier/add_listener/add_listener.dart index ead1c72d8..780be14a9 100644 --- a/website/docs/migration/from_state_notifier/add_listener/add_listener.dart +++ b/website/docs/migration/from_state_notifier/add_listener/add_listener.dart @@ -10,7 +10,7 @@ part 'add_listener.g.dart'; class MyNotifier extends _$MyNotifier { @override int build() { - ref.listenSelf((_, next) => debugPrint('$next')); + listenSelf((_, next) => debugPrint('$next')); return 0; } diff --git a/website/docs/migration/from_state_notifier/add_listener/add_listener.g.dart b/website/docs/migration/from_state_notifier/add_listener/add_listener.g.dart index 783472ad4..dff85bbe7 100644 --- a/website/docs/migration/from_state_notifier/add_listener/add_listener.g.dart +++ b/website/docs/migration/from_state_notifier/add_listener/add_listener.g.dart @@ -54,7 +54,7 @@ final class MyNotifierProvider extends $NotifierProvider { @override MyNotifierProvider $copyWithBuild( int Function( - Ref, + Ref, MyNotifier, ) build, ) { @@ -68,7 +68,7 @@ final class MyNotifierProvider extends $NotifierProvider { $NotifierProviderElement(this, pointer); } -String _$myNotifierHash() => r'9acd382ed579c545ace755687b155e28eba01d22'; +String _$myNotifierHash() => r'7ff4b7b8f822ca720b55e2d29ed07d7f0b3485e8'; abstract class _$MyNotifier extends $Notifier { int build(); @@ -78,4 +78,4 @@ abstract class _$MyNotifier extends $Notifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/migration/from_state_notifier/add_listener/raw.dart b/website/docs/migration/from_state_notifier/add_listener/raw.dart index d032a4c2d..c2c30b288 100644 --- a/website/docs/migration/from_state_notifier/add_listener/raw.dart +++ b/website/docs/migration/from_state_notifier/add_listener/raw.dart @@ -7,7 +7,7 @@ import 'package:riverpod/riverpod.dart'; class MyNotifier extends Notifier { @override int build() { - ref.listenSelf((_, next) => debugPrint('$next')); + listenSelf((_, next) => debugPrint('$next')); return 0; } diff --git a/website/docs/migration/from_state_notifier/async_notifier/async_notifier.g.dart b/website/docs/migration/from_state_notifier/async_notifier/async_notifier.g.dart index 7ae0b4412..7c9f86c59 100644 --- a/website/docs/migration/from_state_notifier/async_notifier/async_notifier.g.dart +++ b/website/docs/migration/from_state_notifier/async_notifier/async_notifier.g.dart @@ -47,7 +47,7 @@ final class AsyncTodosNotifierProvider @override AsyncTodosNotifierProvider $copyWithBuild( FutureOr> Function( - Ref>>, + Ref, AsyncTodosNotifier, ) build, ) { @@ -72,4 +72,4 @@ abstract class _$AsyncTodosNotifier extends $AsyncNotifier> { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/migration/from_state_notifier/build_init/build_init.g.dart b/website/docs/migration/from_state_notifier/build_init/build_init.g.dart index d2c67e60e..d91084e2d 100644 --- a/website/docs/migration/from_state_notifier/build_init/build_init.g.dart +++ b/website/docs/migration/from_state_notifier/build_init/build_init.g.dart @@ -55,7 +55,7 @@ final class CounterNotifierProvider @override CounterNotifierProvider $copyWithBuild( int Function( - Ref, + Ref, CounterNotifier, ) build, ) { @@ -79,4 +79,4 @@ abstract class _$CounterNotifier extends $Notifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/migration/from_state_notifier/family_and_dispose/family_and_dispose.dart b/website/docs/migration/from_state_notifier/family_and_dispose/family_and_dispose.dart index 54df8a0ab..0bc88af1f 100644 --- a/website/docs/migration/from_state_notifier/family_and_dispose/family_and_dispose.dart +++ b/website/docs/migration/from_state_notifier/family_and_dispose/family_and_dispose.dart @@ -9,7 +9,7 @@ import '../../utils.dart'; part 'family_and_dispose.g.dart'; @riverpod -TaskTrackerRepo taskTracker(TaskTrackerRef ref) => TaskTrackerRepo(); +TaskTrackerRepo taskTracker(Ref ref) => TaskTrackerRepo(); /* SNIPPET START */ @riverpod diff --git a/website/docs/migration/from_state_notifier/family_and_dispose/family_and_dispose.g.dart b/website/docs/migration/from_state_notifier/family_and_dispose/family_and_dispose.g.dart index af2146920..e6db0d173 100644 --- a/website/docs/migration/from_state_notifier/family_and_dispose/family_and_dispose.g.dart +++ b/website/docs/migration/from_state_notifier/family_and_dispose/family_and_dispose.g.dart @@ -8,17 +8,15 @@ part of 'family_and_dispose.dart'; // RiverpodGenerator // ************************************************************************** -typedef TaskTrackerRef = Ref; - @ProviderFor(taskTracker) const taskTrackerProvider = TaskTrackerProvider._(); final class TaskTrackerProvider extends $FunctionalProvider - with $Provider { + with $Provider { const TaskTrackerProvider._( {TaskTrackerRepo Function( - TaskTrackerRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -32,7 +30,7 @@ final class TaskTrackerProvider ); final TaskTrackerRepo Function( - TaskTrackerRef ref, + Ref ref, )? _createCb; @override @@ -54,20 +52,20 @@ final class TaskTrackerProvider @override TaskTrackerProvider $copyWithCreate( TaskTrackerRepo Function( - TaskTrackerRef ref, + Ref ref, ) create, ) { return TaskTrackerProvider._(create: create); } @override - TaskTrackerRepo create(TaskTrackerRef ref) { + TaskTrackerRepo create(Ref ref) { final _$cb = _createCb ?? taskTracker; return _$cb(ref); } } -String _$taskTrackerHash() => r'd78149146c3a07b78e7dc1d03fa60ed1941c3702'; +String _$taskTrackerHash() => r'004d4554b37d841c6f668e298067dd39611a453a'; @ProviderFor(BugsEncounteredNotifier) const bugsEncounteredNotifierProvider = BugsEncounteredNotifierFamily._(); @@ -120,7 +118,7 @@ final class BugsEncounteredNotifierProvider @override BugsEncounteredNotifierProvider $copyWithBuild( FutureOr Function( - Ref>, + Ref, BugsEncounteredNotifier, ) build, ) { @@ -194,8 +192,8 @@ final class BugsEncounteredNotifierFamily extends Family { /// {@macro riverpod.override_with_build} Override overrideWithBuild( - FutureOr Function(Ref> ref, - BugsEncounteredNotifier notifier, String argument) + FutureOr Function( + Ref ref, BugsEncounteredNotifier notifier, String argument) build, ) { return $FamilyOverride( @@ -228,4 +226,4 @@ abstract class _$BugsEncounteredNotifier extends $AsyncNotifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/migration/from_state_notifier/family_and_dispose_old.dart b/website/docs/migration/from_state_notifier/family_and_dispose_old.dart index f01455cf7..113594ef1 100644 --- a/website/docs/migration/from_state_notifier/family_and_dispose_old.dart +++ b/website/docs/migration/from_state_notifier/family_and_dispose_old.dart @@ -14,7 +14,7 @@ class BugsEncounteredNotifier extends StateNotifier> { required this.featureId, }) : super(const AsyncData(99)); final String featureId; - final Ref> ref; + final Ref ref; Future fix(int amount) async { state = await AsyncValue.guard(() async { diff --git a/website/docs/migration/from_state_notifier/from_state_provider/from_state_provider.g.dart b/website/docs/migration/from_state_notifier/from_state_provider/from_state_provider.g.dart index fd51f4c27..0f1fdaa0f 100644 --- a/website/docs/migration/from_state_notifier/from_state_provider/from_state_provider.g.dart +++ b/website/docs/migration/from_state_notifier/from_state_provider/from_state_provider.g.dart @@ -55,7 +55,7 @@ final class CounterNotifierProvider @override CounterNotifierProvider $copyWithBuild( int Function( - Ref, + Ref, CounterNotifier, ) build, ) { @@ -79,4 +79,4 @@ abstract class _$CounterNotifier extends $Notifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/migration/from_state_notifier/old_lifecycles/old_lifecycles.g.dart b/website/docs/migration/from_state_notifier/old_lifecycles/old_lifecycles.g.dart index 77786bd38..3ca538354 100644 --- a/website/docs/migration/from_state_notifier/old_lifecycles/old_lifecycles.g.dart +++ b/website/docs/migration/from_state_notifier/old_lifecycles/old_lifecycles.g.dart @@ -54,7 +54,7 @@ final class MyNotifierProvider extends $NotifierProvider { @override MyNotifierProvider $copyWithBuild( int Function( - Ref, + Ref, MyNotifier, ) build, ) { @@ -78,4 +78,4 @@ abstract class _$MyNotifier extends $Notifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/migration/from_state_notifier/old_lifecycles_final/old_lifecycles_final.dart b/website/docs/migration/from_state_notifier/old_lifecycles_final/old_lifecycles_final.dart index ec601378e..7c0233912 100644 --- a/website/docs/migration/from_state_notifier/old_lifecycles_final/old_lifecycles_final.dart +++ b/website/docs/migration/from_state_notifier/old_lifecycles_final/old_lifecycles_final.dart @@ -6,11 +6,11 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'old_lifecycles_final.g.dart'; @riverpod -Duration duration(DurationRef ref) => const Duration(seconds: 1); +Duration duration(Ref ref) => const Duration(seconds: 1); @riverpod // ignore: library_private_types_in_public_api -_MyRepo repository(RepositoryRef ref) => _MyRepo(); +_MyRepo repository(Ref ref) => _MyRepo(); class _MyRepo { Future update(int i, {CancelToken? token}) async {} diff --git a/website/docs/migration/from_state_notifier/old_lifecycles_final/old_lifecycles_final.g.dart b/website/docs/migration/from_state_notifier/old_lifecycles_final/old_lifecycles_final.g.dart index d1bbb1248..02f0ae7a2 100644 --- a/website/docs/migration/from_state_notifier/old_lifecycles_final/old_lifecycles_final.g.dart +++ b/website/docs/migration/from_state_notifier/old_lifecycles_final/old_lifecycles_final.g.dart @@ -8,16 +8,14 @@ part of 'old_lifecycles_final.dart'; // RiverpodGenerator // ************************************************************************** -typedef DurationRef = Ref; - @ProviderFor(duration) const durationProvider = DurationProvider._(); final class DurationProvider extends $FunctionalProvider - with $Provider { + with $Provider { const DurationProvider._( {Duration Function( - DurationRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -31,7 +29,7 @@ final class DurationProvider extends $FunctionalProvider ); final Duration Function( - DurationRef ref, + Ref ref, )? _createCb; @override @@ -53,31 +51,29 @@ final class DurationProvider extends $FunctionalProvider @override DurationProvider $copyWithCreate( Duration Function( - DurationRef ref, + Ref ref, ) create, ) { return DurationProvider._(create: create); } @override - Duration create(DurationRef ref) { + Duration create(Ref ref) { final _$cb = _createCb ?? duration; return _$cb(ref); } } -String _$durationHash() => r'be282a34a01007c6f3e04447579609199306aecc'; - -typedef RepositoryRef = Ref<_MyRepo>; +String _$durationHash() => r'997cacfb78da8107053428dfc5515497354b50c6'; @ProviderFor(repository) const repositoryProvider = RepositoryProvider._(); final class RepositoryProvider extends $FunctionalProvider<_MyRepo, _MyRepo> - with $Provider<_MyRepo, RepositoryRef> { + with $Provider<_MyRepo> { const RepositoryProvider._( {_MyRepo Function( - RepositoryRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -91,7 +87,7 @@ final class RepositoryProvider extends $FunctionalProvider<_MyRepo, _MyRepo> ); final _MyRepo Function( - RepositoryRef ref, + Ref ref, )? _createCb; @override @@ -113,20 +109,20 @@ final class RepositoryProvider extends $FunctionalProvider<_MyRepo, _MyRepo> @override RepositoryProvider $copyWithCreate( _MyRepo Function( - RepositoryRef ref, + Ref ref, ) create, ) { return RepositoryProvider._(create: create); } @override - _MyRepo create(RepositoryRef ref) { + _MyRepo create(Ref ref) { final _$cb = _createCb ?? repository; return _$cb(ref); } } -String _$repositoryHash() => r'80732dff4b7c3731f85f4c5ae72c820ae349c7fe'; +String _$repositoryHash() => r'8c1b035ba722660550674e92444db7b6f25ac2a3'; @ProviderFor(MyNotifier) const myNotifierProvider = MyNotifierProvider._(); @@ -174,7 +170,7 @@ final class MyNotifierProvider extends $NotifierProvider { @override MyNotifierProvider $copyWithBuild( int Function( - Ref, + Ref, MyNotifier, ) build, ) { @@ -198,4 +194,4 @@ abstract class _$MyNotifier extends $Notifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/migration/from_state_notifier/old_lifecycles_old.dart b/website/docs/migration/from_state_notifier/old_lifecycles_old.dart index 880fcee10..2b6e8b335 100644 --- a/website/docs/migration/from_state_notifier/old_lifecycles_old.dart +++ b/website/docs/migration/from_state_notifier/old_lifecycles_old.dart @@ -21,7 +21,7 @@ class MyNotifier extends StateNotifier { _timer = Timer.periodic(period, (t) => update()); // 2 side effect on init } final Duration period; - final Ref ref; + final Ref ref; late final Timer _timer; Future update() async { diff --git a/website/docs/providers/future_provider/config_provider/codegen.dart b/website/docs/providers/future_provider/config_provider/codegen.dart index 2aa87a29e..e862b79f8 100644 --- a/website/docs/providers/future_provider/config_provider/codegen.dart +++ b/website/docs/providers/future_provider/config_provider/codegen.dart @@ -5,6 +5,7 @@ import 'dart:convert'; import 'package:flutter/services.dart'; import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'codegen.g.dart'; + class Configuration { Configuration.fromJson(Map json); final String host = ''; @@ -13,7 +14,7 @@ class Configuration { /* SNIPPET START */ @riverpod -Future fetchConfiguration(FetchConfigurationRef ref) async { +Future fetchConfiguration(Ref ref) async { final content = json.decode( await rootBundle.loadString('assets/configurations.json'), ) as Map; diff --git a/website/docs/providers/future_provider/config_provider/codegen.g.dart b/website/docs/providers/future_provider/config_provider/codegen.g.dart index 552b84192..4464c19c8 100644 --- a/website/docs/providers/future_provider/config_provider/codegen.g.dart +++ b/website/docs/providers/future_provider/config_provider/codegen.g.dart @@ -8,19 +8,15 @@ part of 'codegen.dart'; // RiverpodGenerator // ************************************************************************** -typedef FetchConfigurationRef = Ref>; - @ProviderFor(fetchConfiguration) const fetchConfigurationProvider = FetchConfigurationProvider._(); final class FetchConfigurationProvider extends $FunctionalProvider< AsyncValue, FutureOr> - with - $FutureModifier, - $FutureProvider { + with $FutureModifier, $FutureProvider { const FetchConfigurationProvider._( {FutureOr Function( - FetchConfigurationRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -34,7 +30,7 @@ final class FetchConfigurationProvider extends $FunctionalProvider< ); final FutureOr Function( - FetchConfigurationRef ref, + Ref ref, )? _createCb; @override @@ -49,21 +45,21 @@ final class FetchConfigurationProvider extends $FunctionalProvider< @override FetchConfigurationProvider $copyWithCreate( FutureOr Function( - FetchConfigurationRef ref, + Ref ref, ) create, ) { return FetchConfigurationProvider._(create: create); } @override - FutureOr create(FetchConfigurationRef ref) { + FutureOr create(Ref ref) { final _$cb = _createCb ?? fetchConfiguration; return _$cb(ref); } } String _$fetchConfigurationHash() => - r'6c0f062e6f20baf883c4282856f1197fbe633d89'; + r'f18dd06ced5e58734c6fd925e5614c34e94d1b9e'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/providers/notifier_provider/remote_todos/codegen.g.dart b/website/docs/providers/notifier_provider/remote_todos/codegen.g.dart index 89721667f..3f847060c 100644 --- a/website/docs/providers/notifier_provider/remote_todos/codegen.g.dart +++ b/website/docs/providers/notifier_provider/remote_todos/codegen.g.dart @@ -64,7 +64,7 @@ final class AsyncTodosProvider @override AsyncTodosProvider $copyWithBuild( FutureOr> Function( - Ref>>, + Ref, AsyncTodos, ) build, ) { @@ -88,4 +88,4 @@ abstract class _$AsyncTodos extends $AsyncNotifier> { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/providers/notifier_provider/todos/codegen.g.dart b/website/docs/providers/notifier_provider/todos/codegen.g.dart index 2cd348c1d..efd558a2c 100644 --- a/website/docs/providers/notifier_provider/todos/codegen.g.dart +++ b/website/docs/providers/notifier_provider/todos/codegen.g.dart @@ -54,7 +54,7 @@ final class TodosProvider extends $NotifierProvider> { @override TodosProvider $copyWithBuild( List Function( - Ref>, + Ref, Todos, ) build, ) { @@ -78,4 +78,4 @@ abstract class _$Todos extends $Notifier> { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/providers/provider/completed_todos/completed_todos.dart b/website/docs/providers/provider/completed_todos/completed_todos.dart index 1a29d96f5..720a034ba 100644 --- a/website/docs/providers/provider/completed_todos/completed_todos.dart +++ b/website/docs/providers/provider/completed_todos/completed_todos.dart @@ -7,7 +7,7 @@ part 'completed_todos.g.dart'; /* SNIPPET START */ @riverpod -List completedTodos(CompletedTodosRef ref) { +List completedTodos(Ref ref) { final todos = ref.watch(todosProvider); // we return only the completed todos diff --git a/website/docs/providers/provider/completed_todos/completed_todos.g.dart b/website/docs/providers/provider/completed_todos/completed_todos.g.dart index 707b10a68..41474e4a3 100644 --- a/website/docs/providers/provider/completed_todos/completed_todos.g.dart +++ b/website/docs/providers/provider/completed_todos/completed_todos.g.dart @@ -8,17 +8,15 @@ part of 'completed_todos.dart'; // RiverpodGenerator // ************************************************************************** -typedef CompletedTodosRef = Ref>; - @ProviderFor(completedTodos) const completedTodosProvider = CompletedTodosProvider._(); final class CompletedTodosProvider extends $FunctionalProvider, List> - with $Provider, CompletedTodosRef> { + with $Provider> { const CompletedTodosProvider._( {List Function( - CompletedTodosRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -32,7 +30,7 @@ final class CompletedTodosProvider ); final List Function( - CompletedTodosRef ref, + Ref ref, )? _createCb; @override @@ -54,20 +52,20 @@ final class CompletedTodosProvider @override CompletedTodosProvider $copyWithCreate( List Function( - CompletedTodosRef ref, + Ref ref, ) create, ) { return CompletedTodosProvider._(create: create); } @override - List create(CompletedTodosRef ref) { + List create(Ref ref) { final _$cb = _createCb ?? completedTodos; return _$cb(ref); } } -String _$completedTodosHash() => r'855706c09268f428696b3b382ae1605818361b83'; +String _$completedTodosHash() => r'0a6a67db7f22556b2cd64236815fdd4d2e72a72b'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/providers/provider/optimized_previous_button/optimized_previous_button.dart b/website/docs/providers/provider/optimized_previous_button/optimized_previous_button.dart index 7d3b8a332..4c36fafd9 100644 --- a/website/docs/providers/provider/optimized_previous_button/optimized_previous_button.dart +++ b/website/docs/providers/provider/optimized_previous_button/optimized_previous_button.dart @@ -22,7 +22,7 @@ class PageIndex extends _$PageIndex { // A provider which computes whether the user is allowed to go to the previous page @riverpod /* highlight-start */ -bool canGoToPreviousPage(CanGoToPreviousPageRef ref) { +bool canGoToPreviousPage(Ref ref) { /* highlight-end */ return ref.watch(pageIndexProvider) != 0; } diff --git a/website/docs/providers/provider/optimized_previous_button/optimized_previous_button.g.dart b/website/docs/providers/provider/optimized_previous_button/optimized_previous_button.g.dart index c64586e3f..8d7ca5e1f 100644 --- a/website/docs/providers/provider/optimized_previous_button/optimized_previous_button.g.dart +++ b/website/docs/providers/provider/optimized_previous_button/optimized_previous_button.g.dart @@ -54,7 +54,7 @@ final class PageIndexProvider extends $NotifierProvider { @override PageIndexProvider $copyWithBuild( int Function( - Ref, + Ref, PageIndex, ) build, ) { @@ -77,16 +77,14 @@ abstract class _$PageIndex extends $Notifier { int runBuild() => build(); } -typedef CanGoToPreviousPageRef = Ref; - @ProviderFor(canGoToPreviousPage) const canGoToPreviousPageProvider = CanGoToPreviousPageProvider._(); final class CanGoToPreviousPageProvider extends $FunctionalProvider - with $Provider { + with $Provider { const CanGoToPreviousPageProvider._( {bool Function( - CanGoToPreviousPageRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -100,7 +98,7 @@ final class CanGoToPreviousPageProvider extends $FunctionalProvider ); final bool Function( - CanGoToPreviousPageRef ref, + Ref ref, )? _createCb; @override @@ -122,21 +120,21 @@ final class CanGoToPreviousPageProvider extends $FunctionalProvider @override CanGoToPreviousPageProvider $copyWithCreate( bool Function( - CanGoToPreviousPageRef ref, + Ref ref, ) create, ) { return CanGoToPreviousPageProvider._(create: create); } @override - bool create(CanGoToPreviousPageRef ref) { + bool create(Ref ref) { final _$cb = _createCb ?? canGoToPreviousPage; return _$cb(ref); } } String _$canGoToPreviousPageHash() => - r'801fe8182a37cd21ae83bdfccbe36c125b4d14fb'; + r'1cb9c497aa7e5e8ee03c5711f079c2b68a4c28c5'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/providers/provider/todo/todo.g.dart b/website/docs/providers/provider/todo/todo.g.dart index fde860cf8..cb2d43165 100644 --- a/website/docs/providers/provider/todo/todo.g.dart +++ b/website/docs/providers/provider/todo/todo.g.dart @@ -54,7 +54,7 @@ final class TodosProvider extends $NotifierProvider> { @override TodosProvider $copyWithBuild( List Function( - Ref>, + Ref, Todos, ) build, ) { @@ -78,4 +78,4 @@ abstract class _$Todos extends $Notifier> { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/providers/provider/unoptimized_previous_button/unoptimized_previous_button.g.dart b/website/docs/providers/provider/unoptimized_previous_button/unoptimized_previous_button.g.dart index ae755d0cd..f56618fca 100644 --- a/website/docs/providers/provider/unoptimized_previous_button/unoptimized_previous_button.g.dart +++ b/website/docs/providers/provider/unoptimized_previous_button/unoptimized_previous_button.g.dart @@ -54,7 +54,7 @@ final class PageIndexProvider extends $NotifierProvider { @override PageIndexProvider $copyWithBuild( int Function( - Ref, + Ref, PageIndex, ) build, ) { @@ -78,4 +78,4 @@ abstract class _$PageIndex extends $Notifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/docs/providers/stream_provider/live_stream_chat_provider/codegen.dart b/website/docs/providers/stream_provider/live_stream_chat_provider/codegen.dart index e2e34878c..6ac7b13c4 100644 --- a/website/docs/providers/stream_provider/live_stream_chat_provider/codegen.dart +++ b/website/docs/providers/stream_provider/live_stream_chat_provider/codegen.dart @@ -9,7 +9,7 @@ part 'codegen.g.dart'; /* SNIPPET START */ @riverpod -Stream> chat(ChatRef ref) async* { +Stream> chat(Ref ref) async* { // Connect to an API using sockets, and decode the output final socket = await Socket.connect('my-api', 4242); ref.onDispose(socket.close); diff --git a/website/docs/providers/stream_provider/live_stream_chat_provider/codegen.g.dart b/website/docs/providers/stream_provider/live_stream_chat_provider/codegen.g.dart index 4a02bafb4..4c5c4e59b 100644 --- a/website/docs/providers/stream_provider/live_stream_chat_provider/codegen.g.dart +++ b/website/docs/providers/stream_provider/live_stream_chat_provider/codegen.g.dart @@ -8,17 +8,15 @@ part of 'codegen.dart'; // RiverpodGenerator // ************************************************************************** -typedef ChatRef = Ref>>; - @ProviderFor(chat) const chatProvider = ChatProvider._(); final class ChatProvider extends $FunctionalProvider>, Stream>> - with $FutureModifier>, $StreamProvider, ChatRef> { + with $FutureModifier>, $StreamProvider> { const ChatProvider._( {Stream> Function( - ChatRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -32,7 +30,7 @@ final class ChatProvider ); final Stream> Function( - ChatRef ref, + Ref ref, )? _createCb; @override @@ -47,20 +45,20 @@ final class ChatProvider @override ChatProvider $copyWithCreate( Stream> Function( - ChatRef ref, + Ref ref, ) create, ) { return ChatProvider._(create: create); } @override - Stream> create(ChatRef ref) { + Stream> create(Ref ref) { final _$cb = _createCb ?? chat; return _$cb(ref); } } -String _$chatHash() => r'db1302132f90e854fe2f5da9d97d89c9a3c8b858'; +String _$chatHash() => r'bad093d5344471463a1e71688281924642f3a58c'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/i18n/bn/docusaurus-plugin-content-docs/current/concepts/combining_providers.mdx b/website/i18n/bn/docusaurus-plugin-content-docs/current/concepts/combining_providers.mdx index 970aea954..1ca5b48cc 100644 --- a/website/i18n/bn/docusaurus-plugin-content-docs/current/concepts/combining_providers.mdx +++ b/website/i18n/bn/docusaurus-plugin-content-docs/current/concepts/combining_providers.mdx @@ -166,7 +166,7 @@ final repositoryProvider = Provider((ref) => Repository(ref)); class Repository { Repository(this.ref); - final Ref ref; + final Ref ref; } ``` diff --git a/website/i18n/bn/docusaurus-plugin-content-docs/current/concepts/reading_counter.dart b/website/i18n/bn/docusaurus-plugin-content-docs/current/concepts/reading_counter.dart index d4cacfdd8..c8abd8706 100644 --- a/website/i18n/bn/docusaurus-plugin-content-docs/current/concepts/reading_counter.dart +++ b/website/i18n/bn/docusaurus-plugin-content-docs/current/concepts/reading_counter.dart @@ -16,7 +16,7 @@ final counterProvider = StateNotifierProvider((ref) { class Counter extends StateNotifier { Counter(this.ref) : super(0); - final Ref ref; + final Ref ref; void increment() { // Counter এই "ref" অবজেক্ট ব্যবহার করে অন্য প্রভাইডার পড়তে পারবে diff --git a/website/i18n/de/docusaurus-plugin-content-docs/current/concepts/combining_providers.mdx b/website/i18n/de/docusaurus-plugin-content-docs/current/concepts/combining_providers.mdx index c2902ddac..91c4c2a46 100644 --- a/website/i18n/de/docusaurus-plugin-content-docs/current/concepts/combining_providers.mdx +++ b/website/i18n/de/docusaurus-plugin-content-docs/current/concepts/combining_providers.mdx @@ -174,7 +174,7 @@ final repositoryProvider = Provider((ref) => Repository(ref)); class Repository { Repository(this.ref); - final Ref ref; + final Ref ref; } ``` diff --git a/website/i18n/de/docusaurus-plugin-content-docs/current/concepts/reading_counter.dart b/website/i18n/de/docusaurus-plugin-content-docs/current/concepts/reading_counter.dart index feee2608b..103dd40d4 100644 --- a/website/i18n/de/docusaurus-plugin-content-docs/current/concepts/reading_counter.dart +++ b/website/i18n/de/docusaurus-plugin-content-docs/current/concepts/reading_counter.dart @@ -16,7 +16,7 @@ final counterProvider = StateNotifierProvider((ref) { class Counter extends StateNotifier { Counter(this.ref) : super(0); - final Ref ref; + final Ref ref; void increment() { // Counter kann "ref" dazu benutzen um andere Provider auszulesen diff --git a/website/i18n/es/docusaurus-plugin-content-docs/current/concepts/combining_providers.mdx b/website/i18n/es/docusaurus-plugin-content-docs/current/concepts/combining_providers.mdx index 4c30a0c51..395bd4730 100644 --- a/website/i18n/es/docusaurus-plugin-content-docs/current/concepts/combining_providers.mdx +++ b/website/i18n/es/docusaurus-plugin-content-docs/current/concepts/combining_providers.mdx @@ -166,7 +166,7 @@ final repositoryProvider = Provider((ref) => Repository(ref)); class Repository { Repository(this.ref); - final Ref ref; + final Ref ref; } ``` Sin embargo, pasar `ref.read` da como resultado un código un poco menos verboso diff --git a/website/i18n/es/docusaurus-plugin-content-docs/current/concepts/reading.mdx b/website/i18n/es/docusaurus-plugin-content-docs/current/concepts/reading.mdx index f49ebaf7c..81b1e7b2e 100644 --- a/website/i18n/es/docusaurus-plugin-content-docs/current/concepts/reading.mdx +++ b/website/i18n/es/docusaurus-plugin-content-docs/current/concepts/reading.mdx @@ -39,7 +39,7 @@ final counter = StateNotifierProvider((ref) { class Counter extends StateNotifier { Counter(this.ref): super(0); - final Ref ref; + final Ref ref; void increment() { // `Counter` puede usar la "ref" para leer otros providers diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/current/about_codegen/main.dart b/website/i18n/fr/docusaurus-plugin-content-docs/current/about_codegen/main.dart index 1ccb42807..6dbbf14aa 100644 --- a/website/i18n/fr/docusaurus-plugin-content-docs/current/about_codegen/main.dart +++ b/website/i18n/fr/docusaurus-plugin-content-docs/current/about_codegen/main.dart @@ -16,7 +16,7 @@ final http = Http(); /* SNIPPET START */ @riverpod -Future fetchUser(FetchUserRef ref, {required int userId}) async { +Future fetchUser(Ref ref, {required int userId}) async { final json = await http.get('api/user/$userId'); return User.fromJson(json); } diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/current/about_hooks.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/current/about_hooks.mdx index 705bbb7ae..04386796e 100644 --- a/website/i18n/fr/docusaurus-plugin-content-docs/current/about_hooks.mdx +++ b/website/i18n/fr/docusaurus-plugin-content-docs/current/about_hooks.mdx @@ -52,7 +52,7 @@ En général, les hokks sont utiles pour : - les formulaires - les animations - la réaction aux événements de l'utilisateur -- ... +- etc. Par exemple, nous pourrions utiliser les hooks pour implémenter manuellement une animation en fondu, où un widget commence invisible et apparaît lentement. diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/current/concepts/combining_providers.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/current/concepts/combining_providers.mdx index 82260ba01..cfa1da36c 100644 --- a/website/i18n/fr/docusaurus-plugin-content-docs/current/concepts/combining_providers.mdx +++ b/website/i18n/fr/docusaurus-plugin-content-docs/current/concepts/combining_providers.mdx @@ -174,7 +174,7 @@ final repositoryProvider = Provider((ref) => Repository(ref)); class Repository { Repository(this.ref); - final Ref ref; + final Ref ref; } ``` diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/current/concepts/reading_counter.dart b/website/i18n/fr/docusaurus-plugin-content-docs/current/concepts/reading_counter.dart index 9c7c301a1..87f981849 100644 --- a/website/i18n/fr/docusaurus-plugin-content-docs/current/concepts/reading_counter.dart +++ b/website/i18n/fr/docusaurus-plugin-content-docs/current/concepts/reading_counter.dart @@ -16,7 +16,7 @@ final counterProvider = StateNotifierProvider((ref) { class Counter extends StateNotifier { Counter(this.ref) : super(0); - final Ref ref; + final Ref ref; void increment() { // Counter peut utiliser le "ref" pour lire d'autres providers diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/current/getting_started/dart_hello_world/main.dart b/website/i18n/fr/docusaurus-plugin-content-docs/current/getting_started/dart_hello_world/main.dart index a7c49d638..4a9361d1d 100644 --- a/website/i18n/fr/docusaurus-plugin-content-docs/current/getting_started/dart_hello_world/main.dart +++ b/website/i18n/fr/docusaurus-plugin-content-docs/current/getting_started/dart_hello_world/main.dart @@ -9,7 +9,7 @@ part 'main.g.dart'; // We create a "provider", which will store a value (here "Hello world"). // By using a provider, this allows us to mock/override the value exposed. @riverpod -String helloWorld(HelloWorldRef ref) { +String helloWorld(Ref ref) { return 'Hello world'; } diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/current/getting_started/hello_world/main.dart b/website/i18n/fr/docusaurus-plugin-content-docs/current/getting_started/hello_world/main.dart index f03708b64..11c0f9cb3 100644 --- a/website/i18n/fr/docusaurus-plugin-content-docs/current/getting_started/hello_world/main.dart +++ b/website/i18n/fr/docusaurus-plugin-content-docs/current/getting_started/hello_world/main.dart @@ -11,7 +11,7 @@ part 'main.g.dart'; // We create a "provider", which will store a value (here "Hello world"). // By using a provider, this allows us to mock/override the value exposed. @riverpod -String helloWorld(HelloWorldRef ref) { +String helloWorld(Ref ref) { return 'Hello world'; } diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/current/introduction.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/current/introduction.mdx index 210549880..9108476fd 100644 --- a/website/i18n/fr/docusaurus-plugin-content-docs/current/introduction.mdx +++ b/website/i18n/fr/docusaurus-plugin-content-docs/current/introduction.mdx @@ -35,9 +35,9 @@ influencés par un grand nombre de fonctionnalités, telles que : - rechercher en tapant - debouncing des requêtes asynchrones - annulation des requêtes asynchrones lorsqu'elles ne sont plus utilisées -- interfaces utilisateur optimistes +- interfaces utilisateur optimistes - mode hors ligne -- ... +- etc. Ces fonctionnalités peuvent être délicates à mettre en œuvre, mais sont cruciales pour une bonne expérience utilisateur. @@ -59,7 +59,7 @@ implémentée à l'aide de Riverpod. // Récupère la liste des packages depuis pub.dev @riverpod Future> fetchPackages( - FetchPackagesRef ref, { + Ref ref, { required int page, String search = '', }) async { diff --git a/website/i18n/it/docusaurus-plugin-content-docs/current/case_studies/cancel/extension.dart b/website/i18n/it/docusaurus-plugin-content-docs/current/case_studies/cancel/extension.dart index cdebd482e..2db7bba89 100644 --- a/website/i18n/it/docusaurus-plugin-content-docs/current/case_studies/cancel/extension.dart +++ b/website/i18n/it/docusaurus-plugin-content-docs/current/case_studies/cancel/extension.dart @@ -2,7 +2,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:http/http.dart' as http; /* SNIPPET START */ -extension DebounceAndCancelExtension on Ref { +extension DebounceAndCancelExtension on Ref { /// Aspetta per la [duration] (di default a 500ms) e poi ritorna un [http.Client] /// con il quale possiamo effettuare una richiesta. /// diff --git a/website/i18n/it/docusaurus-plugin-content-docs/current/concepts/combining_providers.mdx b/website/i18n/it/docusaurus-plugin-content-docs/current/concepts/combining_providers.mdx index 4466dcec9..e3aacdf73 100644 --- a/website/i18n/it/docusaurus-plugin-content-docs/current/concepts/combining_providers.mdx +++ b/website/i18n/it/docusaurus-plugin-content-docs/current/concepts/combining_providers.mdx @@ -161,7 +161,7 @@ final repositoryProvider = Provider((ref) => Repository(ref)); class Repository { Repository(this.ref); - final Ref ref; + final Ref ref; } ``` L'unica differenza che comporta passare `ref.read` è la scrittura di meno codice, inoltre, diff --git a/website/i18n/it/docusaurus-plugin-content-docs/current/essentials/first_request.mdx b/website/i18n/it/docusaurus-plugin-content-docs/current/essentials/first_request.mdx index e7bec27f3..c71c2745c 100644 --- a/website/i18n/it/docusaurus-plugin-content-docs/current/essentials/first_request.mdx +++ b/website/i18n/it/docusaurus-plugin-content-docs/current/essentials/first_request.mdx @@ -177,7 +177,7 @@ Le letture successive non chiameranno nuovamente la funzione, ma restituiranno i } `} @@ -216,7 +216,7 @@ Le letture successive non chiameranno nuovamente la funzione, ma restituiranno i }, { offset: 28, - length: 17, + length: 7, label: "Ref", description: <> diff --git a/website/i18n/it/docusaurus-plugin-content-docs/current/essentials/first_request/codegen/provider.dart b/website/i18n/it/docusaurus-plugin-content-docs/current/essentials/first_request/codegen/provider.dart index 24ae03d1a..f975eff35 100644 --- a/website/i18n/it/docusaurus-plugin-content-docs/current/essentials/first_request/codegen/provider.dart +++ b/website/i18n/it/docusaurus-plugin-content-docs/current/essentials/first_request/codegen/provider.dart @@ -13,7 +13,7 @@ part 'provider.g.dart'; /// This will create a provider named `activityProvider` /// which will cache the result of this function. @riverpod -Future activity(ActivityRef ref) async { +Future activity(Ref ref) async { // Usando il package http, otteniamo un'attività casuale dalle Bored API final response = await http.get(Uri.https('boredapi.com', '/api/activity')); // Usando dart:convert, decodifichiamo il payload JSON in una Map. diff --git a/website/i18n/it/docusaurus-plugin-content-docs/current/essentials/passing_args/codegen/family.dart b/website/i18n/it/docusaurus-plugin-content-docs/current/essentials/passing_args/codegen/family.dart index 15b704231..f3d02eb43 100644 --- a/website/i18n/it/docusaurus-plugin-content-docs/current/essentials/passing_args/codegen/family.dart +++ b/website/i18n/it/docusaurus-plugin-content-docs/current/essentials/passing_args/codegen/family.dart @@ -10,7 +10,7 @@ part 'family.g.dart'; /* SNIPPET START */ @riverpod Future activity( - ActivityRef ref, + Ref ref, // Possiamo aggiungere argomenti al provider // Il tipo del parametro può essere qualsiasi cosa tu voglia. String activityType, diff --git a/website/i18n/it/docusaurus-plugin-content-docs/current/essentials/passing_args/codegen/provider.dart b/website/i18n/it/docusaurus-plugin-content-docs/current/essentials/passing_args/codegen/provider.dart index f91c10052..8a2adf42e 100644 --- a/website/i18n/it/docusaurus-plugin-content-docs/current/essentials/passing_args/codegen/provider.dart +++ b/website/i18n/it/docusaurus-plugin-content-docs/current/essentials/passing_args/codegen/provider.dart @@ -12,7 +12,7 @@ FutureOr fetchActivity() => throw UnimplementedError(); /* SNIPPET START */ // Un provider "funzionale" @riverpod -Future activity(ActivityRef ref) async { +Future activity(Ref ref) async { // TODO: eseguire una richiesta di rete per ottenere un'attività. return fetchActivity(); } diff --git a/website/i18n/it/docusaurus-plugin-content-docs/current/essentials/side_effects/codegen/todo_list_provider.dart b/website/i18n/it/docusaurus-plugin-content-docs/current/essentials/side_effects/codegen/todo_list_provider.dart index 76ab146fd..5a16c314a 100644 --- a/website/i18n/it/docusaurus-plugin-content-docs/current/essentials/side_effects/codegen/todo_list_provider.dart +++ b/website/i18n/it/docusaurus-plugin-content-docs/current/essentials/side_effects/codegen/todo_list_provider.dart @@ -14,7 +14,7 @@ class Todo with _$Todo { /* SNIPPET START */ @riverpod -Future> todoList(TodoListRef ref) async { +Future> todoList(Ref ref) async { // Simula una richiesta di rete. Normalmente il risultato dovrebbe venire da una API reale return [ Todo(description: 'Learn Flutter', completed: true), diff --git a/website/i18n/it/docusaurus-plugin-content-docs/current/from_provider/quickstart.mdx b/website/i18n/it/docusaurus-plugin-content-docs/current/from_provider/quickstart.mdx index d47e57bde..4a66f0ba7 100644 --- a/website/i18n/it/docusaurus-plugin-content-docs/current/from_provider/quickstart.mdx +++ b/website/i18n/it/docusaurus-plugin-content-docs/current/from_provider/quickstart.mdx @@ -156,7 +156,7 @@ Successivamente, puoi esporre il tuo `ChangeNotifier` con la seguente sintassi c ```dart // ignore_for_file: unsupported_provider_value @riverpod -MyNotifier example(ExampleRef ref) { +MyNotifier example(Ref ref) { return ref.listenAndDisposeChangeNotifier(MyNotifier()); } ``` diff --git a/website/i18n/it/docusaurus-plugin-content-docs/current/migration/utils.dart b/website/i18n/it/docusaurus-plugin-content-docs/current/migration/utils.dart index ad922b1e3..37d1d7f83 100644 --- a/website/i18n/it/docusaurus-plugin-content-docs/current/migration/utils.dart +++ b/website/i18n/it/docusaurus-plugin-content-docs/current/migration/utils.dart @@ -5,19 +5,19 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'utils.g.dart'; @riverpod -int random(RandomRef ref) { +int random(Ref ref) { return math.Random().nextInt(6); } @riverpod -TaskTrackerRepo taskTracker(TaskTrackerRef ref) => TaskTrackerRepo(); +TaskTrackerRepo taskTracker(Ref ref) => TaskTrackerRepo(); class TaskTrackerRepo { Future fix({required String id, required int fixed}) async => 0; } @riverpod -Duration duration(DurationRef ref) => Duration.zero; +Duration duration(Ref ref) => Duration.zero; @riverpod -int availableWater(AvailableWaterRef ref) => 40; +int availableWater(Ref ref) => 40; diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/current/about_codegen/main.dart b/website/i18n/ja/docusaurus-plugin-content-docs/current/about_codegen/main.dart index 1ccb42807..6dbbf14aa 100644 --- a/website/i18n/ja/docusaurus-plugin-content-docs/current/about_codegen/main.dart +++ b/website/i18n/ja/docusaurus-plugin-content-docs/current/about_codegen/main.dart @@ -16,7 +16,7 @@ final http = Http(); /* SNIPPET START */ @riverpod -Future fetchUser(FetchUserRef ref, {required int userId}) async { +Future fetchUser(Ref ref, {required int userId}) async { final json = await http.get('api/user/$userId'); return User.fromJson(json); } diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/current/concepts/combining_providers.mdx b/website/i18n/ja/docusaurus-plugin-content-docs/current/concepts/combining_providers.mdx index ce41b30d1..7caaeb576 100644 --- a/website/i18n/ja/docusaurus-plugin-content-docs/current/concepts/combining_providers.mdx +++ b/website/i18n/ja/docusaurus-plugin-content-docs/current/concepts/combining_providers.mdx @@ -161,7 +161,7 @@ final repositoryProvider = Provider((ref) => Repository(ref)); class Repository { Repository(this.ref); - final Ref ref; + final Ref ref; } ``` diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/current/concepts/reading_counter.dart b/website/i18n/ja/docusaurus-plugin-content-docs/current/concepts/reading_counter.dart index 3c02b890e..3640d66a6 100644 --- a/website/i18n/ja/docusaurus-plugin-content-docs/current/concepts/reading_counter.dart +++ b/website/i18n/ja/docusaurus-plugin-content-docs/current/concepts/reading_counter.dart @@ -16,7 +16,7 @@ final counterProvider = StateNotifierProvider((ref) { class Counter extends StateNotifier { Counter(this.ref) : super(0); - final Ref ref; + final Ref ref; void increment() { // Counter は `ref` を使って他のプロバイダーを利用することができる diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/current/essentials/first_request.mdx b/website/i18n/ja/docusaurus-plugin-content-docs/current/essentials/first_request.mdx index b601703f3..875a93235 100644 --- a/website/i18n/ja/docusaurus-plugin-content-docs/current/essentials/first_request.mdx +++ b/website/i18n/ja/docusaurus-plugin-content-docs/current/essentials/first_request.mdx @@ -184,7 +184,7 @@ provider のロジックを配置する場所です。 } `} @@ -223,7 +223,7 @@ Result myFunction(MyFunctionRef ref) { }, { offset: 28, - length: 17, + length: 7, label: "Ref", description: <> diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/current/from_provider/quickstart.mdx b/website/i18n/ja/docusaurus-plugin-content-docs/current/from_provider/quickstart.mdx index b60aaaaed..e3be6ad72 100644 --- a/website/i18n/ja/docusaurus-plugin-content-docs/current/from_provider/quickstart.mdx +++ b/website/i18n/ja/docusaurus-plugin-content-docs/current/from_provider/quickstart.mdx @@ -162,7 +162,7 @@ extension ChangeNotifierWithCodeGenExtension on Ref { ```dart // ignore_for_file: unsupported_provider_value @riverpod -MyNotifier example(ExampleRef ref) { +MyNotifier example(Ref ref) { return ref.listenAndDisposeChangeNotifier(MyNotifier()); } ``` diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/current/getting_started/dart_hello_world/main.dart b/website/i18n/ja/docusaurus-plugin-content-docs/current/getting_started/dart_hello_world/main.dart index a7c49d638..4a9361d1d 100644 --- a/website/i18n/ja/docusaurus-plugin-content-docs/current/getting_started/dart_hello_world/main.dart +++ b/website/i18n/ja/docusaurus-plugin-content-docs/current/getting_started/dart_hello_world/main.dart @@ -9,7 +9,7 @@ part 'main.g.dart'; // We create a "provider", which will store a value (here "Hello world"). // By using a provider, this allows us to mock/override the value exposed. @riverpod -String helloWorld(HelloWorldRef ref) { +String helloWorld(Ref ref) { return 'Hello world'; } diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/current/getting_started/hello_world/main.dart b/website/i18n/ja/docusaurus-plugin-content-docs/current/getting_started/hello_world/main.dart index f03708b64..11c0f9cb3 100644 --- a/website/i18n/ja/docusaurus-plugin-content-docs/current/getting_started/hello_world/main.dart +++ b/website/i18n/ja/docusaurus-plugin-content-docs/current/getting_started/hello_world/main.dart @@ -11,7 +11,7 @@ part 'main.g.dart'; // We create a "provider", which will store a value (here "Hello world"). // By using a provider, this allows us to mock/override the value exposed. @riverpod -String helloWorld(HelloWorldRef ref) { +String helloWorld(Ref ref) { return 'Hello world'; } diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/current/introduction.mdx b/website/i18n/ja/docusaurus-plugin-content-docs/current/introduction.mdx index a5f0d1c2c..513376b7f 100644 --- a/website/i18n/ja/docusaurus-plugin-content-docs/current/introduction.mdx +++ b/website/i18n/ja/docusaurus-plugin-content-docs/current/introduction.mdx @@ -51,7 +51,7 @@ Riverpod は Flutter の widget にインスパイアされた、 // pub.dev からパッケージ一覧を取得する @riverpod Future> fetchPackages( - FetchPackagesRef ref, { + Ref ref, { required int page, String search = '', }) async { diff --git a/website/i18n/ko/docusaurus-plugin-content-docs/current/concepts/about_hooks.mdx b/website/i18n/ko/docusaurus-plugin-content-docs/current/concepts/about_hooks.mdx index 7516cbbae..aab39806d 100644 --- a/website/i18n/ko/docusaurus-plugin-content-docs/current/concepts/about_hooks.mdx +++ b/website/i18n/ko/docusaurus-plugin-content-docs/current/concepts/about_hooks.mdx @@ -49,7 +49,7 @@ Riverpod의 provider가 "전역(Global)" 애플리케이션 상태(State)를 위 - 폼(forms) - 애니메이션(animations) - 사용자 이벤트에 반응하기(reacting to user events) -- ... +- etc. 예를 들어, 훅(Hooks)를 위젯이 보이지 않다가 서서히 나타나는 페이드인(Fade-in) 애니메이션을 직접 구현하는데 사용할 수 있습니다. diff --git a/website/i18n/ko/docusaurus-plugin-content-docs/current/concepts/combining_providers.mdx b/website/i18n/ko/docusaurus-plugin-content-docs/current/concepts/combining_providers.mdx index 6d01aa2e0..1714af6af 100644 --- a/website/i18n/ko/docusaurus-plugin-content-docs/current/concepts/combining_providers.mdx +++ b/website/i18n/ko/docusaurus-plugin-content-docs/current/concepts/combining_providers.mdx @@ -163,7 +163,7 @@ final repositoryProvider = Provider((ref) => Repository(ref)); class Repository { Repository(this.ref); - final Ref ref; + final Ref ref; } ``` diff --git a/website/i18n/ko/docusaurus-plugin-content-docs/current/essentials/first_request.mdx b/website/i18n/ko/docusaurus-plugin-content-docs/current/essentials/first_request.mdx index 2d7957eb8..f9b79eead 100644 --- a/website/i18n/ko/docusaurus-plugin-content-docs/current/essentials/first_request.mdx +++ b/website/i18n/ko/docusaurus-plugin-content-docs/current/essentials/first_request.mdx @@ -180,7 +180,7 @@ provider 타입은 자연스럽게 따라올 것입니다. } `} @@ -219,7 +219,7 @@ Result myFunction(MyFunctionRef ref) { }, { offset: 28, - length: 17, + length: 7, label: "Ref", description: <> @@ -274,7 +274,7 @@ provider는 당연히 "ref" 객체에 액세스할 수 있으므로 이전에 pr 하지만 여기서는 provider가 아니라 위젯에 있습니다. 그렇다면 "ref"는 어떻게 얻을 수 있을까요? 해결책은 `Consumer`라는 커스텀 위젯을 사용하는 것입니다. -`Consumer`는 `Builder`와 비슷한 위젲이지만, "ref"를 제공한다는 추가적인 이점이 있습니다. +`Consumer`는 `Builder`와 비슷한 위젯이지만, "ref"를 제공한다는 추가적인 이점이 있습니다. 이를 통해 UI가 provider들을 읽을 수 있습니다. 다음 예제는 `Consumer`를 사용하는 방법을 보여줍니다: diff --git a/website/i18n/ko/docusaurus-plugin-content-docs/current/from_provider/quickstart.mdx b/website/i18n/ko/docusaurus-plugin-content-docs/current/from_provider/quickstart.mdx index d3a3fa6c0..650ae7b82 100644 --- a/website/i18n/ko/docusaurus-plugin-content-docs/current/from_provider/quickstart.mdx +++ b/website/i18n/ko/docusaurus-plugin-content-docs/current/from_provider/quickstart.mdx @@ -158,7 +158,7 @@ extension ChangeNotifierWithCodeGenExtension on Ref { ```dart // ignore_for_file: unsupported_provider_value @riverpod -MyNotifier example(ExampleRef ref) { +MyNotifier example(Ref ref) { return ref.listenAndDisposeChangeNotifier(MyNotifier()); } ``` diff --git a/website/i18n/ko/docusaurus-plugin-content-docs/current/migration/utils.dart b/website/i18n/ko/docusaurus-plugin-content-docs/current/migration/utils.dart index ad922b1e3..37d1d7f83 100644 --- a/website/i18n/ko/docusaurus-plugin-content-docs/current/migration/utils.dart +++ b/website/i18n/ko/docusaurus-plugin-content-docs/current/migration/utils.dart @@ -5,19 +5,19 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'utils.g.dart'; @riverpod -int random(RandomRef ref) { +int random(Ref ref) { return math.Random().nextInt(6); } @riverpod -TaskTrackerRepo taskTracker(TaskTrackerRef ref) => TaskTrackerRepo(); +TaskTrackerRepo taskTracker(Ref ref) => TaskTrackerRepo(); class TaskTrackerRepo { Future fix({required String id, required int fixed}) async => 0; } @riverpod -Duration duration(DurationRef ref) => Duration.zero; +Duration duration(Ref ref) => Duration.zero; @riverpod -int availableWater(AvailableWaterRef ref) => 40; +int availableWater(Ref ref) => 40; diff --git a/website/i18n/ru/docusaurus-plugin-content-docs/current/concepts/combining_providers.mdx b/website/i18n/ru/docusaurus-plugin-content-docs/current/concepts/combining_providers.mdx index 578714d56..75d691be3 100644 --- a/website/i18n/ru/docusaurus-plugin-content-docs/current/concepts/combining_providers.mdx +++ b/website/i18n/ru/docusaurus-plugin-content-docs/current/concepts/combining_providers.mdx @@ -179,7 +179,7 @@ final repositoryProvider = Provider((ref) => Repository(ref)); class Repository { Repository(this.ref); - final Ref ref; + final Ref ref; } ``` diff --git a/website/i18n/ru/docusaurus-plugin-content-docs/current/concepts/reading_counter.dart b/website/i18n/ru/docusaurus-plugin-content-docs/current/concepts/reading_counter.dart index a92076a79..815cafe73 100644 --- a/website/i18n/ru/docusaurus-plugin-content-docs/current/concepts/reading_counter.dart +++ b/website/i18n/ru/docusaurus-plugin-content-docs/current/concepts/reading_counter.dart @@ -16,7 +16,7 @@ final counterProvider = StateNotifierProvider((ref) { class Counter extends StateNotifier { Counter(this.ref) : super(0); - final Ref ref; + final Ref ref; void increment() { // Counter может использовать "ref" для чтения других провайдеров diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/case_studies/cancel/extension.dart b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/case_studies/cancel/extension.dart index 2f2becfc5..8a06acb22 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/case_studies/cancel/extension.dart +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/case_studies/cancel/extension.dart @@ -2,7 +2,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:http/http.dart' as http; /* SNIPPET START */ -extension DebounceAndCancelExtension on Ref { +extension DebounceAndCancelExtension on Ref { /// 等待 [duration](默认为 500ms), /// 然后返回一个 [http.Client],用于发出请求。 /// diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/combining_providers.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/combining_providers.mdx index 9b0ebf319..07a82f984 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/combining_providers.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/concepts/combining_providers.mdx @@ -131,7 +131,7 @@ final repositoryProvider = Provider(Repository.new); class Repository { Repository(this.ref); - final Ref ref; + final Ref ref; Future fetchCatalog() async { String token = ref.read(userTokenProvider); diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/essentials/first_request.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/essentials/first_request.mdx index 490a98fbf..b8777fb7b 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/essentials/first_request.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/essentials/first_request.mdx @@ -293,7 +293,7 @@ Subsequent reads will not call the function again, but instead return the cached } `} @@ -354,7 +354,7 @@ Subsequent reads will not call the function again, but instead return the cached }, { offset: 28, - length: 17, + length: 7, label: "Ref", description: <> diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/essentials/first_request/codegen/provider.dart b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/essentials/first_request/codegen/provider.dart index 0f70b54f6..ce35a3d4e 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/essentials/first_request/codegen/provider.dart +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/essentials/first_request/codegen/provider.dart @@ -9,7 +9,7 @@ part 'provider.g.dart'; /// 这将创建一个名为 `activityProvider` 的提供者程序 /// 它可以缓存函数执行的结果 @riverpod -Future activity(ActivityRef ref) async { +Future activity(Ref ref) async { // 使用 package:http, 我们可以从 Bored API 获取一个随机的活动。 final response = await http.get(Uri.https('boredapi.com', '/api/activity')); // 使用 dart:convert, 然后我们将 JSON 有效负载解码为 Map 数据结构。 diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/essentials/passing_args/codegen/family.dart b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/essentials/passing_args/codegen/family.dart index 7d5c4c260..93877649e 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/essentials/passing_args/codegen/family.dart +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/essentials/passing_args/codegen/family.dart @@ -8,7 +8,7 @@ part 'family.g.dart'; /* SNIPPET START */ @riverpod Future activity( - ActivityRef ref, + Ref ref, // 我们可以向提供者程序添加参数。 // 参数的类型可以是您想要的任何类型。 String activityType, diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/essentials/passing_args/codegen/provider.dart b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/essentials/passing_args/codegen/provider.dart index d2cd2b635..3c1a97cc7 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/essentials/passing_args/codegen/provider.dart +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/essentials/passing_args/codegen/provider.dart @@ -11,7 +11,7 @@ FutureOr fetchActivity() => throw UnimplementedError(); /* SNIPPET START */ // “函数型”提供者程序 @riverpod -Future activity(ActivityRef ref) async { +Future activity(Ref ref) async { // TODO: 执行网络请求以获取活动 return fetchActivity(); } diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/essentials/side_effects/codegen/todo_list_provider.dart b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/essentials/side_effects/codegen/todo_list_provider.dart index 88eb06c0e..2a4e5acea 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/essentials/side_effects/codegen/todo_list_provider.dart +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/essentials/side_effects/codegen/todo_list_provider.dart @@ -14,7 +14,7 @@ class Todo with _$Todo { } @riverpod -Future> todoList(TodoListRef ref) async { +Future> todoList(Ref ref) async { // 模拟一个网络请求。这通常来自真实的 API return [ Todo(description: 'Learn Flutter', completed: true), diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/from_provider/quickstart.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/from_provider/quickstart.mdx index d98512916..a95d57fc1 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/from_provider/quickstart.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/from_provider/quickstart.mdx @@ -333,7 +333,7 @@ And then, you can expose your `ChangeNotifier` with the following codegen syntax ```dart // ignore_for_file: unsupported_provider_value @riverpod -MyNotifier example(ExampleRef ref) { +MyNotifier example(Ref ref) { return ref.listenAndDisposeChangeNotifier(MyNotifier()); } ``` diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/migration/utils.dart b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/migration/utils.dart index ad922b1e3..37d1d7f83 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/migration/utils.dart +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/migration/utils.dart @@ -5,19 +5,19 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'utils.g.dart'; @riverpod -int random(RandomRef ref) { +int random(Ref ref) { return math.Random().nextInt(6); } @riverpod -TaskTrackerRepo taskTracker(TaskTrackerRef ref) => TaskTrackerRepo(); +TaskTrackerRepo taskTracker(Ref ref) => TaskTrackerRepo(); class TaskTrackerRepo { Future fix({required String id, required int fixed}) async => 0; } @riverpod -Duration duration(DurationRef ref) => Duration.zero; +Duration duration(Ref ref) => Duration.zero; @riverpod -int availableWater(AvailableWaterRef ref) => 40; +int availableWater(Ref ref) => 40; diff --git a/website/pubspec.yaml b/website/pubspec.yaml index 0a0847b5d..0684ef534 100644 --- a/website/pubspec.yaml +++ b/website/pubspec.yaml @@ -25,7 +25,7 @@ dependencies: dev_dependencies: build_runner: - custom_lint: ^0.6.4 + custom_lint: ^0.7.0 flutter_test: sdk: flutter freezed: ^2.2.0 diff --git a/website/static/snippets/async.dart b/website/static/snippets/async.dart index e3a5e86db..82b764d78 100644 --- a/website/static/snippets/async.dart +++ b/website/static/snippets/async.dart @@ -19,7 +19,7 @@ class Configuration { /* SNIPPET START */ @riverpod -Future configurations(ConfigurationsRef ref) async { +Future configurations(Ref ref) async { final uri = Uri.parse('configs.json'); final rawJson = await File.fromUri(uri).readAsString(); diff --git a/website/static/snippets/async.g.dart b/website/static/snippets/async.g.dart index b34a4deb5..974da642c 100644 --- a/website/static/snippets/async.g.dart +++ b/website/static/snippets/async.g.dart @@ -8,19 +8,15 @@ part of 'async.dart'; // RiverpodGenerator // ************************************************************************** -typedef ConfigurationsRef = Ref>; - @ProviderFor(configurations) const configurationsProvider = ConfigurationsProvider._(); final class ConfigurationsProvider extends $FunctionalProvider< AsyncValue, FutureOr> - with - $FutureModifier, - $FutureProvider { + with $FutureModifier, $FutureProvider { const ConfigurationsProvider._( {FutureOr Function( - ConfigurationsRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -34,7 +30,7 @@ final class ConfigurationsProvider extends $FunctionalProvider< ); final FutureOr Function( - ConfigurationsRef ref, + Ref ref, )? _createCb; @override @@ -49,20 +45,20 @@ final class ConfigurationsProvider extends $FunctionalProvider< @override ConfigurationsProvider $copyWithCreate( FutureOr Function( - ConfigurationsRef ref, + Ref ref, ) create, ) { return ConfigurationsProvider._(create: create); } @override - FutureOr create(ConfigurationsRef ref) { + FutureOr create(Ref ref) { final _$cb = _createCb ?? configurations; return _$cb(ref); } } -String _$configurationsHash() => r'27f534f8b2a22c39b2d28c2414358a228c552155'; +String _$configurationsHash() => r'9ba3dc8a87bfe57002a403f03c8e0db6ba4759fd'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/static/snippets/combine.dart b/website/static/snippets/combine.dart index 96664b177..0ad595310 100644 --- a/website/static/snippets/combine.dart +++ b/website/static/snippets/combine.dart @@ -15,15 +15,15 @@ enum Filter { } @riverpod -List todos(TodosRef ref) => []; +List todos(Ref ref) => []; @riverpod -Filter filter(FilterRef ref) => Filter.all; +Filter filter(Ref ref) => Filter.all; /* SNIPPET START */ @riverpod -List filteredTodos(FilteredTodosRef ref) { +List filteredTodos(Ref ref) { // Providers can consume other providers using the "ref" object. // With ref.watch, providers will automatically update if the watched values changes. final List todos = ref.watch(todosProvider); diff --git a/website/static/snippets/combine.g.dart b/website/static/snippets/combine.g.dart index f63fa7d0e..f11a03ee8 100644 --- a/website/static/snippets/combine.g.dart +++ b/website/static/snippets/combine.g.dart @@ -8,16 +8,14 @@ part of 'combine.dart'; // RiverpodGenerator // ************************************************************************** -typedef TodosRef = Ref>; - @ProviderFor(todos) const todosProvider = TodosProvider._(); final class TodosProvider extends $FunctionalProvider, List> - with $Provider, TodosRef> { + with $Provider> { const TodosProvider._( {List Function( - TodosRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -31,7 +29,7 @@ final class TodosProvider extends $FunctionalProvider, List> ); final List Function( - TodosRef ref, + Ref ref, )? _createCb; @override @@ -53,31 +51,29 @@ final class TodosProvider extends $FunctionalProvider, List> @override TodosProvider $copyWithCreate( List Function( - TodosRef ref, + Ref ref, ) create, ) { return TodosProvider._(create: create); } @override - List create(TodosRef ref) { + List create(Ref ref) { final _$cb = _createCb ?? todos; return _$cb(ref); } } -String _$todosHash() => r'146df519c4c2f843a867e4c6f5983259194f34fc'; - -typedef FilterRef = Ref; +String _$todosHash() => r'ed255140669430745a7779b542a1209dc182ce0c'; @ProviderFor(filter) const filterProvider = FilterProvider._(); final class FilterProvider extends $FunctionalProvider - with $Provider { + with $Provider { const FilterProvider._( {Filter Function( - FilterRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -91,7 +87,7 @@ final class FilterProvider extends $FunctionalProvider ); final Filter Function( - FilterRef ref, + Ref ref, )? _createCb; @override @@ -113,32 +109,30 @@ final class FilterProvider extends $FunctionalProvider @override FilterProvider $copyWithCreate( Filter Function( - FilterRef ref, + Ref ref, ) create, ) { return FilterProvider._(create: create); } @override - Filter create(FilterRef ref) { + Filter create(Ref ref) { final _$cb = _createCb ?? filter; return _$cb(ref); } } -String _$filterHash() => r'db6b594dad9378c59a08eaee9a1208065cb916eb'; - -typedef FilteredTodosRef = Ref>; +String _$filterHash() => r'38c5f61dc2d4b44e9be37bb724487d265cc0a645'; @ProviderFor(filteredTodos) const filteredTodosProvider = FilteredTodosProvider._(); final class FilteredTodosProvider extends $FunctionalProvider, List> - with $Provider, FilteredTodosRef> { + with $Provider> { const FilteredTodosProvider._( {List Function( - FilteredTodosRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -152,7 +146,7 @@ final class FilteredTodosProvider ); final List Function( - FilteredTodosRef ref, + Ref ref, )? _createCb; @override @@ -174,20 +168,20 @@ final class FilteredTodosProvider @override FilteredTodosProvider $copyWithCreate( List Function( - FilteredTodosRef ref, + Ref ref, ) create, ) { return FilteredTodosProvider._(create: create); } @override - List create(FilteredTodosRef ref) { + List create(Ref ref) { final _$cb = _createCb ?? filteredTodos; return _$cb(ref); } } -String _$filteredTodosHash() => r'bcb1e81823aaf9b967948b619c177ebc571d96a7'; +String _$filteredTodosHash() => r'9a243c7679a9c6c6aa4a9bea798cbff31a3038c6'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/static/snippets/create.dart b/website/static/snippets/create.dart index 0690b6e2f..236716169 100644 --- a/website/static/snippets/create.dart +++ b/website/static/snippets/create.dart @@ -10,7 +10,7 @@ part 'create.g.dart'; /* SNIPPET START */ @riverpod -Future boredSuggestion(BoredSuggestionRef ref) async { +Future boredSuggestion(Ref ref) async { final response = await http.get( Uri.https('boredapi.com', '/api/activity'), ); diff --git a/website/static/snippets/create.g.dart b/website/static/snippets/create.g.dart index 6017bf03c..e9368f969 100644 --- a/website/static/snippets/create.g.dart +++ b/website/static/snippets/create.g.dart @@ -8,17 +8,15 @@ part of 'create.dart'; // RiverpodGenerator // ************************************************************************** -typedef BoredSuggestionRef = Ref>; - @ProviderFor(boredSuggestion) const boredSuggestionProvider = BoredSuggestionProvider._(); final class BoredSuggestionProvider extends $FunctionalProvider, FutureOr> - with $FutureModifier, $FutureProvider { + with $FutureModifier, $FutureProvider { const BoredSuggestionProvider._( {FutureOr Function( - BoredSuggestionRef ref, + Ref ref, )? create}) : _createCb = create, super( @@ -32,7 +30,7 @@ final class BoredSuggestionProvider ); final FutureOr Function( - BoredSuggestionRef ref, + Ref ref, )? _createCb; @override @@ -46,20 +44,20 @@ final class BoredSuggestionProvider @override BoredSuggestionProvider $copyWithCreate( FutureOr Function( - BoredSuggestionRef ref, + Ref ref, ) create, ) { return BoredSuggestionProvider._(create: create); } @override - FutureOr create(BoredSuggestionRef ref) { + FutureOr create(Ref ref) { final _$cb = _createCb ?? boredSuggestion; return _$cb(ref); } } -String _$boredSuggestionHash() => r'6cceb7a902c8fe2477eae0dff97d10644a848ea0'; +String _$boredSuggestionHash() => r'ea7579b20dd2a5f45fd9d9ea09fcbd3608330d24'; // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/static/snippets/declare.g.dart b/website/static/snippets/declare.g.dart index f17d4b939..8c3f82b4f 100644 --- a/website/static/snippets/declare.g.dart +++ b/website/static/snippets/declare.g.dart @@ -54,7 +54,7 @@ final class CountProvider extends $NotifierProvider { @override CountProvider $copyWithBuild( int Function( - Ref, + Ref, Count, ) build, ) { @@ -78,4 +78,4 @@ abstract class _$Count extends $Notifier { } // ignore_for_file: type=lint -// ignore_for_file: deprecated_member_use_from_same_package, unreachable_from_main, invalid_use_of_internal_member +// 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 diff --git a/website/yarn.lock b/website/yarn.lock index 343d70c98..583bdd8e7 100644 --- a/website/yarn.lock +++ b/website/yarn.lock @@ -4594,9 +4594,9 @@ http-parser-js@>=0.5.1: integrity sha512-SGeBX54F94Wgu5RH3X5jsDtf4eHyRogWX1XGT3b4HuW3tQPM4AaBzoUji/4AAJNXCEOWZ5O0DgZmJw1947gD5Q== http-proxy-middleware@^2.0.3: - version "2.0.6" - resolved "https://registry.yarnpkg.com/http-proxy-middleware/-/http-proxy-middleware-2.0.6.tgz#e1a4dd6979572c7ab5a4e4b55095d1f32a74963f" - integrity sha512-ya/UeJ6HVBYxrgYotAZo1KvPWlgB48kUJLDePFeneHsVujFaW5WNj2NgWCAE//B1Dl02BIfYlpNgBy8Kf8Rjmw== + version "2.0.7" + resolved "https://registry.yarnpkg.com/http-proxy-middleware/-/http-proxy-middleware-2.0.7.tgz#915f236d92ae98ef48278a95dedf17e991936ec6" + integrity sha512-fgVY8AV7qU7z/MmXJ/rxwbrtQH4jBQ9m7kp3llF0liB7glmFeVZFBepQb32T3y8n8k2+AEYuMPCpinYW+/CuRA== dependencies: "@types/http-proxy" "^1.17.8" http-proxy "^1.18.1"