Questions tagged [flutter-riverpod]
166 questions
3
votes
1 answer
Provider was disposed before a value was emitted
I wrote the following code and encountered the error The provider AutoDisposeFutureProvider#d1e31(465-0041) was disposed before a value was emitted.
I thought it was strange, so I debugged FutureProvider's onDispose and found that it was…

hime_chann____
- 141
- 1
- 5
3
votes
4 answers
How do I get loading state/spinner with flutter riverpod statenotifier, ref watch and asyncvalue?
I have the below example which does refresh the data but does not give a spinner as expected.
I tried using ref.listen to switch to async loading, i tried await in front of the call even though it didn't make sense.
I tried ref.refresh,…

nAndroid
- 862
- 1
- 10
- 25
3
votes
1 answer
What is the point of Riverpod Provider ref.watch
Unless you’re using something like StateNoticationProvider, listening to or watching a normal Provider doesn’t seem to update
the UI even though the object the provider is returning changes. So when is a normal provider’s listen or watch used? By…

Suman Chapai
- 51
- 7
3
votes
1 answer
Riverpod: How do you manage loading and error states with StateNotifier?
How to use loading/error states with StateNotifier like we do with FutureProvider in Riverpod?
We can do the same with Provider using setState, var isLoading with ternary operator and didChangeDependencies.

Anmol Singh
- 393
- 3
- 16
2
votes
2 answers
Flutter - Riverpod Future Provider: How to keep old data when error occurs
This is my usecase:
data is downloaded
final dataProvider = FutureProvider((ref) async {
return fetchData();
});
and it's used like this within widget's build method:
ref.watch(dataProvider).when(
data: DataWidget(data),
…

Palejandro
- 2,092
- 5
- 26
- 38
2
votes
1 answer
Flutter lifecycle used with .autoDispose modifier
I been trying to understand how Riverpod works and was wondering how does it know when to destroy the state of a provider with the .autoDispose modifier when changing a route in Flutter. Is it somehow subscribed to the navigator changes?
The docs…

FRANCISCO BERNAD
- 473
- 4
- 15
2
votes
0 answers
How to implement Authentication using Riverpod in Flutter?
I have three providers for login => email, password, login.
then I am refreshing login provider which is a future provider and will call the login API.
now I need to see if the provider returns success then I will need to navigate to next page.
But…

Ayush Raghuvanshi
- 21
- 1
2
votes
2 answers
Flutter Riverpod, how to set minimut loading state time?
Building an app with Flutter and Riverpod, using a lot of:
ref.watch(someProvider).when(data: (someData){
// render layout with data
}, error: (err, stack) {
// do stuff with error
}, loading: (){
return LoadingScreen(); <----
})
The…

Majoren
- 983
- 5
- 16
- 36
2
votes
2 answers
Why does Flutter riverpod direct assignment does not work but methods do
Please check the two samples below.
The first sample does not rebuild the Widgets [Possibly 'listeners'
are not being 'notified']
The second sample works as
expected
To my understanding, i think all these two should work. Can someone brief me…

ket-c
- 211
- 1
- 10
2
votes
1 answer
Flutter Riverpod Future provider - requires async and await?
I've been reviewing the RiverPod 2 tutorial at https://codewithandrea.com/articles/flutter-state-management-riverpod/
In the section dealing with Future providers there is a code snippet as shown below...
final weatherFutureProvider =…

user2868835
- 1,250
- 3
- 19
- 33
2
votes
1 answer
Providers are not allowed to modify other providers during their initialization
I have a scenario, where I want to change state of loading class while I load my data on screen. So for that I am trying to switch the initial state of a provider from another provider but throws me an error. "Providers are not allowed to modify…

Naveed Ullah
- 129
- 7
2
votes
1 answer
How can you access GoRoute state.params outside of the routing process?
I hope some simple pseudocode is enough so that both me and you can understand the question and answer.
The problem I'm facing is especially hard when using flutter-web, where the refresh restarts the whole program.
I want to use the path parameters…

DempseyRoller
- 21
- 3
2
votes
1 answer
Using Riverpod Consumer widget as top level widget crashes the app in Flutter web
We are using Riverpod for navigation and state management in our app but lately if we want to run the app web version of our app we are experiencing crashes in the initial App widget. This widget gets called in runApp() and sits above our custom…

peer-f
- 41
- 6
2
votes
2 answers
Flutter Riverpod, build() is not getting called after changing the state
Minimal reproducible code:
final fooProvider = StateProvider((ref) => 0);
final barProvider = Provider((ref) {
ref.watch(fooProvider); // 1
return '';
});
class FooPage extends ConsumerWidget {
@override
Widget…

iDecode
- 22,623
- 19
- 99
- 186
2
votes
3 answers
Update TextEditingController Text with Riverpod
I'm new to Riverpod and am trying to migrate an app over from Provider. If I had a TextField and wanted to set its value based on my Provider model, I would do this:
class MyWidget extends StatefulWidget{
const MyWidget({ Key? key }) : super(key:…

Clifton Labrum
- 13,053
- 9
- 65
- 128