Reputation: 4556
Recently, Flutter Riverpod 2.0 was released. I'm not sure what has changed with Flutter Riverpod 2.0. I hope someone can explain these changes to me.
If anyone can tell me what the changes are, I'd really appreciate it. Thank you in advance!
Upvotes: 0
Views: 374
Reputation: 4824
ref.read
, now you should pass parameter ref
=> removed typedef Reader (as I understand, related to complication of testing), for example:final myClassProvider1 = Provider<MyClass>((ref) {
return MyClass(ref);
});
// or using tear-off
final myClassProvider2 = Provider<MyClass>(MyClass.new);
class MyClass {
MyClass(this.ref);
[-] final Reader reader;
[+] final Ref ref;
}
For a quick solution, you can create your own Reader
. However, this is not recommended, BUT will work as a quick fix.
typedef Reader = T Function<T>(ProviderBase<T> provider);
overrideWithProvider
instead overrideWithValue
.And check with riverpod/changelog. Also, you can wait for the official article from Remi Rousselet:
An article is in progress and will be linked here once available.
Upvotes: 1