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

BoxEvent value is null when watching a LazyBox #265

Closed
adiospace opened this issue Mar 28, 2020 · 6 comments · Fixed by #592
Closed

BoxEvent value is null when watching a LazyBox #265

adiospace opened this issue Mar 28, 2020 · 6 comments · Fixed by #592
Labels
question Further information is requested

Comments

@adiospace
Copy link

adiospace commented Mar 28, 2020

Question
When watching a lazy box by key, event.value is null. Is this the correct behaviour?

Code sample

await Hive.openLazyBox<Game>('games');
LazyBox<Game> game = await Hive.lazyBox('games').get('id');

game.watch(key: game.id).listen((e) { print(e.value == null);});

game.nextLevel++;
game.save();

Version

  • Platform: iOS, Android, Mac, Windows, Linux, Web
  • Flutter version: 1.12.13+hotfix.8
  • Hive version: ^1.4.1+1
@adiospace adiospace added the question Further information is requested label Mar 28, 2020
@dop3ch3f
Copy link

Seems to me like normal behavior. IMHO game.watch().listen is like the default stream subscription so it should behave like one and if its initialized without data its going to return null.

@simc
Copy link
Member

simc commented May 31, 2020

When watching a lazy box by key, event.value is null. Is this the correct behaviour?

I don't think it is. Does this still happen?

@JayDev43
Copy link

JayDev43 commented Jan 2, 2021

Hi,

This has just happened to me too.

Debugging the code, I think the problem is that in LazyBoxImpl.putAll() the frame is being converted to a lazy Frame using frame.toLazy() and is then passed into the keystore.insert() method. When that frame makes it the the notifier as its a lazy Frame the value is null and this is what is then being sent out onto the stream.

Hope that helps solve the problem.

@kyleschlosser
Copy link

This just happened to me too. I am on ^1.5.0-pre.

@Abdelazeem777
Copy link

I am facing the same problem here with ^1.4.4+1.
Also, I did some debugging and I think the problem is with frame.toLazy() because it returns a frame with null value.

@dkunzler
Copy link
Contributor

dkunzler commented Mar 1, 2021

I can confirm the problem with 1.6.0-nullsafety.2

@dkunzler dkunzler mentioned this issue Mar 6, 2021
Jjagg pushed a commit to Jjagg/hive that referenced this issue Mar 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants