clearData static method

Future<void> clearData({
  1. required String baseUrl,
  2. required String inboxIdentifier,
  3. String? userIdentifier,
})

Clears all persisted chatwoot data on device for a particular chatwoot client instance. See getClientInstanceKey on how chatwoot client instance are differentiated

Implementation

static Future<void> clearData(
    {required String baseUrl,
    required String inboxIdentifier,
    String? userIdentifier}) async {
  final clientInstanceKey = getClientInstanceKey(
      baseUrl: baseUrl,
      inboxIdentifier: inboxIdentifier,
      userIdentifier: userIdentifier);
  providerContainerMap.putIfAbsent(
      clientInstanceKey, () => ProviderContainer());
  final container = providerContainerMap[clientInstanceKey]!;
  final params = ChatwootParameters(
      isPersistenceEnabled: true,
      baseUrl: "",
      inboxIdentifier: "",
      clientInstanceKey: "");

  final localStorage = container.read(localStorageProvider(params));
  await localStorage.clear();

  localStorage.dispose();
  container.dispose();
  providerContainerMap.remove(clientInstanceKey);
}