Questions tagged [riverpod]

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

1086 questions
8
votes
2 answers

How to convert a Stream to a Listenable in Flutter?

I am trying to figure out how to make use of Firebase's onAuthStateChanges() stream to use as a Listenable in the refreshListenable parameter from the go_router package to redirect whenever the authState changes. In additon I am using…
Florian Leeser
  • 590
  • 1
  • 6
  • 20
8
votes
2 answers

How to use HookWidget with useTextEditingController

I'm new to flutter development and trying to understand Riverpod. I currently managed to make the following login form work with a StatefulWidget. Basically, the button becomes enabled if both fields are not empty and viceversa. And this is the…
Robert Estivill
  • 12,369
  • 8
  • 43
  • 64
8
votes
1 answer

Flutter Riverpod: How to create different instances of the same provider for each Stateful widget on a GridView

I have a GridView which contains a list of StatefulWidgets that shows a preview of the image being uploaded and the progress of the upload for that image. Each widget on the list should have its own state where some of them can upload successfully…
Eleandro Duzentos
  • 1,370
  • 18
  • 36
8
votes
2 answers

Is there any ways to pass parameters in riverpod's provider

How do I pass a FirebaseAuth user to a StreamProvider in riverpod? When using old provider package, I used to get the user.uid from FirebaseAuth and pass the variable to the StreamProvider, returning the StreamProvider if we could get the…
Masahiro Aoki
  • 815
  • 12
  • 22
7
votes
3 answers

How to make Dependency Injection with Riverpod?

How can I know the type of the parameter in the constructor to make riverpod works like get_it, so I don't have to pass ref.read(x) every time, so I just have to pass locator()? I'm just passing ref.read(x).
7
votes
2 answers

How to refresh FutureProvider without showing loading indicator again in Flutter with Riverpod?

Currently I am refreshing a FutureProvider that is responsible for fetching data from Firebase and displaying it in a simple ListView with liquid_pull_to_refresh package, which causes the list to disappear, the loading indicator is shown again and…
Florian Leeser
  • 590
  • 1
  • 6
  • 20
7
votes
2 answers

How to define a GoRouter that depends on a Provider?

I'm integrating GoRouter in my Flutter app where I'm already using Riverpod. I have an isAuthorizedProvider defined as follows: final isAuthorizedProvider = Provider((ref) { final authStateChanged = ref.watch(_authStateChangedProvider); …
Marco
  • 1,572
  • 1
  • 10
  • 21
7
votes
2 answers

Riverpod: Simple way to ingest REST API

I'm currently building an app that is ingesting the WordPress REST API to display blog posts. On initial app load, I want to have it pull initial data with a method to then pull more posts via user interaction. I currently have this working,…
Zach Russell
  • 1,060
  • 2
  • 13
  • 27
7
votes
3 answers

How to get a Listenable from a Riverpod Provider?

I want to use go_router (https://pub.dev/packages/go_router#redirection) together with Riverpod. I have a Provider and a StreamProvider, which I would like to combine into a Listenable so it can be used as the refreshListenable param of GoRouter. I…
imi kim
  • 325
  • 2
  • 11
7
votes
1 answer

Riverpod error: Undefined class 'ScopedReader'

Now I use hooks_riverpod package to manage states. Then I wanted to use FutureProvider to fetch data from firestore. I read this official document(API reference). The example on the link said that UI will be like: Widget build(BuildContext,…
tomo-redx
  • 71
  • 1
  • 2
7
votes
3 answers

Clear state in providers when using Flutter and Riverpod

How can I clear the current state of my Riverpod providers manually in my Flutter app? The use case I have is when a user signs out of my app then signs up as a new/different user the previous users state is still stored in the providers, it is…
Sascha Derungs
  • 141
  • 1
  • 1
  • 5
7
votes
2 answers

How best to use Riverpod to manage items in a list

I'm struggling to figure out how to use Riverpod for the following scenario. I have a ListView where the children are Containers with a button inside. When the button is pressed, I want to change the colour of that container. I want that colour to…
DaveBound
  • 215
  • 4
  • 11
7
votes
1 answer

Riverpod giving a bad state exception when one hits back button on webpage

I'm getting this error in my StateNotifiers when one hits the back button on their webpage. I've isolated it to happening where the longRunningAPI request is below. Exception has occurred. "Error: Bad state: Tried to use RunListNotifier after…
foobar8675
  • 1,215
  • 3
  • 16
  • 26
6
votes
1 answer

How do I set my state when the widget builds with riverpod?

To preface, I am completely new to riverpod so my apologies if I get some terminology wrong. I have an edit feature that I'm implementing with riverpod that I'm migrating over to from flutter_blocs. Basically, with the bloc implementation, I am…
nyphur
  • 2,404
  • 2
  • 24
  • 48
6
votes
1 answer

Riverpod ref.watch(statenotifierprovider) vs ref.watch(statenotifierprovider.notifier)

I've been trying to find out what is the difference between watching a StateNotifierPovider object vs watching the notifier exposed by it. As we can see in the docs following section watching the notifier object does not trigger the object's build…
FRANCISCO BERNAD
  • 473
  • 4
  • 15
1
2
3
72 73