How to make hive singleton class for saving datas like favourites cartitem?
I have created a singleton class for saving data to local storage with GetStorage
, here I have a bucket named userdata
and i want to save favouriteproductids
, cartitems
and many other list,
How to make hive singleton class for saving datas like favourites cartitem?
I have created a singleton class for saving data to local storage with GetStorage
, here I have a bucket named userdata
and i want to save favouriteproductids
, cartitems
and many other list,
hive use in flutter offline and online condition
when the internet is connect data get dynamic but when the internet is offline data gets to hive local database how to use it is briefly explained in Flutter. I implemented hive and tried to fetch data from the hive display but I still fetching errors some time so I need to give a proper example and it’s used.
Flutter Error. Unhandled Exception: HiveError: Cannot write, unknown type: Settings. Did you forget to register an adapter?
I am developing an application in which it is necessary to save user metrics locally in the settings window. I decided to use Hive for this purpose. Generated and registered the adapter. I opened the box, I’m trying to use .put, but I get an error: E/flutter (19700): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: HiveError: Cannot write, unknown type: Settings. Did you forget to register an adapter?
E/flutter (19700): #0 BinaryWriterImpl.write (package:hive/src/binary/binary_writer_impl.dart:338:9)
E/flutter (19700): #1 BinaryWriterImpl.writeFrame (package:hive/src/binary/binary_writer_impl.dart:282:9)
E/flutter (19700): #2 StorageBackendVm.writeFrames. (package:hive/src/backend/vm/storage_backend_vm.dart:128:31)
E/flutter (19700): #3 ReadWriteSync.syncWrite. (package:hive/src/backend/vm/read_write_sync.dart:26:41)
E/flutter (19700):
E/flutter (19700): #4 _AsyncCompleter.complete (dart:async/future_impl.dart:41:3)
E/flutter (19700):
E/flutter (19700): #5 BoxImpl._writeFrames (package:hive/src/box/box_impl.dart:88:7)
E/flutter (19700):
E/flutter (19700):
My code:
Main.dart