I am playing around with the Hive Database for Flutter, and when I am trying to save an object, the documentations says about Adapters clearly:
As you can see, each field has a unique number (unique per class). These field numbers are used to identify the fields in the Hive binary format, and should not be changed once your class is in use.
So, after some refactoring, I need to change the classes and some attributes, including his numeration. After doing that obviously the database gives me error (was working perfectly before), and given that all the data from the database is dum data for testing purposes, I would like to Reser and restart a new Database form 0. I did try several things, like box.clear()
or Hive.deleteFromDisk()
after opening the boxes, but I am still getting an error about the Adapter attribute type does not match with another in the normal class (referencing the one before refactoring and changing the index).
How can I successfully remove all information and clean the database to start from Zero as a new install??
Thanks a lot!
Okkey, I found the answer:
The way to start the app as a new installation in the emulator is to desvnstall the app from the emulator and install it again.
Of course, if new changes to the index number in the Adapter, I would need to recreate these steps:
-Delete the adapters created
-Run flutter clean
-Delete the app from the emulator
-Create the new adapters with flutter packages pub run build_runner build
-Run the app again
Hope is useful for someone in the future :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With