I am using hive and getx together, I am trying to get all data inside hive with watch
method:
Stream<List<VocabularyModel>> watchVocabsFromdb() => hiveService.vocabularyBox
.watch()
.map((event) => hiveService.vocabularyBox.values
.where((element) => element.remember == true)
.toList());
In controller I am using this method:
class WordsController extends GetxController {
WordsController();
late Stream<List<VocabularyModel>> allVocabs;
@override
void onReady() {
log.info('onReady');
super.onReady();
allVocabs = repository.watchVocabsFromdb();
}
Inside view I am using Obx to catch change of hive box :
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Obx(() => ListView.builder(
itemCount: controller.allVocabs.length, ///... Future<int> is not int
itemBuilder: (context, index) {
return Container();
},
)),
),
How can I use hive whats like obs list?