isar / isar/hive

int list can't be saved

Open
#409 0 comments 0 reactions 1 assignee Claimed by @simc View on GitHub
problem
Dominant language
Dart
Stars
4.4k
Forks
449
PR merge metrics
No merged PRs in 30d

Description

I have a hive class that has a filed of type List
after saving an object of this class then query the box I got the List saved correctly
but after querying it after a period of time "one minute or more" it doesn't return the int list of the object any more

**Code sample**
```
@HiveType(typeId: DbUtils.addToCartType)
class AddToCartDb extends HiveObject{

@HiveField(0)
int productId;

@HiveField(1)
int quantity;

@HiveField(2)
List optionValues;

@HiveField(3)
List relatedOptionValues;

@HiveField(4)
String uuid;

AddToCartDb({this.productId, this.quantity, this.optionValues,
this.relatedOptionValues,this.uuid});

}

List list = await convertDbModelToAddItemToCartApi();
if(list?.isNotEmpty == true)
List a = list[0].optionValues;// return empty list

Future> convertDbModelToAddItemToCartApi() async {
List list = List();
var addToCartBox = await Hive.openBox(DbUtils.addToCartName);
for (int i = 0; i < addToCartBox.length; i++) {
AddToCartDb item = addToCartBox.getAt(i);

List relatedValues = List();

if (item.relatedOptionValues?.isNotEmpty == true) {
for (int j = 0; j < item.relatedOptionValues.length; j++) {
RelatedOptionValues value = RelatedOptionValues(
item.relatedOptionValues[j].optionValue1,
item.relatedOptionValues[j].optionValue2,
);
relatedValues.add(value);
}
}

OptionsAddToCart optionsAddToCart = OptionsAddToCart(
optionValues: item.optionValues, relatedOptionValues: relatedValues);
DataAddToCart data = new DataAddToCart(
productId: item.productId,
quantity: item.quantity,
options: optionsAddToCart);
list.add(data);
}
return list;
}

```

**Version**
- Platform: iOS, Android, Mac, Windows, Linux, Web
- Flutter version: [1.17.5]
- Hive version: [ 1.4.1+1]

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.