isar / isar/hive

Hive Type adapter for OOTB DateTimeRange

Open
#1,098 2 comments 3 reactions 0 assignees View on GitHub
question
Dominant language
Dart
Stars
4.4k
Forks
449
PR merge metrics
No merged PRs in 30d

Description

**Question**
I am trying to use Hive to store an object which includes an OOTB DateTimeRange.
I'm getting the following error when I try and store an object including this:
_"Error: HiveError: Cannot write, unknown type: DateTimeRange. Did you forget to register an adapter?"_

How can I register DateTimeRange as a useable type?

Many thanks

**Code sample**
```dart
@HiveType(typeId: 1)
class Trip extends HiveObject {
@HiveField(0)
var id;

@HiveField(1)
late String name;

@HiveField(2)
late DateTimeRange? dateRange;

...
}
```

**Version**
- Flutter Version 3.3.6 (stable channel)
- Hive ^2.2.1

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the DateTimeRange field in the Trip example and the reported “unknown type” HiveError. Read the project’s adapter-registration guidance and inspect how custom types are serialized. Done means providing a confirmed way to store DateTimeRange, or documenting that it requires conversion or an adapter.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, flutter
Domain
database
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.