Questions tagged [riverpod]

For questions relating to the "riverpod" package for the Flutter framework.

1086 questions
6
votes
2 answers

How can I update the value in FutureProvider with riverpod?

I have a FutureProvider with a List of items. How can I update an item in this list without a refresh the provider?
Nidhal
  • 101
  • 3
  • 7
6
votes
0 answers

Stateful widget consumer widget builds twice and hence calls initState twice. How to stop this from happening?

So for my project, I am using Riverpod, and I am creating the home page of my app. The tree looks like this -> CommunityView(Stateful Widget) WillPopScope ProviderScope Consumer Scaffold ...and so on Now inside the build method of the CommunityView…
6
votes
1 answer

How to unit test Riverpod StateNotifier using ProviderContainer

I want to test Riverpod StateNotifierProvider. I'm trying to follow a TDD approach for state notifier providers without implementing UI/Widgets. According to Riverpod documentation on testing, can use ProviderContainer for testing without Widget…
NirmalCode
  • 2,140
  • 1
  • 14
  • 19
6
votes
5 answers

flutter share received pusher data between screens using Riverpod

In our system we used Pusher on both of our Admin Panel and mobile application, in flutter i want to wrap whole application screens with Pusher and Riverpod and using providers with Hook widget in screens, that means i want to implement Pusher in…
DolDurma
  • 15,753
  • 51
  • 198
  • 377
6
votes
1 answer

Riverpod - Create service with async dependency better/elegant way

I've writen some code that provides a ApiService to a StateNotifier. The ApiService has a dependency on a authenticatorclient - The auth client has to be created asynchronously as it uses sharedprefs to get a token. Im just trying to figure out if…
aidanmack
  • 518
  • 1
  • 5
  • 16
6
votes
1 answer

How do you combine 2 Riverpod StreamProviders where 1 stream depends on the data from another stream?

Sometimes I think I'm getting the logic of providers and then I get stumped for hours trying to do something like below. I need to get a List of connection id's from a firestore collectionsstream. Easy. However, I need to feed this streaming list of…
Zelf
  • 1,723
  • 2
  • 23
  • 40
6
votes
1 answer

How to make http.post call in riverpod?

I am trying to make a post-call that would send form data to API and get a response. I would like to make a network post-call which sends the mobile, password, and get user data from user_repo and store it in the state to be accessed in the…
Mr.PY
  • 63
  • 1
  • 4
6
votes
2 answers

Flutter Riverpod : The member 'state' can only be used within instance members of subclasses of 'package:state_notifier/state_notifier.dart'

I have simple example about toggle widget,my expectation after click button i show circularProgressIndicator then after 3 second i showing Text. For my example i use riverpod_hooks and flutter_hooks. LoadingProvider class IsLoading extends…
Zeffry Reynando
  • 3,445
  • 12
  • 49
  • 89
6
votes
2 answers

Riverpod: Is there a correct way to read a StreamProvider within another StreamProvider?

I have been attempting to create streams to Firestore documents using the uid obtained from my auth Provider: class AuthService { ... static final provider = StreamProvider.autoDispose((ref) => FirebaseAuth.instance.onAuthStateChanged); …
Alex Hartford
  • 5,110
  • 2
  • 19
  • 36
5
votes
2 answers

How to pass initial value to a Notifier using family modifier?

This is my Notifier: class Counter extends Notifier { final int initial; Counter(this.initial); @override int build() => initial; } I need to pass initial value to it, but I'm unable to do that using the family modifier anymore. //…
iDecode
  • 22,623
  • 19
  • 99
  • 186
5
votes
1 answer

'AutoDisposeStreamProvider' can't be assigned to the parameter type 'AlwaysAliveProviderListenable>'

I want to be able to create a StreamProvider.autoDispose and listen to it inside a StateNotifier. This way when the StateNotifierProvider.autoDispose is disposed of, the StreamProvider will also be disposed. Otherwise it is left open, which I don’t…
Dan Horton
  • 371
  • 3
  • 11
5
votes
1 answer

How to handle complex state with Riverpods StateNotifierProvider

I have a very big, complex app with lots of pages with input forms with lots of fields (texts, date-selection, combo-boxes,...), so the state is rather big. I'm switching from Provider to Riverpod, and the proposed way for state management seems to…
SouthbayDev
  • 698
  • 5
  • 10
5
votes
2 answers

Riverpod / Flutter Use showDialog inside Consumer Class

I'm not sure what i'm missing i have this simple method with a Consumer class that returns a Dialog, but the problem is the following The return type 'Future' isn't a 'Widget', as required by the closure's context. it points to the line indicated…
ImEsteban
  • 63
  • 2
  • 5
5
votes
2 answers

Riverpod: List provider is not rebuilding

Flutter riverpod is not notifying the Consumer on the state change when the StateNotifier's type is List, while the same implementation works just fine for other types. here, I provided a minimal reproducable example: import 'dart:math'; import…
Adnan
  • 906
  • 13
  • 30
5
votes
1 answer

In riverpod, how to write a StateNotifier that sets up (only once) asynchronously

New to riverpod here. (Using Flutter and hooks_riverpod, btw). Using Hive to store related lists of items. I need to call Hive.initFlutter and wait for Hive to be initialized, and do the same to open hive boxes, once when my app loads. After that,…
Benjamin Lee
  • 1,014
  • 10
  • 24
1 2
3
72 73