flutterdarthiveadapter

Facing "RangeError: Not enough bytes available." When i try to get values from Hive db


I have an application that send a type to a db in Hive and in my adapter I have the methods read and write to all my variables. The problem is with this variable:

@HiveField(5)
String? imoString;

This is the line responsible to read the variable in adapter:

model.imoString = reader.readString();

and this one is to write:

writer.writeString(model.imoString ?? "");

I am 100% sure that I'm saving the variable correctly (with the type string and the value as the value the user wrote in screen) because I can print it in write method. But when I reload the app and the method get from db is called I face this error pointing to the line model.imoString = reader.readString();:

Unhandled Exception: RangeError: Not enough bytes available.

What can I do?

I tried to read with reader.read but it didnt work as well Obs: the variables are in the right sequence in read and write methods

EDIT I figured out that if I comment the first item of this adapter in both read and write it works.. this first element is another model with its own adapter (it has a lot of variables)


Solution

  • You can try changing all the varibles both in read and write to just read() and write() without the type