Fix deprecations and code style
This commit is contained in:
parent
2956c72939
commit
b1350b825f
|
@ -1,4 +1,5 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
|
|
@ -13,8 +13,8 @@ class DownloaderPage extends StatelessWidget {
|
|||
appBar: AppBar(
|
||||
title: Text(context.t('Downloader')),
|
||||
),
|
||||
body: Column(
|
||||
children: const [
|
||||
body: const Column(
|
||||
children: [
|
||||
Logo(),
|
||||
DownloaderMenu(),
|
||||
],
|
||||
|
|
|
@ -28,8 +28,8 @@ class _MainPageState extends State<MainPage> {
|
|||
title: Text(context.t('Main menu')),
|
||||
),
|
||||
drawer: const LeftMenu(),
|
||||
body: Column(
|
||||
children: const [
|
||||
body: const Column(
|
||||
children: [
|
||||
Logo(),
|
||||
MainMenu(),
|
||||
],
|
||||
|
|
|
@ -138,10 +138,10 @@ class _ManagerState extends State<Manager> with PreferencesMixin {
|
|||
if ((entity.path.endsWith('.conf')) && (_isValidConf(entity.path))) {
|
||||
String name = path.basenameWithoutExtension(entity.path);
|
||||
currentVms.add(name);
|
||||
File pidFile = File(name + '/' + name + '.pid');
|
||||
File pidFile = File('$name/$name.pid');
|
||||
if (pidFile.existsSync()) {
|
||||
String pid = pidFile.readAsStringSync().trim();
|
||||
Directory procDir = Directory('/proc/' + pid);
|
||||
Directory procDir = Directory('/proc/$pid');
|
||||
if (procDir.existsSync()) {
|
||||
if (_activeVms.containsKey(name)) {
|
||||
activeVms[name] = _activeVms[name]!;
|
||||
|
@ -172,11 +172,11 @@ class _ManagerState extends State<Manager> with PreferencesMixin {
|
|||
}
|
||||
|
||||
Widget _buildVmList() {
|
||||
List<Widget> _widgetList = [];
|
||||
List<Widget> widgetList = [];
|
||||
final Color buttonColor = Theme.of(context).brightness == Brightness.dark
|
||||
? Colors.white70
|
||||
: Theme.of(context).colorScheme.primary;
|
||||
_widgetList.addAll(
|
||||
widgetList.addAll(
|
||||
[
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
||||
|
@ -222,12 +222,12 @@ class _ManagerState extends State<Manager> with PreferencesMixin {
|
|||
return _buildRow(vm, buttonColor);
|
||||
}).toList();
|
||||
for (var row in rows) {
|
||||
_widgetList.addAll(row);
|
||||
widgetList.addAll(row);
|
||||
}
|
||||
|
||||
return ListView(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
children: _widgetList,
|
||||
children: widgetList,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -239,10 +239,10 @@ class _ManagerState extends State<Manager> with PreferencesMixin {
|
|||
if (active) {
|
||||
vmInfo = _activeVms[currentVm]!;
|
||||
if (vmInfo.spicePort != null) {
|
||||
connectInfo += context.t('SPICE port') + ': ' + vmInfo.spicePort! + ' ';
|
||||
connectInfo += '${context.t('SPICE port')}: ${vmInfo.spicePort!} ';
|
||||
}
|
||||
if (vmInfo.sshPort != null && _terminalEmulator != null) {
|
||||
connectInfo += context.t('SSH port') + ': ' + vmInfo.sshPort! + ' ';
|
||||
connectInfo += '${context.t('SSH port')}: ${vmInfo.sshPort!} ';
|
||||
_detectSsh(int.parse(vmInfo.sshPort!)).then((sshRunning) {
|
||||
if (sshRunning && !sshy) {
|
||||
setState(() {
|
||||
|
@ -331,12 +331,8 @@ class _ManagerState extends State<Manager> with PreferencesMixin {
|
|||
showDialog<String?>(
|
||||
context: context,
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
title: Text('Delete ' + currentVm),
|
||||
content: Text('You are about to delete ' +
|
||||
currentVm +
|
||||
'. This cannot be undone. ' +
|
||||
'Would you like to delete the disk image but keep the ' +
|
||||
'configuration, or delete the whole VM?'),
|
||||
title: Text('Delete $currentVm'),
|
||||
content: Text('You are about to delete $currentVm. This cannot be undone. Would you like to delete the disk image but keep the configuration, or delete the whole VM?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: const Text('Cancel'),
|
||||
|
@ -390,21 +386,22 @@ class _ManagerState extends State<Manager> with PreferencesMixin {
|
|||
IconButton(
|
||||
icon: SvgPicture.asset('assets/images/console.svg',
|
||||
semanticsLabel: 'Connect with SSH',
|
||||
color: sshy ? buttonColor : Colors.grey),
|
||||
colorFilter: ColorFilter.mode(sshy ? buttonColor : Colors.grey, BlendMode.srcIn)
|
||||
),
|
||||
tooltip: sshy
|
||||
? 'Connect with SSH'
|
||||
: 'SSH server not detected on guest',
|
||||
onPressed: !sshy
|
||||
? null
|
||||
: () {
|
||||
TextEditingController _usernameController =
|
||||
TextEditingController usernameController =
|
||||
TextEditingController();
|
||||
showDialog<bool>(
|
||||
context: context,
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
title: Text('Launch SSH connection to $currentVm'),
|
||||
content: TextField(
|
||||
controller: _usernameController,
|
||||
controller: usernameController,
|
||||
decoration: const InputDecoration(
|
||||
hintText: "SSH username"),
|
||||
),
|
||||
|
@ -426,7 +423,7 @@ class _ManagerState extends State<Manager> with PreferencesMixin {
|
|||
'ssh',
|
||||
'-p',
|
||||
vmInfo.sshPort!,
|
||||
_usernameController.text + '@localhost'
|
||||
'${usernameController.text}@localhost'
|
||||
];
|
||||
// Set the arguments to execute the ssh command in the default terminal.
|
||||
// Strip the extension as x-terminal-emulator may point to a .wrapper
|
||||
|
|
|
@ -72,12 +72,12 @@ class _DownloaderMenuState extends State<DownloaderMenu> with PreferencesMixin {
|
|||
const Divider(
|
||||
thickness: 2,
|
||||
),
|
||||
Row(
|
||||
const Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: const [
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 12),
|
||||
child: HomePageButtonGroup(),
|
||||
|
|
|
@ -105,8 +105,8 @@ class _HomePageButtonGroupState extends State<HomePageButtonGroup> {
|
|||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => WillPopScope(
|
||||
onWillPop: () async => false,
|
||||
builder: (context) => PopScope(
|
||||
canPop: false,
|
||||
child: AlertDialog(
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(8.0)),
|
||||
|
@ -153,8 +153,8 @@ class _HomePageButtonGroupState extends State<HomePageButtonGroup> {
|
|||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => WillPopScope(
|
||||
onWillPop: () async => false,
|
||||
builder: (context) => PopScope(
|
||||
canPop: false,
|
||||
child: AlertDialog(
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(8.0)),
|
||||
|
|
Loading…
Reference in New Issue