isPrivilegedPasswordRequired property
bool
get
isPrivilegedPasswordRequired
Returns true if running a privileged action would cause a password to be requested.
Linux/MacOS: will return true if the sudo password is not currently cached and we are not already running as a privileged user.
Windows: This will always return false as Windows is never able to escalate privileges.
Implementation
bool get isPrivilegedPasswordRequired {
if (isPrivilegedUser) {
return false;
}
final response = 'sudo -nv'.toList(nothrow: true);
return response.isNotEmpty &&
response.first == 'sudo: a password is required';
}