supabase / supabase-flutter

Flutter integration for Supabase. This package makes it simple for developers to build secure and scalable products.
https://supabase.com/
MIT License
662 stars 155 forks source link

Dependency conflict with hive package #812

Closed Namli1 closed 4 months ago

Namli1 commented 5 months ago

supabase_flutter depends on hive: ^2.2.1, but the newest version of the package hive: ^4.0.0. I would like to use that newer version in my project but as there have been some breaking changes, supabase_flutter is incompatible with hive: ^4.0.0. It seems like migrating from the older to the newer version of hive can be done by updating a few lines, the only problem is be that people still using hive: ^2.2.1 would then in turn receive an incompatible error. So I wanted to ask how this dependency conflict can be resolved, maybe by either completely removing HiveLocalStorage, as SharedPreferencesLocalStorage is the default local storage anyway or by moving HiveLocalStorage out of the package so it won't cause a dependency conflict anymore. Any thoughts on this?

Vinzent03 commented 5 months ago

v.3 and v.4 are both dev releases, which aren't compatible with the old version, so when allowing the newer versions as well, one might upgrade accidentally to the dev release and the old sessions aren't available. So I think it's better when you try to solve the issue via dependency_overrides

Namli1 commented 5 months ago

Thank you for you reply. I have actually already tried resolving the issue with dependency_overrides, but that way the local_storage.dart file in supabase_flutter will throw errors because hive: ^4.0.0 is not backward compatible with hive: ^2.2.1. For example, you get an error like (when using hive: ^4.0.0):

../../../../.pub-cache/hosted/pub.dev/supabase_flutter-2.3.1/lib/src/local_storage.dart:85:5: Error: 'HiveCipher' isn't a type.
    HiveCipher? encryptionCipher;

I am not sure if there is a way to simply ignore the file where the non-compatible HiveLocalStorage is defined when depending on supabase_flutter, but currently it is defined in the same local_storage.dart file as SharedPreferencesLocalStorage, so those definitions would need to be put into separate files before that could work.

The only fix I can think of right now is to remove the HiveLocalStorage from the supabase_flutter package (therefore completely removing the dependency on hive) and then have developers using HiveLocalStorage just copy and paste the class into their flutter project. I do see that this is not really an optimal solution, but currently supabase_flutter prohibits anyone from using hive: 4.0.0, which is also not optimal.

dshukertjr commented 5 months ago

The only fix I can think of right now is to remove the HiveLocalStorage from the supabase_flutter package (therefore completely removing the dependency on hive) and then have developers using HiveLocalStorage just copy and paste the class into their flutter project.

Yeah, maybe it's about time to do this. It's not ideal to keep the hive dependency around anyway.

@Namli1 Just out of curiosity, what is the reason why you want to use hive 4.x-dev and not 2.x? Is it just because it's new?

Namli1 commented 5 months ago

@dshukertjr I mainly want to use the hive 4.x-dev version to save myself the trouble of migrating from hive 2.x to hive 4.x later on and as the hive 4.x is built on top of isar, there also seem to be a few performance improvements.