Open mitty1987 opened 4 years ago
I found the reason. Because of the use of serializable, I need extends $tagversionserializable, and $tagversionserializable extends map, which causes typeadapter < tagversion > to fail, so I modify the method BinaryWriterImpl.write,
void write<T>(T value, {bool writeTypeId = true}) {
if (value == null) {
if (writeTypeId) {
writeByte(FrameValueType.nullT);
}
return;
}
var resolved = _typeRegistry.findAdapterForValue(value);
if (resolved != null) {
if (writeTypeId) {
writeByte(resolved.typeId);
}
resolved.adapter.write(this, value);
} else if (value is int) {
if (writeTypeId) {
writeByte(FrameValueType.intT);
}
writeInt(value);
} else if (value is double) {
if (writeTypeId) {
writeByte(FrameValueType.doubleT);
}
writeDouble(value);
} else if (value is bool) {
if (writeTypeId) {
writeByte(FrameValueType.boolT);
}
writeBool(value);
} else if (value is String) {
if (writeTypeId) {
writeByte(FrameValueType.stringT);
}
writeString(value);
} else if (value is List) {
_writeList(value, writeTypeId: writeTypeId);
} else if (value is Map) {
if (writeTypeId) {
writeByte(FrameValueType.mapT);
}
writeMap(value);
} else {
throw HiveError('Cannot write, unknown type: ${value.runtimeType}. '
'Did you forget to register an adapter?');
}
}
First check Adapter...
IMHO dart does this thing where during execution it generates an InternalLinkedHashMap. So be sure to call a .toMap() wherever it throws the error to convert it to a map. This should be a temporary fix to the problem
Maybe check Adapter should be at first when write to db Hive version: 2.0.0
Steps to Reproduce b and b2 are all right, but b3.values or get will throw the exception after reopen box as TagVersion...
Version