For questions relating to the "riverpod" package for the Flutter framework.
Questions tagged [riverpod]
1086 questions
19
votes
3 answers
Riverpod : Alternate way of overriding initState inside ConsumerWidget
What is the solution of initializing things inside consumerWidget as because the initState method is not overridable here?

towhid
- 2,778
- 5
- 18
- 28
16
votes
1 answer
Flutter Riverpod ref.read() vs ref.listen() vs ref.watch()
After reading the documentation, it did not explain very well what ref.read(), ref.watch(), and ref.listen() is.
The questions I have are as follows:
What is the purpose and difference between these functions?
Where and where not can I use these…

Vraj Shah
- 536
- 2
- 7
- 19
13
votes
2 answers
The type 'StateNotifierProvider' is declared with 2 type parameters, but 1 type arguments were given
In the context of a Flutter 2.0.5 app whose state I'd like to manage with Riverpod, I thought I can declare a StateNotifierProvider like this:
import 'package:flutter_riverpod/flutter_riverpod.dart';
final counterProvider =…

Giorgio
- 2,137
- 3
- 20
- 40
13
votes
5 answers
error `pumpAndSettle timed out` MAYBE due to riverpod
I'm stuck with a widget test and I could use some help
to reproduce the behavior please run the code sample below
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'home_page.dart';
void main() =>…

Francesco Iapicca
- 2,618
- 5
- 40
- 85
13
votes
3 answers
Riverpod, reading state in outside BuildContext and Provider
I am struggling to figure out why this is not working (as opposed to the documentation which states it should be working).
I have a provider something like this
import 'package:hooks_riverpod/hooks_riverpod.dart';
import…

ptheofan
- 2,150
- 3
- 23
- 36
13
votes
2 answers
RiverPod - How to await using FutureProvider on AsyncValue not in widget
I need to get 1 field 1 time from Firebase Cloud Firestore. How do I accomplish this with providers outside of Widget build?
Below are my combined providers. appStartupProvider is a FutureProvider and I want to get the bool value from this 1 field…

Zelf
- 1,723
- 2
- 23
- 40
13
votes
3 answers
Implement ChangeNotifier vs StateNotifier
I'm quite familiar with Provider package and combine it with the ChangeNotifier.
Let's say I have 3 getters and method with a different function :
Toggle Loading
Toggle Image Loading
Toggle ObsecurePassword
Using ChangeNotifer
import…

Zeffry Reynando
- 3,445
- 12
- 49
- 89
11
votes
2 answers
How to use a riverpod family provider without passing parameter
Is there a way to access an instance of a provided ".family" change notifier (which has already been instantiated, passing the right parameters) without passing the parameters again?
IN PROVIDER
When you create a provider of a ChangeNotifier (which…

Prince
- 245
- 4
- 9
11
votes
1 answer
Flutter Riverpod context.read vs Provider in the build method
In the Riverpod documentation it says:
That's where context.read(myProvider) is a solution.
Using it, we could refactor our previous code to:
@override
Widget build(BuildContext context) {
return RaisedButton(
onPressed: () =>…

Suragch
- 484,302
- 314
- 1,365
- 1,393
9
votes
1 answer
combine FutureProviders into a StateNotifierProvider
I'm using riverpod with Freezed unions.
I'm trying to merge/watch two FutureProviders that both return the same type into a StateNotifierProvider and use them to set state.
I've noticed that because I'm watching two futureProviders, that it creates…

aidanmack
- 518
- 1
- 5
- 16
9
votes
1 answer
Dart Riverpod: Undefined class 'WidgetRef'
I'm going through Flutter Riverpod package documentation, and for some reason the basic example in 'Getting started' is throwing Error:
Undefined class 'WidgetRef'. Try changing the name to the name of an
existing class, or creating a class with…

Natnael A.
- 591
- 6
- 20
9
votes
3 answers
Type 'Null' is not a subtype of type 'Map' in type cast error
In my sample project I implemented project with riverpod package and freezed. In the code below, I can get data from the server successfully, but when I try to use model.fromJson I get this error:
getting type 'Null' is not a subtype of type…

DolDurma
- 15,753
- 51
- 198
- 377
9
votes
3 answers
Implementing pull-to-refresh in Flutter with Riverpod
I am new to Riverpod and trying to implement pull to refresh with Riverpod in my Flutter app and can't seem to find any good tutorial online. Has anyone implemented pull-to-refresh in their Flutter app while using Riverpod. I have looked for…

camboo_babbage
- 93
- 1
- 4
9
votes
2 answers
Flutter make a form with provider and riverpod
I'm new with Flutter and I want to upgrade my code. I have a form that uses multiple textformfields and I want to convert this code using provider and riverpod to improve readability but I'm not sure how to do it.
For the example I simplified my…

xenos92
- 231
- 6
- 26
8
votes
1 answer
Flutter riverpod debounce multiple dependent providers
As described in the Riverpod docs, a Riverpod provider can watch other providers to make a "processing pipeline".
I have something like this:
final prov = Provider((ref){
final w1 = ref.watch(prov1);
final w2 = ref.watch(prov2);
…

DaveBound
- 215
- 4
- 11