KonectarEvents/lib/contacts_module/storage_hive/speaker_data/crud.speaker.dart

43 lines
1.2 KiB
Dart
Raw Normal View History

2024-10-08 12:01:59 +00:00
// import 'package:konectar_events/storage_hive/speaker_data/speaker_model_hive.dart';
import 'package:konectar_events/contacts_module/storage_hive/speaker_data/speaker_model_hive.dart';
import 'package:hive_flutter/hive_flutter.dart';
addSpeaker(List nihlist) async {
var box = await Hive.openBox<Spe>('speahive');
List<Spe> pros = nihlist.map((json) {
return Spe(
id: json.id,
programtopic: json.programtopic,
speakername: json.speakername.toString() ?? '',
role: json.role ?? '',
evaluatorname: json.evaluatorname.toString() ?? '',
programdate: json.programdate.toString() ?? '',
createdAt: json.createdAt.toString() ?? '',
updatedAt: json.updatedAt.toString() ?? '',
);
}).toList();
print("Eduactionnsss ${pros}");
for (var pro in pros) {
print("Storing_Eduactionnsss: ${pro.evaluatorname}");
await box.put(pro.id, pro); // Use `put` with id as key
}
}
retrieveidspeaker(int id) async {
var box = await Hive.openBox<Spe>('speahive');
print('Retrive Doctor}');
var pros = box.get(id);
print('Retrive Doctor Procedure123 ${pros}');
List<Spe> datapro = [];
if (pros != null) {
datapro.add(pros); // Add to the list if not null
}
return datapro;
}