rrousselGit / riverpod

A reactive caching and data-binding framework. Riverpod makes working with asynchronous code a breeze.
https://riverpod.dev
MIT License
6.17k stars 943 forks source link

[riverpod_generator] Build runner fails after upgrading to 2.0.0 #2259

Closed austinried closed 1 year ago

austinried commented 1 year ago

Describe the bug After upgrading my project to the latest riverpod/hooks versions, I'm getting an error in build runner:

[SEVERE] riverpod_generator on lib/models/settings.dart:
Bad state: Failed to obtain the unit: too many inconsistent analysis exceptions.

This is after changing versions from:

  flutter_hooks: ^0.18.5+1 -> ^0.18.6
  hooks_riverpod: ^2.2.0 -> ^2.3.0
  riverpod_annotation: ^1.2.1 -> ^2.0.0
  riverpod_generator: ^1.1.1 -> ^2.0.0

Weird thing is that lib/models/settings.dart is not a riverpod part file, nothing riverpod in it, it's part of a freezed file

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.7.6, on Ubuntu 22.04.1 LTS 5.15.0-60-generic, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2022.1)
[✓] Connected device (3 available)
[✓] HTTP Host Availability

To Reproduce Sorry but I don't have a repro example for this one yet, is there anything from a log that would help?

Expected behavior No build runner errors.

mykhailo-gaidai commented 1 year ago

I've ran into the same issue after upgrading Flutter to 3.7.6 with super-simple provider

@riverpod
bool isAuthorized(IsAuthorizedProvider ref) => return false;

downgrading flutter to 3.7.5 fixes the issue for me

K9i-0 commented 1 year ago

I also had a similar problem occur. When I downgraded my Flutter version from 3.7.6 to 3.7.5, the issue was resolved. It might be related to a change in the Dart version🤔

rrousselGit commented 1 year ago

The issue isn't related to a specific sdk version. Rather changing version forcibly clears the codegen cache and restart.

You should be able work around this error by deleting the .dart_tool folder and re-running codegen

austinried commented 1 year ago

You should be able work around this error by deleting the .dart_tool folder and re-running codegen

Unfortunately this does not solve the issue for me, although it appears to sometimes change the specific file that causes the error (now it's lib/models/music.dart for example, still not a riverpod file).