What is the best practice for using an external library's enum with Hive? #1280
Unanswered
yamashita-room-335
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I understood that the enum implemented in MyApp should use @HiveType annotation as shown in the link below.
https://docs.hivedb.dev/#/custom-objects/generate_adapter?id=enums
But there are times when I want to save the enum of an external library.
(e.g., save ThemeMode from material library and manage app-specific ThemeMode)
https://api.flutter.dev/flutter/material/ThemeMode.html
How do you guys implement such a case?
I have come up with the following two methods
This method has the following drawbacks
This method has the following drawbacks
I would appreciate it if you could share your thoughts on best practices.
In both cases, we need to add code when registering a new enum to Hive.
So I would be most happy to see a convenient feature like isar's enumerated annotation!
https://pub.dev/documentation/isar/latest/isar/Enumerated-class.html
Beta Was this translation helpful? Give feedback.
All reactions