Skip to content
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

Dependency conflict with hive package #812

Closed
Namli1 opened this issue Jan 27, 2024 · 4 comments · Fixed by #823
Closed

Dependency conflict with hive package #812

Namli1 opened this issue Jan 27, 2024 · 4 comments · Fixed by #823
Labels
bug Something isn't working

Comments

@Namli1
Copy link

Namli1 commented Jan 27, 2024

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?

@Namli1 Namli1 added the bug Something isn't working label Jan 27, 2024
@Vinzent03
Copy link
Collaborator

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
Copy link
Author

Namli1 commented Jan 29, 2024

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
Copy link
Member

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
Copy link
Author

Namli1 commented Jan 30, 2024

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants