'retreiving list values form hive box flutter

I am having trouble getting "hours" int value from hive box and get the sum of all hours total and display it in a card as a String hours. what I have is:

 var data = fastBox.values.where((element) => element.hours != 
  0).toList();

 if (fastBox.isNotEmpty){
  int hoursInt = data.reduce((value, element) => {
    value.hours + element.hours
  });
  hours = "${hoursInt.toString()}";
} else{
  hours = "0 " + Languages.of(context)!.hours;
}`

i am getting error:

Class 'List<dynamic>' has no instance getter 'hours'.
 Receiver: Instance(length:1) of '_GrowableList'
Tried calling: hours

my hive is:

 @HiveType(typeId: 4)
class FastHive{
@HiveField(0)
final int days;
@HiveField(1)
final List<DateTime> dates;
@HiveField(2)
final int hours;
@HiveField(3)
DateTime startTime;
@HiveField(4)
DateTime endTime;

FastHive(this.days, this.dates, this.hours, this.startTime, 
  this.endTime);
}

just learning here. pls, help! Thank you!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source