diff --git a/lib/core/application.dart b/lib/core/application.dart index 4ff4116..f936504 100644 --- a/lib/core/application.dart +++ b/lib/core/application.dart @@ -13,7 +13,7 @@ class Application { writeLog = (error, stack) => logError('$error:\n$stack'); func(); }, (error, stack) { - writeLog??(error, stack); + writeLog?.call(error, stack); errorListener(error, stack); }); } diff --git a/lib/platform/process.dart b/lib/platform/process.dart index ee4bc05..4e841e2 100644 --- a/lib/platform/process.dart +++ b/lib/platform/process.dart @@ -161,13 +161,13 @@ class ProcessExecutor { if (Platform.isMacOS || Platform.isWindows) { workspace = workspace ?? Directory.systemTemp.path; if (printStdout_) { - logHandler ?? ('Execute Shell: $arg', LogType.verbose); + logHandler?.call('Execute Shell: $arg', LogType.verbose); } try { processData.process = await Process.start(exe, args, workingDirectory: workspace); } on Exception catch (e) { - logHandler ?? (e, LogType.error); + logHandler?.call(e.toString(), LogType.error); } } else { logHandler ?? ('This platform not support process executor.'); @@ -192,7 +192,7 @@ class ProcessExecutor { var file = File('$workspace/$tempFileName'); processData.file = file; if (printStdout_) { - logHandler ?? + logHandler?.call ( 'Execute Shell: ${file.path} \n ${shell.toString()}', LogType.verbose @@ -208,14 +208,14 @@ class ProcessExecutor { processData.process = await Process.start(shellExe, [file.path], workingDirectory: workspace); } on Exception catch (e) { - logHandler ?? (e, LogType.error); + logHandler?.call(e.toString(), LogType.error); } } else if (Platform.isWindows) { workspace = workspace ?? Directory.systemTemp.path; var file = File('$workspace/$tempFileName'); processData.file = file; if (printStdout_) { - logHandler ?? + logHandler?.call ( 'Execute Shell: ${file.path} \n ${shell.toString()}', LogType.verbose @@ -232,16 +232,16 @@ class ProcessExecutor { processData.process = await Process.start( 'powershell', ['-NoProfile', '-File', file.absolute.path]); } on Exception catch (e) { - logHandler ?? (e, LogType.error); + logHandler?.call(e.toString(), LogType.error); } } else { - logHandler ?? + logHandler?.call ('This platform not support process executor.', LogType.error); } c.complete(processData); await processData.waitForExit(); } on Exception catch (e) { - logHandler ?? + logHandler?.call ('General Exception in ProcessExecutor.start: $e', LogType.error); } return c.future; @@ -257,12 +257,12 @@ class ProcessExecutor { workspace = workspace ?? Directory.systemTemp.path; var file = File('$workspace/$tempFileName'); if (printStdout) { - logHandler ?? + logHandler?.call ( '---------------------------------------------------', LogType.verbose ); - logHandler ?? + logHandler?.call ( 'Shell Path: ${file.path} \nExecute Shell: ${shell.toString()}', LogType.verbose @@ -277,7 +277,7 @@ class ProcessExecutor { processResult = await Process.run(shellExe, [file.path], workingDirectory: workspace); } on Exception catch (e) { - logHandler ?? (e, LogType.error); + logHandler?.call(e.toString(), LogType.error); } finally { file.deleteSync(); } @@ -298,7 +298,7 @@ class ProcessExecutor { file.deleteSync(); c.complete(processResult); } else { - logHandler ?? + logHandler?.call ('This platform not support process executor.', LogType.error); c.complete(null); } @@ -308,7 +308,7 @@ class ProcessExecutor { if (decoder != null) { stdout = decoder.convert(stdout.codeUnits); } - logHandler ?? + logHandler?.call ( // ignore: prefer_interpolation_to_compose_strings '[ProcessExecutor] Result: $stdout', @@ -320,7 +320,7 @@ class ProcessExecutor { if (decoder != null) { stderr = decoder.convert(stderr.codeUnits); } - logHandler ?? + logHandler?.call ( // ignore: prefer_interpolation_to_compose_strings '[ProcessExecutor] Exit Code: ${processResult.exitCode}\nError: $stderr', diff --git a/lib/socket/socket_client.dart b/lib/socket/socket_client.dart index b2b71b4..46fb253 100644 --- a/lib/socket/socket_client.dart +++ b/lib/socket/socket_client.dart @@ -28,11 +28,11 @@ class SocketClient { } catch (e) { print(e); } - resultListener??(connected); + resultListener?.call(connected); // ignore: argument_type_not_assignable_to_error_handler }).catchError((AsyncError e) { print('Unable to connect: $e'); - resultListener??(connected); + resultListener?.call(connected); }); } @@ -52,7 +52,7 @@ class SocketClient { } void disconnect() { - eventDisconnected??(); + eventDisconnected?.call(); _socket!.close(); _socket = null; } @@ -111,6 +111,6 @@ class SocketClient { void _onDone() { print('Disconnected'); - eventDisconnected??(); + eventDisconnected?.call(); } }