From a8824044b52f2ba8e4f60724a33668d3ca741714 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Thu, 16 Nov 2023 14:16:50 -0800 Subject: [PATCH] cleanup --- pkgs/dart_services/lib/src/sdk.dart | 24 +++++++------------ .../test/flutter_analysis_server_test.dart | 3 ++- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/pkgs/dart_services/lib/src/sdk.dart b/pkgs/dart_services/lib/src/sdk.dart index 493443a22..0f5b9e67d 100644 --- a/pkgs/dart_services/lib/src/sdk.dart +++ b/pkgs/dart_services/lib/src/sdk.dart @@ -7,8 +7,6 @@ import 'dart:io'; import 'package:path/path.dart' as path; -const stableChannel = 'stable'; - class Sdk { /// The path to the Flutter binaries. late final String _flutterBinPath; @@ -76,7 +74,7 @@ class Sdk { flutterVersion = versions['flutterVersion'] as String; engineVersion = versions['engineRevision'] as String; - // Report the 'master' channel to 'main'; + // Report the 'master' channel as 'main'; final tempChannel = versions['channel'] as String; channel = tempChannel == 'master' ? 'main' : tempChannel; } @@ -94,26 +92,22 @@ class Sdk { // analytics disclaimer). try { - final str = Process.runSync( + return jsonDecode(Process.runSync( flutterToolPath, ['--version', '--machine'], workingDirectory: sdkPath, - ).stdout.toString().trim(); - return jsonDecode(str) as Map; + ).stdout.toString().trim()) as Map; } on FormatException { - final str = Process.runSync( + return jsonDecode(Process.runSync( flutterToolPath, ['--version', '--machine'], workingDirectory: sdkPath, - ).stdout.toString().trim(); - return jsonDecode(str) as Map; + ).stdout.toString().trim()) as Map; } } - static String _readVersionFile(String filePath) => - _readFile(path.join(filePath, 'version')); + static String _readVersionFile(String filePath) { + final file = File(path.join(filePath, 'version')); + return file.readAsStringSync().trim(); + } } - -const channels = ['stable', 'beta', 'main']; - -String _readFile(String filePath) => File(filePath).readAsStringSync().trim(); diff --git a/pkgs/dart_services/test/flutter_analysis_server_test.dart b/pkgs/dart_services/test/flutter_analysis_server_test.dart index 59e173b7a..3f503db43 100644 --- a/pkgs/dart_services/test/flutter_analysis_server_test.dart +++ b/pkgs/dart_services/test/flutter_analysis_server_test.dart @@ -13,7 +13,8 @@ import 'package:dart_services/src/sdk.dart'; import 'package:dart_services/src/server_cache.dart'; import 'package:test/test.dart'; -final channel = Platform.environment['FLUTTER_CHANNEL'] ?? stableChannel; +final channel = Platform.environment['FLUTTER_CHANNEL'] ?? 'stable'; + void main() => defineTests(); void defineTests() {