Questions tagged [riverpod]

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

1086 questions
3
votes
0 answers

Riverpod Stream Provider Testing in Pure Dart

I'm struggling with writing a test for a Stream Provider. It can obviously be done, but I'm kind of new to using Mocks, and I haven't figured out a way to get it to work. Here's what I have so far: @Riverpod(keepAlive: true) class AtFhirListen…
Grey
  • 331
  • 3
  • 11
3
votes
2 answers

How to create an AutoDisposeAsyncNotifierProviderFamily in Riverpod?

As the question implies, I am trying to create an AutoDisposeAsyncNotifierProviderFamily. I currently have this: final participantProvider = AsyncNotifierProvider.autoDispose.family< ParticipantNotifier, Map>, …
Wessel
  • 617
  • 4
  • 13
3
votes
2 answers

What is the correct way of providing a GoRouter instance with riverpod?

I'm trying to provide an instance of GoRouter with riverpod. However, this results in the "The riverpod_generator package does not support ChangeNotifier values" warning to be displayed: My question is, what would be the correct way of achieving…
Alex Lomia
  • 6,705
  • 12
  • 53
  • 87
3
votes
3 answers

How to ("partially") update AsyncValue in riverpod?

The riverpod (v2) documentation contains two great examples how a TODO-list could be implemented using either a Notifier or an AsyncNotifier. Both examples are functionally equivalent. To pick one particular detail the non-async example contains a…
Vinci
  • 1,382
  • 10
  • 12
3
votes
2 answers

Update value of variable inside list inside data class using Riverpod and copyWith method

Let's say I have a data class Dog that includes a List of puppies. @immutable class Dog extends Equatable{ final int id; final List listOfPuppies; Dog({required this.id,required this.listOfPuppies}); Dog copyWith({int?…
bqubique
  • 678
  • 6
  • 17
3
votes
1 answer

The argument type 'HWFamily' can't be assigned to the parameter type 'ProviderListenable'

I'm following the example in https://carltonaikins.me/how-to-use-riverpod-2-generator-in-your-flutter-project and I now have ... @riverpod class HW extends _$HW { @override dynamic build(foo) => 'HelloWorld'; // without foo, I get build dynamic…
pinoyyid
  • 21,499
  • 14
  • 64
  • 115
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
2 answers

How to change the app bar title depending on the selected GoRouter route?

I want to implement a GoRouter based navigation with a fixed Scaffold and AppBar, but change the title of the AppBar dynamically based on the selected route. I'm using GoRouter's ShellRoute to have a fixed Scaffold and AppBar and tried changing the…
schneida
  • 729
  • 3
  • 11
  • 37
3
votes
1 answer

Flutter + Beamer + Riverpods + Hot Reload = Multiple widgets used the same GlobalKey

I'm using Beamer to implement a tabbed interface with a navigation stack on each tab; similar to one of the Beamer examples. However, I'm driving the list of tabs from a Riverpod provider, rather than hard-coding them, and also monitoring the tab…
Sam Deane
  • 1,553
  • 1
  • 13
  • 17
3
votes
1 answer

Riverpod and immutability of a state vs. entites - how to get it right?

Recently I am learning Riverpod and I get to the idea of an immutable state. So far so good... except when in many tutorials entites were introduced. Different authors uses terms like: model entity state For me, my current understanding is…
Maciej Pszczolinski
  • 1,623
  • 1
  • 19
  • 38
3
votes
2 answers

How to provide Future to inside Providers using Riverpod?

I'm trying to learn Riverpod with clean architecture. I have following set/chain of providers: final databaseFutureProvider = FutureProvider((ref) async { final db = await DatabaseHelper().createDatabase(); // this is async because…
Maciej Pszczolinski
  • 1,623
  • 1
  • 19
  • 38
3
votes
1 answer

How to prevent provider from auto disposing when using riverpod_generator

I am using riverpod_generator and I don't see any way of keeping the provider alive. The generator code is actually equivalent to final fooProvider = FutureProvider.autoDispose((ref) async => 0); But in above code I could remove autoDispose but how…
iDecode
  • 22,623
  • 19
  • 99
  • 186
3
votes
1 answer

Flutter riverpod: 'Bad State No ProvderScope found' after using navigator

I have the following scanario: i`m using the riverpod state management across the application and everything works fine, but when I try to use in a screen that I reach using Navigator, the following error appear: Bad state: No ProviderScope…
Shadell
  • 33
  • 3