when I tried to add a new field(intWrkTime) and I had generated a new adapter I had this problem although I had initialized it in all my usages
the error : Unhandled Exception: type 'Null' is not a subtype of type 'int' in type cast
import 'package:hive/hive.dart';
part 'emp_model.g.dart';
@HiveType(typeId: 0)
class EmployeeModel extends HiveObject
{
@HiveField(0)
late String empName;
@HiveField(2)
late int idWrkTime;
EmployeeModel({
required this.empName,
required this.idWrkTime,
});
}
CodePudding user response:
do like this
@HiveType(typeId: 0)
class TaskEntitiy extends HiveObject {
int id = -1;
@HiveField(0)
String name = '';
@HiveField(1)
bool isCompleted = false;
}
dont put late before fields and give them default amount
Blockquote