Questions tagged [flutter-riverpod]

166 questions
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
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

Using Firebase Authentication with Go Router and Riverpod

I've been reading through this latest implementation of Go Router with Riverpod but don't know how to use Firebase Authentication Streams with it, and I don't know if I need to be using…
5
votes
3 answers

What is the difference between getx and riverpod?

I want to know what is the difference between getx and riverpod. I am so confused about which one of these two state management tools I will use in real projects.
Atul maurya
  • 51
  • 1
  • 3
4
votes
0 answers

Riverpod: overriding and watching prevents listening on a dependent provider

Here is a very curious case with Riverpod which is probably a bug. The existence of a simple watch line prevents a listen from executing. When watching a base provider and listening to a provider that depends on it, listen only executes if you do…
Gazihan Alankus
  • 11,256
  • 7
  • 46
  • 57
4
votes
2 answers

Riverpod trigger rebuild when update state with freezed copywith even if nothing changed

I thought Riverpod will only trigger rebuild if the state value is different but turn out it rebuild every time when state is set although the value is the same. Is that true? The case is as below @Freezed(genericArgumentFactories: true) class Model…
Anson Wong
  • 1,034
  • 8
  • 10
4
votes
0 answers

How to listen the riverpod with family

I have this provider with family final gameControllerProvider = ChangeNotifierProvider.autoDispose .family((ref, gameLevel) { final gameController = GameController()..initializeController(gameLevel, ref); return…
4
votes
3 answers

Flutter: how to listen to GoRouter's route / location changes in a Riverpod provider?

I am developing a Flutter application with go_router and riverpod for navigation and state management respectively. The app has a widget which displays a live camera feed, and I'd like to "switch it off" and free the camera when other pages are…
Michele
  • 2,148
  • 1
  • 9
  • 14
4
votes
2 answers

Undefined class 'Reader' in Riverpod 2.0.2

For accessing providers inside non widget classes I was using Reader function. After updating Riverpod dependency to ^2.0.2 version, It seems, the Reader function is no longer available. What workaround you suggest? Sould I pass Ref or WidgetRef as…
Davoud
  • 2,576
  • 1
  • 32
  • 53
4
votes
2 answers

How to dynamically create providers at runtime with Riverpod?

In my flutter app I am exploring a transition from the Provider package to Riverpod. The app is quite simple: it fetches a list of objects from a database, and allows the user to change these objects's characteristics. It is thus pretty similar to…
Michele
  • 2,148
  • 1
  • 9
  • 14
3
votes
2 answers

How does flutter_riverpod in Flutter convert ConsumerWidget to ConsumerStatefulWidget more conveniently?

I am using flutter_riverpod package. I want to convert ConsumerWidget to ConsumerStatefulWidget. However, it took me a lot of time to do it like this: (code) class Widget extends ConsumerWidget { const Widget({super.key}); @override Widget…
My Car
  • 4,198
  • 5
  • 17
  • 50
3
votes
1 answer

How to properly use flutter riverpod to share data between widgets in different files?

I am able to share data between widgets when the widgets are int he same file but when the widgets are in different files, the ui does not rebuild and i do not seem to get it right. Please kindly check my codes below and see where I'm falling…
ket-c
  • 211
  • 1
  • 10
3
votes
2 answers

Why Riverpod's ConsumerWidget can show state changes?

I looked at Riverpod's counter example and noticed it uses ConsumerWidget instead of ConsumerStatefulWidget. If ConsumerWidget can show state changes, is there any need to use ConsumerStatefulWidget? Why Riverpod, as a state management solution, has…
duckling
  • 31
  • 1
3
votes
1 answer

Riverpod and MediaQuery

I am trying to write a Riverpod provider that would return me a scaling factor for the screen, so that I can resize all my elements accordingly. final scale = ref.watch(scaleProvider); return LinearPercentIndicator( animation: true, …
vasily
  • 2,850
  • 1
  • 24
  • 40
3
votes
2 answers

Flutter Riverpod StateNotifierProvider Async value still loading

I'm new to Flutter. I use the Riverpod state management library. I am calling a remote API to get a list of board games. If I don't pass a parameter to my query, it returns me a list of popular games, and if I pass a games name parameter, it returns…
Collembole
  • 158
  • 2
  • 13
1
2 3
10 11