Unverified Commit 59a8ef3a authored by Nate Bosch's avatar Nate Bosch Committed by GitHub

Remove direct uses of LocalPlatform (#56605)

When `const LocalPlatform` is used immediately and not passed as a
dependency it does not have utility over the static properties from
`dart:io`. Remove these uses to reduce the noise around how the
instantiable `Platform` class is used.
parent fab03bd1
...@@ -2,15 +2,13 @@ ...@@ -2,15 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:io';
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
import 'package:platform/platform.dart';
import 'package:yaml/yaml.dart'; import 'package:yaml/yaml.dart';
import 'utils.dart'; import 'utils.dart';
Platform get platform => _platform ??= const LocalPlatform();
Platform _platform;
/// Loads manifest data from `manifest.yaml` file or from [yaml], if present. /// Loads manifest data from `manifest.yaml` file or from [yaml], if present.
Manifest loadTaskManifest([ String yaml ]) { Manifest loadTaskManifest([ String yaml ]) {
final dynamic manifestYaml = yaml == null final dynamic manifestYaml = yaml == null
...@@ -73,7 +71,7 @@ class ManifestTask { ...@@ -73,7 +71,7 @@ class ManifestTask {
(String str) => str.split('/')[0] (String str) => str.split('/')[0]
) )
); );
String hostPlatform = platform.operatingSystem; String hostPlatform = Platform.operatingSystem;
if (hostPlatform == 'macos') { if (hostPlatform == 'macos') {
hostPlatform = 'mac'; // package:platform uses 'macos' while manifest.yaml uses 'mac' hostPlatform = 'mac'; // package:platform uses 'macos' while manifest.yaml uses 'mac'
} }
......
...@@ -2,11 +2,10 @@ ...@@ -2,11 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:io' hide Platform; import 'dart:io';
import 'package:args/args.dart'; import 'package:args/args.dart';
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
import 'package:platform/platform.dart';
import 'configuration.dart'; import 'configuration.dart';
import 'snippets.dart'; import 'snippets.dart';
...@@ -35,8 +34,7 @@ String getChannelName() { ...@@ -35,8 +34,7 @@ String getChannelName() {
/// Generates snippet dartdoc output for a given input, and creates any sample /// Generates snippet dartdoc output for a given input, and creates any sample
/// applications needed by the snippet. /// applications needed by the snippet.
void main(List<String> argList) { void main(List<String> argList) {
const Platform platform = LocalPlatform(); final Map<String, String> environment = Platform.environment;
final Map<String, String> environment = platform.environment;
final ArgParser parser = ArgParser(); final ArgParser parser = ArgParser();
final List<String> snippetTypes = final List<String> snippetTypes =
SnippetType.values.map<String>((SnippetType type) => getEnumName(type)).toList(); SnippetType.values.map<String>((SnippetType type) => getEnumName(type)).toList();
......
...@@ -2,14 +2,13 @@ ...@@ -2,14 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:io' hide Platform; import 'dart:io';
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
import 'package:platform/platform.dart' show LocalPlatform;
/// The location of the Flutter root directory, based on the known location of /// The location of the Flutter root directory, based on the known location of
/// this script. /// this script.
final Directory flutterRoot = Directory(path.dirname(const LocalPlatform().script.toFilePath())).parent.parent.parent.parent; final Directory flutterRoot = Directory(path.dirname(Platform.script.toFilePath())).parent.parent.parent.parent;
/// Converts `FOO_BAR` to `fooBar`. /// Converts `FOO_BAR` to `fooBar`.
String shoutingToLowerCamel(String shouting) { String shoutingToLowerCamel(String shouting) {
......
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'dart:io';
import 'package:file/memory.dart'; import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/terminal.dart'; import 'package:flutter_tools/src/base/terminal.dart';
import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/attach.dart'; import 'package:flutter_tools/src/commands/attach.dart';
...@@ -392,7 +392,7 @@ void main() { ...@@ -392,7 +392,7 @@ void main() {
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FileSystem: () => testFileSystem, FileSystem: () => testFileSystem,
ProcessManager: () => FakeProcessManager.any(), ProcessManager: () => FakeProcessManager.any(),
}, skip: const LocalPlatform().isWindows); // mDNS does not work on Windows. }, skip: Platform.isWindows); // mDNS does not work on Windows.
group('forwarding to given port', () { group('forwarding to given port', () {
const int devicePort = 499; const int devicePort = 499;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment