我的电脑上有一个 Ubuntu 22.04,还有一个啪的一声使用 Flutter 创建的 Linux 应用程序。我的 Flutter 应用程序中还有一个用于重新启动操作系统的按钮。
我尝试了两种不同的方法:
方法一:
await Process.run("reboot", []);
信息:
flutter: Running in chroot, ignoring request.
方法 2:
await Process.run('sudo', ['reboot']);
信息:
flutter: >>> /etc/sudoers: syntax error near line 54 <<<
sudo: parse error in /etc/sudoers near line 54
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin
这也是我的“snapcarft.yaml”文件内容:
name: panel-gyro-compass
version: 1.0.0
summary: panel gyro compass
description: panel gyro compass
confinement: strict
base: core18
grade: stable
slots:
dbus-panel-gyro-compass: # adjust accordingly to your app name
interface: dbus
bus: session
name: org.bar.panel_gyro_compass # adjust accordingly to your app name and
apps:
panel-gyro-compass:
command: panel_gyro_compass
extensions: [flutter-master] # Where "master" defines which Flutter channel to use for the build
plugs: [network, serial-port]
slots: [dbus-panel-gyro-compass]
parts:
panel-gyro-compass:
source: .
plugin: flutter
flutter-target: lib/main.dart # The main entry-point file of the application
请告诉我如何在 Flutter 中运行命令来重新启动 PC。