Skip to content

Conversation

@riscait
Copy link
Member

@riscait riscait commented Sep 12, 2025

🙌 What's Done

  • Riverpod 3
    • copyWithPrevious is invalid_use_of_internal_member
    • remove valueOrNull
      • replace to value

✍️ What's Not Done

📝 Additional Notes

🖼️ Image Differences

Before After
image image

Pre-launch Checklist

  • I have reviewed my own code (e.g., updated tests and documentation)

@riscait riscait changed the title build: bump riverpod to 3.0 build: bump Riverpod from 2 to 3 Sep 12, 2025
@codecov
Copy link

codecov bot commented Sep 12, 2025

Codecov Report

❌ Patch coverage is 47.36842% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 29.10%. Comparing base (00b220b) to head (b42cfdc).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...s/flutter_app/lib/util/logger/provider_logger.dart 0.00% 7 Missing ⚠️
...er_provider_page/async_notifier_provider_page.dart 50.00% 1 Missing ⚠️
...pages/riverpod_example_page/util/dio_provider.dart 50.00% 1 Missing ⚠️
...ib/util/providers/shared_preferences_provider.dart 50.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            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     
Files with missing lines Coverage Δ
...atures/theme_selector/theme_selector_provider.dart 90.90% <100.00%> (+0.90%) ⬆️
...il/network_connectivity/connectivity_provider.dart 100.00% <100.00%> (ø)
...onnectivity/network_connection_state_provider.dart 100.00% <100.00%> (ø)
...er_provider_page/async_notifier_provider_page.dart 8.69% <50.00%> (+1.34%) ⬆️
...pages/riverpod_example_page/util/dio_provider.dart 50.00% <50.00%> (+50.00%) ⬆️
...ib/util/providers/shared_preferences_provider.dart 50.00% <50.00%> (+50.00%) ⬆️
...s/flutter_app/lib/util/logger/provider_logger.dart 12.00% <0.00%> (-2.29%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 00b220b...b42cfdc. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@riscait riscait marked this pull request as ready for review September 12, 2025 02:09
@riscait riscait requested a review from a team as a code owner September 12, 2025 02:09
@riscait riscait requested review from Copilot, k-nkmr and naipaka and removed request for a team September 12, 2025 02:09
Copy link
Contributor

Copilot AI left a 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 @riverpod annotations with manual provider definitions
  • Replaced mockito with mocktail testing framework throughout the test suite
  • Updated deprecated Riverpod APIs, replacing valueOrNull with value and 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.

Comment on lines 39 to 42
state = const AsyncLoading<GetSearchedPackagesResponseBody>()
// Note: This is a workaround to avoid the error.
// ignore: invalid_use_of_internal_member
.copyWithPrevious(state);
Copy link

Copilot AI Sep 12, 2025

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.

Suggested change
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);

Copilot uses AI. Check for mistakes.
Copy link

@cursor cursor bot left a 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'),
Copy link

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)

Fix in Cursor Fix in Web

Copy link
Member Author

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).

https://pub.dev/packages/riverpod/changelog

ref.watch(userDeviceInitializingProvider).requireValue;
final userDeviceProvider = Provider<UserDevice>(
(ref) => ref.watch(userDeviceInitializingProvider).requireValue,
);
Copy link

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)

Fix in Cursor Fix in Web

Copy link
Member Author

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.

Copy link
Contributor

@naipaka naipaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@k-nkmr k-nkmr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@riscait riscait added this pull request to the merge queue Sep 12, 2025
Merged via the queue into main with commit 36115a1 Sep 12, 2025
9 checks passed
@riscait riscait deleted the riverpod-3 branch September 12, 2025 05:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants