close method
Close the geiger api properly
Implementation
Future<void> close() async {
log('[close] Going to close the GeigerAPIConnector...');
if (pluginApi != null) {
if (storageController != null) {
// Unregister all the listener
if (storageListener != null) {
log('[close] Going to deregister all the change listeners');
try {
await storageController!.deregisterChangeListener(storageListener!);
log('[close] All the change listeners have been removed');
} catch (e, trace) {
log('[close] Failed to deregister the storage listener');
log(e.toString());
if (exceptionHandler != null) {
exceptionHandler!(e, trace);
}
}
}
//close the storage controller
// log('[close] Going to close the storage controller');
// try {
// await storageController!.close();
// log('[close] The storage controller has been closed');
// } catch (e) {
// log('[close] Failed to close the storage controller');
// log(e.toString());
// }
storageController = null;
storageListener = null;
}
log('[close] Going to close the geiger api');
try {
await pluginApi!.zapState();
await pluginApi!.close();
pluginListener = null;
pluginApi = null;
log('[close] The GeigerAPI has been closed');
} catch (e, trace) {
log('[close] Failed to close the GeigerAPI');
log(e.toString());
if (exceptionHandler != null) {
exceptionHandler!(e, trace);
}
}
}
}