withPrivileges method Null safety

void withPrivileges(
  1. RunPrivileged action,
  2. {bool allowUnprivileged = false}
)

Run action with root UID and gid

Implementation

void withPrivileges(RunPrivileged action, {bool allowUnprivileged = false}) {
  if (!allowUnprivileged && !Shell.current.isPrivilegedUser) {
    throw ShellException(
      'You can only use withPrivileges when running as a privileged user.',
    );
  }
  action();
}