From 0d549ebbb8a6d4a46b1a6293ae4ba12ce23145f0 Mon Sep 17 00:00:00 2001 From: toki Date: Wed, 5 Jul 2023 22:05:05 +0900 Subject: [PATCH] =?UTF-8?q?dart=20fix=20=EB=A1=9C=20=EC=88=98=EC=A0=95?= =?UTF-8?q?=EB=90=9C=20=EC=BD=94=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/main.dart | 2 -- lib/core/app_data_manager.dart | 2 +- lib/platform/process.dart | 14 +++++++------- lib/utils/path.dart | 2 +- lib/utils/slack/slack_data.dart | 1 - lib/utils/slack/slack_sender.dart | 8 ++++---- lib/utils/system_util.dart | 1 - 7 files changed, 13 insertions(+), 17 deletions(-) diff --git a/bin/main.dart b/bin/main.dart index 55006b2..1d0ffc8 100644 --- a/bin/main.dart +++ b/bin/main.dart @@ -1,6 +1,4 @@ -import 'dart:convert'; import 'dart:io'; -import 'package:dart_framework/log/log.dart'; import 'package:dart_framework/subtitle/parser_smi.dart'; import 'package:dart_framework/subtitle/parser_srt.dart'; import 'package:path/path.dart' as path; diff --git a/lib/core/app_data_manager.dart b/lib/core/app_data_manager.dart index ae5b6e5..854be6e 100644 --- a/lib/core/app_data_manager.dart +++ b/lib/core/app_data_manager.dart @@ -93,7 +93,7 @@ class AppDataManager { var shell = StringBuffer(); shell.writeln('git rev-parse HEAD'); var process = - await ProcessExecutor.start(shell, workspace: this._workspace); + await ProcessExecutor.start(shell, workspace: _workspace); await process.process.exitCode; var hash = process.stdoutArr.last; print('#### Git Hash: $hash'); diff --git a/lib/platform/process.dart b/lib/platform/process.dart index 159fc0d..bc2a6b4 100644 --- a/lib/platform/process.dart +++ b/lib/platform/process.dart @@ -65,7 +65,7 @@ class ProcessData { } void checkExit() async { - exitCode = await this.process.exitCode; + exitCode = await process.exitCode; print('#### Exit Code: $exitCode'); deleteFile(); isRunning = false; @@ -248,7 +248,7 @@ class NetStatData { break; case 4: var value = int.tryParse(category); - if (value == null) value = -1; + value ??= -1; pid = value; break; } @@ -289,7 +289,7 @@ Future> findNetStat(String searchWord) async { item = item.replaceAll(returnPattern, ''); if (item.isNotEmpty) { var categories = item.split(' '); - if (categories.length > 0) { + if (categories.isNotEmpty) { netList.add(NetStatData(categories)); } } @@ -406,7 +406,7 @@ class ProcessInfoListener { late ProcessInfo? _process; bool isRunning = false; late Timer? _timer; - late int _checkInterval; + late final int _checkInterval; late Function(ProcessInfoListener, bool)? _connectionListener; set _isRunning(bool value) { if (isRunning != value) { @@ -416,7 +416,7 @@ class ProcessInfoListener { } ProcessInfoListener(this._process, this._checkInterval) { - this.checkLive(); + checkLive(); } void checkLive() async { @@ -429,7 +429,7 @@ class ProcessInfoListener { if (list.isNotEmpty) { print('process live'); enable = true; - this._isRunning = true; + _isRunning = true; } } @@ -474,7 +474,7 @@ class ProcessInfoListener { void terminate() { if (isRunning && _process != null) { - Process.killPid(this._process?.pid as int); + Process.killPid(_process?.pid as int); } } } diff --git a/lib/utils/path.dart b/lib/utils/path.dart index f59beeb..565b9d2 100644 --- a/lib/utils/path.dart +++ b/lib/utils/path.dart @@ -88,7 +88,7 @@ class Path { file.delete(recursive: true); } } - } on Exception catch (e) { + } on Exception { result = false; } c.complete(result); diff --git a/lib/utils/slack/slack_data.dart b/lib/utils/slack/slack_data.dart index 40a6cd2..3a36b35 100644 --- a/lib/utils/slack/slack_data.dart +++ b/lib/utils/slack/slack_data.dart @@ -3,7 +3,6 @@ import 'dart:convert'; import 'dart:io'; import 'package:json_annotation/json_annotation.dart'; -import 'package:dart_framework/utils/system_util.dart'; import 'package:http/http.dart'; // ignore: depend_on_referenced_packages, implementation_imports import 'package:http_parser/src/media_type.dart'; diff --git a/lib/utils/slack/slack_sender.dart b/lib/utils/slack/slack_sender.dart index 86b1f52..03fef5b 100644 --- a/lib/utils/slack/slack_sender.dart +++ b/lib/utils/slack/slack_sender.dart @@ -72,9 +72,9 @@ class SlackSender { if (response.statusCode < 300 && response.statusCode >= 200) { print(response.body); - if (completeListener != null) completeListener!(response.body); + if (completeListener != null) completeListener(response.body); } else { - if (errorListener != null) errorListener!(response); + if (errorListener != null) errorListener(response); } c.complete(); @@ -107,9 +107,9 @@ class SlackSender { var result = await response.stream.bytesToString(); if (response.statusCode < 300 && response.statusCode >= 200) { - if (completeListener != null) completeListener!(result); + if (completeListener != null) completeListener(result); } else { - if (errorListener != null) errorListener!(result); + if (errorListener != null) errorListener(result); } c.complete(); diff --git a/lib/utils/system_util.dart b/lib/utils/system_util.dart index 78b27fc..fd0c737 100644 --- a/lib/utils/system_util.dart +++ b/lib/utils/system_util.dart @@ -3,7 +3,6 @@ import 'dart:convert'; import 'dart:io'; import 'dart:typed_data'; -import 'package:path/path.dart'; import 'package:yaml/yaml.dart'; import 'package:path/path.dart' as path;