how to use stateNotifierProvider or changeNotifierProvider that depends on future Provider #1547
gopiKrishnaPuligundla
started this conversation in
General
Replies: 2 comments 1 reply
-
any inputs would be helpful .. am new to flutter |
Beta Was this translation helpful? Give feedback.
0 replies
-
I don't really understand the question but I think this is what you want. final objectBoxProvider = FutureProvider((ref) async {
return await ObjectBox.init();
});
//final quotesAllProvider = StateNotifierProvider<AsyncValue<List>>((ref) async {
final OBNProvider = ChangeNotifierProvider((ref) {
ObjectBox? ob = ref.watch(objectBoxProvider).value;
//return ob?.getAllQuotes();
return ObjectBoxNotifier(objectBox: ob);
} ); |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi All,
my requirement is , i want to have a listview that displays list of quotes which are stored in object box .
i tried changenotifierprovider to keep track of CRUD for quotes , so that listview widget gets rebuild.
but changenotifierProvider initialisation needs a object box instance which is a future , so i defined a future provider for initialising object box.
and in changenotifierprovider initialisation am listening to future provider as below, but it is not working .. please find code snippet below
final objectBoxProvider = FutureProvider((ref) async {
return await ObjectBox.init();
});
//final quotesAllProvider = StateNotifierProvider<AsyncValue<List>>((ref) async {
final OBNProvider = ChangeNotifierProvider((ref) {
ObjectBox? ob = ref.read(objectBoxProvider).value;
//return ob?.getAllQuotes();
return ObjectBoxNotifier(objectBox: ob);
} );
i feel some basic understanding of riverpod is wrong from my end.
git repo link : https://github.com/gopiKrishnaPuligundla/japa_counter/blob/dev_branch/
Beta Was this translation helpful? Give feedback.
All reactions