How do I add new properties to hiveobject
- Dominant language
- Dart
- Stars
- 4.4k
- Forks
- 449
- PR merge metrics
- No merged PRs in 30d
Description
class Person extends HiveObject {
@HiveField(0)
String? name;
@HiveField(1)
int? age;
}
class PersonAdapter extends TypeAdapter {
@override
final int typeId = 0;
@override
Person read(BinaryReader reader) {
return Person(
name: reader.readString(),
age: reader.readInt()
);
}
@override
void write(BinaryWriter writer, obj) {
writer.writeString(obj.name ?? '');
writer.writeString(obj.age ?? 0);
}
}
// like this, if i want to add "address" on Person class, what should I do
// an error will be reported if I add "address: reader.readString()," to PersonAdapter.read method --- Unhandled Exception: RangeError: Not enough bytes available.
// can u tell me what I should do,thank u, orz
Contributor guide
No contributing guide indexed for this repository
Research direction
The issue provides a Dart Person model and PersonAdapter.read/write entry points; start by reviewing how these methods serialize existing records. Document the supported procedure for adding the address property and how older stored data should remain readable. Done means the example explains the migration behavior and avoids the reported RangeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- databases, documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100