In Flutter, I using ValueListenableBuilder
widget to get list of hive data,
and I'm trying to filter my data by data values.
Example:-
Key: 1
name(value) : mydata1
des(value) : mydescription1
value(value) : 1
here in this example I want to filter data by data value called value(value)
by help of dropdown,
like:
if (value.compareTo(1) == 1){
print('All First Value Data Showing Result');
}
Something like that:
Expanded(
child: ValueListenableBuilder(
valueListenable: msgbox.listenable(),
builder: (context, box, _) {
Map<dynamic, dynamic> raw = box.toMap();
List list = raw.values.toList();
return ListView.builder(
itemCount: list.length,
itemBuilder: (context, index){
MsgModel msges = list[index];
return GestureDetector(
onDoubleTap: () {},
child: Padding(
padding: EdgeInsets.only(left: 8, right: 8),
child: Column(
children: [
...
To Edit Your Model Object ,you will need hive model key soon and later. For that I have some kind of filtering keys specific and use those to read data. Do not use
index
frombox.values
because it can misleading issue when you delete or update some data on a model likebox.putAt(index,updatedModel)
orbox.deleteAt(index,toBeDeletedModel)
when multi selecting models.