init method

Future<void> init()

Initializes the adapter by opening the Hive box. This method must be called before using any other methods of this adapter.

Implementation

Future<void> init() async {
  if (_isInitialized) return;

  if (!Hive.isBoxOpen(_boxName)) {
    _box = await Hive.openBox(_boxName);
  } else {
    _box = Hive.box(_boxName);
  }

  _isInitialized = true;
}