The documentation is not very clear of when to use:
GetX
Would be Nice to have an example written in all possible ways.
Also, is not very Clear where we should instantiate our Controller. Please include the scope of the controller and where should it be instantiated(meaning Scope).
Thank you very much.
just to be sure, you already read this page right? https://github.com/jonataslaw/getx/blob/master/documentation/en_US/state_management.md
just to be sure, you already read this page right? https://github.com/jonataslaw/getx/blob/master/documentation/en_US/state_management.md
Yes Sr i went all over the place. maybe is because i am very new to flutter, but after watching some more youtube videos i understood, even though i think the docs should be enough, in this case it wasn't enough for me, as a new flutter programmer
I had thoughts on similar lines. I read the state management docs and went through both reactive and simple state management. It would help if there is a comparison between those two and also which approach is better for which use case with the help of examples
just to be sure, you already read this page right? https://github.com/jonataslaw/getx/blob/master/documentation/en_US/state_management.md
Agree. i confused when/where should i use Obx or GetBuilder. I have an issue to fetch API data from my custom GetxCotroller and the _Future_ doesn't work properly. Imagine...
Future loadNotes() async {
notes.addAll(await Note.get(_mainController.agent.value.accessToken));
log('${notes.length}', name: 'NOTES_COUNT');
}
Future loadCategories() async {
categories.addAll(await Category.getCategories());
log('${categories.length}', name: 'CATEGORIES_COUNT');
}
Future loadNews() async {
news.value = await News.getNews();
log('${news.length}', name: 'NEWS_COUNT');
}
void onInit() {
Future.wait([
loadNotes(),
loadCategories(),
loadNews()
]);
super.onInit();
}
All the _Future_ function don't wait until the API completely loaded. So when my screen is build, it showing many errors because the _Future_ didn't completely loaded. Doesn't work with Obx or GetBuilder. How should i fix this?
@kingmaster772 As far I know, flutter doesn't let wait async to be resolved when building Widget. Is it right @jonataslaw ?
That's why we need to use something like FutureBuilder or Rx with default value.
@kingmaster772 As far I know, flutter doesn't let wait async to be resolved when building Widget. Is it right @jonataslaw ?
That's why we need to use something like
FutureBuilderorRxwith default value.
Exactly.
Asynchronous events will be executed after the build. You need a FutureBuilder or reactive programming (recommended) for this. This is the basics of dart.
The documentation is not very clear of when to use:
GetX or Obx() or GetBuilder
There is a dedicated topic in the documentation just to explain how each one works and in which situation each of them could be better reused. Today I think anyone can do anything, but Rx prevents unnecessary reconstructions, while the simple state manager, being a mechanical update, gives you more control over the change of state, but if you call the update, the view will be updated . The rest does not make much difference.
Would be Nice to have an example written in all possible ways.
Also, is not very Clear where we should instantiate our Controller. Please include the scope of the controller and where should it be instantiated(meaning Scope).
Controllers can be instantiated in 3 ways and the 3 are explained. The first is using Get.put (Controller) in the view instance, the second is using "init" to initialize the controller there, and the third, more advanced, but what I recommend is the use of Bindings.
Thank you very much.
Well, we are already improving the documentation daily, so that this issue becomes redundant.
That's why I'm closing it.
Most helpful comment
There is a dedicated topic in the documentation just to explain how each one works and in which situation each of them could be better reused. Today I think anyone can do anything, but Rx prevents unnecessary reconstructions, while the simple state manager, being a mechanical update, gives you more control over the change of state, but if you call the update, the view will be updated . The rest does not make much difference.
Controllers can be instantiated in 3 ways and the 3 are explained. The first is using Get.put (Controller) in the view instance, the second is using "init" to initialize the controller there, and the third, more advanced, but what I recommend is the use of Bindings.
Well, we are already improving the documentation daily, so that this issue becomes redundant.
That's why I'm closing it.