hive
hive copied to clipboard
Listas de objetos anidados falla.
El inconveniente se presenta cuando consulto una lista de objetos anidados lo guardo en una variable, luego modificó un valor de algún objeto de la lista y al intentar consultar de nuevo los datos a mi box.hive los datos almacenados en la variable local se reflejan en los resultados de la consulta.
Sí limpio la variable local y ejecutor de nuevo una consulta al box los resultados son Null, como si no contuviese ningún dato. @HiveType(typeId: 7) class Combos extends HiveObject { @HiveField(0) int codigo; @HiveField(1) String nombre; @HiveField(2) List<CombosDetalle> datosDescontar; @HiveField(3) String sincronizado; Combos({ required this.codigo, required this.nombre, required this.datosDescontar, required this.sincronizado, });
adaptador de CombosDetalle
`@HiveType(typeId: 10) class IdentificadorDetalle extends HiveObject { @HiveField(0) int codigo; @HiveField(1) String nombre; @HiveField(2) String identificador; @HiveField(3) double cantidad;
IdentificadorDetalle({ required this.codigo, required this.nombre, required this.identificador, required this.cantidad, });`
Aquí coloco mi ejemplo
IconButton( onPressed: () { Combos combo = boxCombos.get(1); List<CombosDetalle> detalle = combo.datosDescontar; print('valor de cantidad: ${detalle[0].cantidad}'); // valor de cantidad: 1.0 //cambiare los datos almacenados en delalle detalle[0].cantidad = 100.0; double value = boxCombos.get(1).datosDescontar[0].cantidad; print('valor de cantidad: $value'); //valor de cantidad:100.0 }, icon: const Icon(Icons.edit), ),
Version
- Platform: iOS, Android, Mac, Windows, Linux, Web
- Flutter version: [3.1.0]
- Hive version: [2.2.1]
"The inconvenience occurs when I consult a list of nested objects I save it in a variable, then it modified a value of some object in the list and when I try to consult the data again to my box.hive the data stored in the local variable is reflected in the query results. If I clean the local variable and execute a query to the box again, the results are Null, as if it did not contain any data."