-
Notifications
You must be signed in to change notification settings - Fork 408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Isar vs Hive (what should we be using now?) #1292
Comments
Hive, in my opinion is better for clean architecture because you don't have to use the generator and all the annotations in your core model classes. consider this product model using dart_mappable package to generate @MappableClass(discriminatorKey: 'type')
sealed class Product with ProductMappable {
const Product(this.id, {required this.isAvailable});
final int id;
final bool isAvailable;
}
@MappableClass()
class AvailableProduct extends Product with AvailableProductMappable {
const AvailableProduct(super.id) : super(isAvailable: true);
}
@MappableClass()
class UnAvailableProduct extends Product with UnAvailableProductMappable {
const UnAvailableProduct(super.id) : super(isAvailable: false);
} using this code at your core folder of your app is a good practice because it depends only on dart_mappable and not on your services (Hive, Isar, Sqflite) or logic (Bloc, Riverpod) .... then you add the following code to make it compatible with Hive class ProductAdapter extends TypeAdapter<Product> {
@override
Product read(BinaryReader reader) {
final map = reader.readMap().map((key, value) => MapEntry(key.toString(), value));
return ProductMapper.fromMap(map);
}
@override
int get typeId => 10;
@override
void write(BinaryWriter writer, Product obj) {
writer.writeMap(obj.toMap());
}
} If you want now to change, lets say to Sqflite, you don't need to change your core prodcut models. |
To bee or not to bee: |
I suggest you find the most recent version of either hive or isar that works for your requirement. Do not bank on any future functionality being delivered to bail you out. Now if you're able to fork and self maintain go crazy. I use hive for exactly the reasons @CardosoShlomo cites. But don't have much faith in future support. |
I am confused on what to use. On Isar faq page I find this.
On the hive quick start page I find this:
And in the github page of hive I find this:
I am building a shopping list/ todo list. Super simple. What should I be using? I would think hive because it is just a key value store. But after reading the other pages I am not sure anymore. Can we have clarification on this?
The text was updated successfully, but these errors were encountered: