listProfiles method

Future<List<String>> listProfiles()

Lists the profile identifiers present in the store.

Throws an AskarStoreException if listing profiles fails.

Implementation

Future<List<String>> listProfiles() async {
  StringListHandle? stringListHandle;

  try {
    stringListHandle = (await askarStoreListProfiles(handle)).getValueOrException();

    final count = askarStringListCount(stringListHandle).getValueOrException();

    List<String> profiles = [];

    for (int i = 0; i < count; i++) {
      final profile = askarStringListGetItem(stringListHandle, i).getValueOrException();
      profiles.add(profile);
    }

    return profiles;
  } catch (e) {
    throw AskarStoreException('Failed to list profiles: $e');
  } finally {
    if (stringListHandle != null) {
      askarStringListFree(stringListHandle);
    }
  }
}