You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I am listening for a state change, and when it occurs triggering some separate logic to do some more complex checks on the state. However, ref.listen() is updated, but when triggering the other code, the ref.read() gets the previous value.
It appears to only happen for AsyncValue.
To Reproduce
//example_provider.dartimport'package:flutter/foundation.dart';
import'package:riverpod_annotation/riverpod_annotation.dart';
part'example_provider.g.dart';
@riverpodclassExampleextends_$Example {
int counter =0;
@overrideFuture<String> build() async {
return"$counter";
}
voidincrement() {
debugPrint("Updated counter from $counter to ${++counter}");
state =AsyncData("$counter");
}
}
Describe the bug
I am listening for a state change, and when it occurs triggering some separate logic to do some more complex checks on the state. However, ref.listen() is updated, but when triggering the other code, the ref.read() gets the previous value.
It appears to only happen for AsyncValue.
To Reproduce
From debugging:
Expected behavior
ref.read() gets the same value as ref.listen() next
The text was updated successfully, but these errors were encountered: