-
Notifications
You must be signed in to change notification settings - Fork 29
build: bump Riverpod from 2 to 3 #611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #611 +/- ##
==========================================
+ Coverage 26.66% 29.10% +2.43%
==========================================
Files 15 15
Lines 180 189 +9
==========================================
+ Hits 48 55 +7
- Misses 132 134 +2
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Updates the Flutter app to use Riverpod 3.x, replacing code generation with manual provider definitions and migrating from mockito to mocktail for testing.
- Migrated from Riverpod 2.x to 3.x, replacing
@riverpodannotations with manual provider definitions - Replaced mockito with mocktail testing framework throughout the test suite
- Updated deprecated Riverpod APIs, replacing
valueOrNullwithvalueand adapting provider observer methods
Reviewed Changes
Copilot reviewed 69 out of 70 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/flutter_app/pubspec.yaml | Updated hooks_riverpod to 3.0.0, removed riverpod_annotation/riverpod_generator, added mocktail |
| packages/flutter_app/lib/util/providers/*.dart | Converted generated providers to manual Provider definitions |
| packages/flutter_app/lib/util/logger/provider_logger.dart | Updated ProviderObserver methods to use new ProviderObserverContext API |
| packages/flutter_app/lib/pages/riverpod_example_page/**/*.dart | Migrated from @riverpod annotations to manual NotifierProvider definitions |
| packages/flutter_app/test/**/*.dart | Migrated from mockito to mocktail, updated mock syntax and imports |
| packages/flutter_app/lib/package_adaptor/*.dart | Converted generated providers to manual provider definitions |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| state = const AsyncLoading<GetSearchedPackagesResponseBody>() | ||
| // Note: This is a workaround to avoid the error. | ||
| // ignore: invalid_use_of_internal_member | ||
| .copyWithPrevious(state); |
Copilot
AI
Sep 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of copyWithPrevious with invalid_use_of_internal_member ignore comment suggests this is accessing internal Riverpod APIs. Consider using the public API alternatives or refactoring to avoid internal member usage.
| state = const AsyncLoading<GetSearchedPackagesResponseBody>() | |
| // Note: This is a workaround to avoid the error. | |
| // ignore: invalid_use_of_internal_member | |
| .copyWithPrevious(state); | |
| state = AsyncLoading<GetSearchedPackagesResponseBody>(state.value); |
...b/pages/riverpod_example_page/async_notifier_provider_page/async_notifier_provider_page.dart
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is being reviewed by Cursor Bugbot
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, please upgrade to Bugbot Pro by visiting the Cursor dashboard. Your first 14 days will be free!
| ListTile( | ||
| title: const Text('UID:'), | ||
| subtitle: Text(ref.watch(userProvider).valueOrNull?.uid ?? 'none'), | ||
| subtitle: Text(ref.watch(userProvider).value?.uid ?? 'none'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: AsyncValue Access Causing Runtime Errors
Using AsyncValue.value instead of valueOrNull can cause runtime crashes. The .value getter throws an exception when the AsyncValue is in a loading or error state, unlike valueOrNull which safely returns null. This affects the userProvider when displaying the UID and the AsyncTodoList's add method, leading to crashes if the data is not yet available or an error occurs.
Additional Locations (1)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Breaking removed AsyncValue.valueOrNull (use .value instead).
| ref.watch(userDeviceInitializingProvider).requireValue; | ||
| final userDeviceProvider = Provider<UserDevice>( | ||
| (ref) => ref.watch(userDeviceInitializingProvider).requireValue, | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Riverpod Migration Causes Unexpected Provider Auto-Dispose
During the migration from riverpod_annotation, several providers that were explicitly marked with @Riverpod(keepAlive: true) now default to auto-dispose. This change in lifecycle may lead to unexpected re-initialization and loss of state for components intended to persist throughout the app or maintain their initialized values.
Additional Locations (6)
packages/flutter_app/lib/environment/src/flavor_provider.dart#L5-L6packages/flutter_app/lib/package_adaptor/package_info_provider.dart#L4-L7packages/flutter_app/lib/package_adaptor/configurator_provider.dart#L8-L9packages/flutter_app/lib/features/validator/validator_provider.dart#L2-L3packages/flutter_app/lib/package_adaptor/tracker_provider.dart#L6-L7packages/flutter_app/lib/util/providers/shared_preferences_provider.dart#L3-L6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since .autoDispose isn’t applied, it should remain in KeepAlive.
naipaka
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
k-nkmr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙌 What's Done
✍️ What's Not Done
📝 Additional Notes
🖼️ Image Differences
Pre-launch Checklist