For questions relating to the "riverpod" package for the Flutter framework.
Questions tagged [riverpod]
1086 questions
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
4
votes
2 answers
How to generate providers using Riverpod generator?
With riverpod_generator, I can use:
@riverpod
int foo(FooRef ref) => 0;
which is the equivalent of:
final fooProvider = Provider((ref) => 0);
But how can I do the same thing for other providers like FutureProvider, StateProvider, etc?

iDecode
- 22,623
- 19
- 99
- 186
4
votes
2 answers
Why you should use Riverpod?
There is setState and moreover Provider, using which you can manage your states easily and neatly, then why Riverpod?,
I see different examples in enter link description here where riverpod is being used, I just find each example making simple…

IonicFireBaseApp
- 925
- 3
- 10
4
votes
3 answers
Riverpod state update does not rebuild the widget
I'm using StateProvider
- > to keep track of user taps on the Tic Tac Toe board.
Actual board is a widget that extends ConsumerWidget and consists of tap-able GridView.
Within the onTap event of GridViews child - following is invoked to…

Sasa
- 93
- 1
- 5
4
votes
2 answers
Flutter Riverpod - .autoDispose - The argument type 'AutoDisposeProvider' can't be assigned to the parameter type 'AlwaysAliveProviderBase'
According to the docs when I'm getting this error I am supposed to mark both Providers with .autoDispose:
The argument type 'AutoDisposeProvider' can't be assigned to the
parameter type 'AlwaysAliveProviderBase'
Why am I still getting the error in…

Lara
- 84
- 1
- 7
- 30
4
votes
1 answer
Why most of the codes use Provider package and don't use GetX/Riverpod/Bloc?
I am learning Flutter. Most of the tutorials use Provider package but some others on Youtube use GetX. I searched about it and found that it seems there are another packages like Bloc, Riverpod, etc.
I am confused and don't know which one to use?
It…

GoodMan
- 542
- 6
- 19
4
votes
1 answer
Should you use setState when having RiverPod
I was wondering , since I started using RiverPod , if I should not use setState at all and have almost everything in StateNotifierProvider

Lerex
- 313
- 1
- 9
4
votes
2 answers
Is there a way to update the value of state provider in river pod after declaring it
final itemCountProvider = StateProvider((ref) {
return 0;
});
i need to keep track of number of items selected in my project initially the item count would be zero but later on i need to give it the calculated value how to update the value…

Likhith M
- 41
- 2
- 6
4
votes
1 answer
Flutter: How to rebuild using Riverpod within showModalBottomSheet
@override
Widget build(BuildContext context, WidgetRef ref) {
final provider = counterNotifierProviders(Counter.initialize());
final counter = ref.watch(provider);
return Scaffold(
body: ElevatedButton(
onPressed: () =>…

zbk
- 189
- 6
4
votes
6 answers
Why is riverpod failing even to initialize in project? Method not found: 'Error.throwWithStackTrace'
So i am trying to get started with riverpod and creating a new flutter project with the "click and counter" default sample.
As soon as I add on the pubspec
flutter_hooks: ^0.18.0
hooks_riverpod: ^2.0.0
And
import…

monkeygoat
- 43
- 1
- 1
- 4
4
votes
2 answers
how can i change bool variable using Flutter Riverpod
i am new to Flutter Riverpod management
i have stfl widget using Flutter Riverpod management, i need to change the test bool varible to true but cannot handle it
final testProvider = StateProvider((ref) => false);
`class FriendsList extends…

Nadia Yaseen
- 61
- 8
4
votes
0 answers
Is this flutter (riverpod with sqfite) code optimal/correct for manual reordering a list? (code attached)
Is this flutter (riverpod/StateNotifier) code optimal/correct for the use case of manually re-ordering a list, and for which order is persisted in SQLite (using sqfite)? Being new to riverpod aspects I'm seeking clarity on:
manually calculating…

Greg
- 34,042
- 79
- 253
- 454
4
votes
2 answers
Flutter Riverpod: Using ref.watch Outside of Build Function
In my Flutter app, I have a function gotoPage() that animates a PageView widget to a new page. I'd like this function to be called whenever newPageProvider is updated. How do I "activate" the ref.watch() inside the function gotoPage() when…

Matt
- 774
- 8
- 16
4
votes
3 answers
Flutter : Hot reload / Hot restart showing white screen with debug banner?
In my flutter app , when I try to hot reload or hot restart , after process complete , the reloaded screen shows for a second and then went whole white
only the Debug banner in top right side showing
There is no errors in the console. It just says…

RagAnt
- 1,064
- 2
- 17
- 35
4
votes
1 answer
Can't watch object instance with Riverpod
In a Flutter web project, I'm having this issue with Riverpod:
Consumer(
builder: (context, watch, child) {
final om=watch(human);
return Text(om.name); }
'watch' is underlined and the compiler says: The expression doesn't evaluate to a…

Eight Rice
- 816
- 7
- 24