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

43 lines
1.2 KiB
Dart
Raw Normal View History

2024-10-07 12:41:28 +00:00
// import 'package:discover_module/storage_hive/speaker_data/speaker_model_hive.dart';
import 'package:discover_module/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;
}