migrateFromHiveToSP method

Future<void> migrateFromHiveToSP()

Implementation

Future<void> migrateFromHiveToSP() async {
  if (_config.type != StorageType.sharedPreferences) {
    throw StateError('Current storage type is not SharedPreferences');
  }

  final tempBox = await Hive.openBox('temp_migration_box');
  final keys = tempBox.keys;

  for (final key in keys) {
    final value = tempBox.get(key);
    if (value != null) {
      await putObject(key.toString(), value);
    }
  }

  await tempBox.close();
}