mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
opt.: replace first with firstOrNull
This commit is contained in:
@@ -70,7 +70,7 @@ class Backup {
|
|||||||
|
|
||||||
Backup.loadFromStore()
|
Backup.loadFromStore()
|
||||||
: version = backupFormatVersion,
|
: version = backupFormatVersion,
|
||||||
date = DateTime.now().toString().split('.').first,
|
date = DateTime.now().toString().split('.').firstOrNull ?? '',
|
||||||
spis = Stores.server.fetch(),
|
spis = Stores.server.fetch(),
|
||||||
snippets = Stores.snippet.fetch(),
|
snippets = Stores.snippet.fetch(),
|
||||||
keys = Stores.key.fetch(),
|
keys = Stores.key.fetch(),
|
||||||
|
|||||||
@@ -92,7 +92,8 @@ class OneTimeCpuStatus extends TimeSeqIface<OneTimeCpuStatus> {
|
|||||||
|
|
||||||
for (var item in raw.split('\n')) {
|
for (var item in raw.split('\n')) {
|
||||||
if (item == '') break;
|
if (item == '') break;
|
||||||
final id = item.split(' ').first;
|
final id = item.split(' ').firstOrNull;
|
||||||
|
if (id == null) continue;
|
||||||
final matches = item.replaceFirst(id, '').trim().split(' ');
|
final matches = item.replaceFirst(id, '').trim().split(' ');
|
||||||
cpus.add(
|
cpus.add(
|
||||||
OneTimeCpuStatus(
|
OneTimeCpuStatus(
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class Temperatures {
|
|||||||
return _map[key];
|
return _map[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return _map.values.first;
|
return _map.values.firstOrNull;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ class _PingPageState extends State<PingPage>
|
|||||||
if (result.results == null || result.results!.isEmpty) {
|
if (result.results == null || result.results!.isEmpty) {
|
||||||
return '$ip - ${l10n.noResult}';
|
return '$ip - ${l10n.noResult}';
|
||||||
}
|
}
|
||||||
final ttl = result.results?.first.ttl ?? unknown;
|
final ttl = result.results?.firstOrNull?.ttl ?? unknown;
|
||||||
final loss = result.statistic?.loss ?? unknown;
|
final loss = result.statistic?.loss ?? unknown;
|
||||||
final min = result.statistic?.min ?? unknown;
|
final min = result.statistic?.min ?? unknown;
|
||||||
final max = result.statistic?.max ?? unknown;
|
final max = result.statistic?.max ?? unknown;
|
||||||
|
|||||||
@@ -287,7 +287,8 @@ class _SSHPageState extends State<SSHPage> with AutomaticKeepAliveClientMixin {
|
|||||||
);
|
);
|
||||||
if (snippets == null || snippets.isEmpty) return;
|
if (snippets == null || snippets.isEmpty) return;
|
||||||
|
|
||||||
final snippet = snippets.first;
|
final snippet = snippets.firstOrNull;
|
||||||
|
if (snippet == null) return;
|
||||||
_terminal.textInput(snippet.script);
|
_terminal.textInput(snippet.script);
|
||||||
_terminal.keyInput(TerminalKey.enter);
|
_terminal.keyInput(TerminalKey.enter);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -665,7 +665,7 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
|||||||
/// Issue #97
|
/// Issue #97
|
||||||
/// In order to compatible with the Synology NAS
|
/// In order to compatible with the Synology NAS
|
||||||
/// which not has '.' and '..' in listdir
|
/// which not has '.' and '..' in listdir
|
||||||
if (fs.isNotEmpty && fs.first.filename == '.') {
|
if (fs.isNotEmpty && fs.firstOrNull?.filename == '.') {
|
||||||
fs.removeAt(0);
|
fs.removeAt(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -673,7 +673,7 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
|||||||
/// Due to [WillPopScope] added in this page
|
/// Due to [WillPopScope] added in this page
|
||||||
/// There is no need to keep '..' folder in listdir
|
/// There is no need to keep '..' folder in listdir
|
||||||
/// So remove it
|
/// So remove it
|
||||||
if (fs.isNotEmpty && fs.first.filename == '..') {
|
if (fs.isNotEmpty && fs.firstOrNull?.filename == '..') {
|
||||||
fs.removeAt(0);
|
fs.removeAt(0);
|
||||||
}
|
}
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
|
|||||||
@@ -135,8 +135,8 @@ void _onTapMoreBtns(
|
|||||||
name: (e) => e.name,
|
name: (e) => e.name,
|
||||||
);
|
);
|
||||||
if (snippets == null || snippets.isEmpty) return;
|
if (snippets == null || snippets.isEmpty) return;
|
||||||
final snippet = snippets.first;
|
final snippet = snippets.firstOrNull;
|
||||||
|
if (snippet == null) return;
|
||||||
AppRoute.ssh(spi: spi, initCmd: snippet.fmtWith(spi)).checkGo(
|
AppRoute.ssh(spi: spi, initCmd: snippet.fmtWith(spi)).checkGo(
|
||||||
context: context,
|
context: context,
|
||||||
check: () => _checkClient(context, spi.id),
|
check: () => _checkClient(context, spi.id),
|
||||||
|
|||||||
Reference in New Issue
Block a user