Skip to content

Commit

Permalink
Register ColorAdapter and TimeOfDayAdapter in Hive.initFlutter
Browse files Browse the repository at this point in the history
  • Loading branch information
Rexios80 committed Jul 5, 2024
1 parent 12baacc commit 3b0d0dc
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions hive_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 2.0.0

- BREAKING: Register `ColorAdapter` and `TimeOfDayAdapter` in `Hive.initFlutter`
- MIGRATION: Remove external registration of `ColorAdapter` and `TimeOfDayAdapter`

## 1.2.0

- The first release of hive_ce_flutter
1 change: 1 addition & 0 deletions hive_flutter/lib/hive_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:hive_ce/hive.dart';
import 'package:hive_ce_flutter/adapters.dart';
import 'package:path/path.dart'
if (dart.library.js_interop) 'src/stub/path.dart' as path_helper;
import 'package:path_provider/path_provider.dart'
Expand Down
5 changes: 5 additions & 0 deletions hive_flutter/lib/src/hive_extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ extension HiveX on HiveInterface {
/// Initializes Hive with the path from [getApplicationDocumentsDirectory].
///
/// You can provide a [subDir] where the boxes should be stored.
///
/// Also registers the flutter type adapters
Future<void> initFlutter([
String? subDir,
HiveStorageBackendPreference backendPreference =
Expand All @@ -22,5 +24,8 @@ extension HiveX on HiveInterface {
path,
backendPreference: backendPreference,
);

registerAdapter(ColorAdapter());
registerAdapter(TimeOfDayAdapter());
}
}
2 changes: 1 addition & 1 deletion hive_flutter/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: hive_ce_flutter
description: Extension for Hive. Makes it easier to use Hive in Flutter apps.
version: 1.2.0
version: 2.0.0
homepage: https://github.com/IO-Design-Team/hive_ce/tree/main/hive_flutter
documentation: https://docs.hivedb.dev/

Expand Down

0 comments on commit 3b0d0dc

Please sign in to comment.