reset method
Resets the state of the SDK. This is useful for resetting the data without disposing the instance permanently.
This does not close the status stream, and instead sets the SDK back to idle mode.
Implementation
FutureOr<void> reset({bool clearCache = false}) async {
log('Resetting SDK. ${clearCache ? 'Clearing cache.' : 'Keeping cache.'}');
_cacheManager?.reset();
_publishDataManager?.reset();
_previewDataManager?.reset();
_templateDataManager?.reset();
_authManager?.reset();
_status = config == null ? CStatus.empty() : CStatus.configured();
_statusStreamController.add(_status);
if (clearCache) {
try {
await _cacheManager?.clearAll();
} catch (e, str) {
logError(
'Error clearing cache.',
error: e,
stackTrace: str,
);
}
try {
await _cacheManager?.deleteAllByteData();
} catch (e, str) {
logError(
'Error deleting cached bytes.',
error: e,
stackTrace: str,
);
}
}
}