hive
                                
                                
                                
                                    hive copied to clipboard
                            
                            
                            
                        App Crash on Restart with following exception Unhandled Exception: type 'Null' is not a subtype of type
I have followed the sample code properly. While the app is running it works fine. It saves and retrieves data. But when I restart the application it crashes with an exception.
** if (!kIsWeb) { Directory dir = await getApplicationDocumentsDirectory(); Hive.init(dir.path); } //await Hive.initFlutter(); Hive.registerAdapter<Company>(CompanyAdapter()); Hive.registerAdapter<Media>(MediaAdapter()); Hive.registerAdapter<KeyWord>(KeyWordAdapter());
if (!Hive.isBoxOpen('storyBox')) { await Hive.openBox<Map<String, dynamic>>( 'storyBox', ); }
**
[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: type 'Null' is not a subtype of type 'Company'
#0      CompanyAdapter.read (package:presseportal/domain/news/story_adapter.dart:47:19)
#1      BinaryReaderImpl.read (package:hive/src/binary/binary_reader_impl.dart:328:33)
#2      BinaryReaderImpl.readMap (package:hive/src/binary/binary_reader_impl.dart:212:21)
#3      BinaryReaderImpl.read (package:hive/src/binary/binary_reader_impl.dart:319:16)
#4      BinaryReaderImpl.readFrame (package:hive/src/binary/binary_reader_impl.dart:276:26)
#5      FrameHelper.framesFromBytes (package:hive/src/binary/frame_helper.dart:21:32)
#6      FrameIoHelper.framesFromFile (package:hive/src/io/frame_io_helper.dart:42:12)
<asynchronous suspension>
#7      StorageBackendVm.initialize (package:hive/src/backend/vm/storage_backend_vm.dart:86:11)
<asynchronous suspension>
#8      HiveImpl._openBox (package:hive/src/hive_impl.dart:105:9)
<asynchronous suspension>
Version
- Platform: iOS, iPhone Pro Max Device and Simulator
 - Flutter version: Flutter (Channel stable, 3.7.1, on macOS 13.2 22D49 darwin-arm64, locale en-DE)