delete method

Future<bool> delete(
  1. String key
)

Delete a value from the system keychain.

Implementation

Future<bool> delete(String key) async {
  if (Platform.isMacOS) {
    final result = await Process.run('security', [
      'delete-generic-password',
      '-a',
      key,
      '-s',
      serviceName,
    ]);
    return result.exitCode == 0;
  } else if (Platform.isLinux) {
    final result = await Process.run('secret-tool', [
      'clear',
      'service',
      serviceName,
      'account',
      key,
    ]);
    return result.exitCode == 0;
  }
  throw UnsupportedError('SecureStorage is not supported on this platform');
}