Questions tagged [riverpod-annotation]
9 questions
2
votes
1 answer
How can I implement MVVM pattern with riverpod annotation in Flutter?
I am trying to make MVVM architecture with riverpod annotation. And Here are some example code snippets.
import ...
part 'invite_customer_usecase.g.dart';
@riverpod
class InviteCustomerUseCase extends _$InviteCustomerUseCase {
final…

c-an
- 129
- 1
- 8
2
votes
1 answer
How can I create a "non-autodispose" provider with riverpod_annotation?
Observations
if I create a provider using riverpod_annotation as follow
import 'package:riverpod_annotation/riverpod_annotation.dart';
part 'foo.g.dart';
@riverpod
String foo(FooRef ref) => 'foo';
said provider will needlessly be a…

Francesco Iapicca
- 2,618
- 5
- 40
- 85
1
vote
1 answer
Usage of ref.read() and ref.watch() inside OnPressed function in Flutter
The Riverpod documentation clearly states that:
The watch method should not be called asynchronously, like inside an onPressed of an ElevatedButton. Nor should it be used inside initState and other State life-cycles. In those cases, consider using…

Johny Gates
- 75
- 1
- 9
1
vote
1 answer
Merge different states with Riverpod and Freezed
I have a page that needs two different API calls.
I am applying the clean architecture to write the code and Riverpod as State Management. Then I am using the Freezed package to map the different states.
How can I combine the different states?
What…

patana93
- 73
- 1
- 8
1
vote
1 answer
how do I fix riverpod_lint error message 'If a provider depends on providers which specify "dependencies"...'
set up
create a new project
add the dependencies visible under additional information
add the files below
foos.dart
import 'package:riverpod_annotation/riverpod_annotation.dart';
part 'foos.g.dart';
@Riverpod(keepAlive: true)
class Foos…

Francesco Iapicca
- 2,618
- 5
- 40
- 85
0
votes
1 answer
Which model is better while using Riverpod
What is the best approach for managing State for Views in RiverPod?
I want to have all the screen states (list data, order, page, search filter, etc.) in State.
A. Use AsyncNotifier for @freezed State classes
It is necessary to prepare multiple…

Youya
- 11
- 3
0
votes
0 answers
How to inject token to the dio provider from Riverpod StateNotifierProvider?
Using riverpod_generator.
How can I inject JWT token to the auth header in Dio:
@riverpod
Dio dio(DioRef ref) => Dio();
@riverpod
ITodoDatasource todoApiService(TodoApiServiceRef ref) {
Dio dio = ref.watch(dioProvider);
return…

Alvin
- 8,219
- 25
- 96
- 177
0
votes
1 answer
"Bad state: Tried to read the state of an uninitialized provider" with riverpod while listening to futureprovider
I have this generated notifier that should rebuild when the data changes without loosing its reference to a previously selected object on rebuild.
@Riverpod(keepAlive:true)
Future
- > modelList (ModelListRef ref) {
return…

Christian
- 834
- 7
- 18
-1
votes
1 answer
How does @riverpod work? I got The argument type 'AutoDisposeNotifierProviderImpl' error
I am using riverpod annotation and stuck here.
@riverpod
ShopRepository shopRepository(ShopRepositoryRef ref) => ShopRepositoryImpl(dio: authDio(), managerLocalStorage: ref.watch(managerLocalStorageImplProvider));
managerLocalStorageImplProvider…

c-an
- 129
- 1
- 8