getBox static method

Future<CollectionBox<String>> getBox(
  1. String env
)

Retrieves or opens a box for the given environment.

Implementation

static Future<CollectionBox<String>> getBox(String env) async {
  if (_hiveBoxCollection == null) {
    throw StateError(
      'HHiveCore is not initialized. Please call HHiveCore.initialize() first.',
    );
  }
  if (_openedBoxes.containsKey(env)) {
    return _openedBoxes[env]!;
  }
  final box = await _hiveBoxCollection!.openBox<String>(env);
  _openedBoxes[env] = box;
  return box;
}