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…
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…
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…
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…
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…
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…
-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…