Unverified Commit 46c99809 authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Migrate flutter_tools file_system to null safety (#78896)

parent 2415eca4
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:file/file.dart';
import 'package:file/local.dart' as local_fs;
import 'package:meta/meta.dart';
......@@ -31,8 +29,8 @@ class FileNotFoundException implements IOException {
/// Various convenience file system methods.
class FileSystemUtils {
FileSystemUtils({
@required FileSystem fileSystem,
@required Platform platform,
required FileSystem fileSystem,
required Platform platform,
}) : _fileSystem = fileSystem,
_platform = platform;
......@@ -86,8 +84,8 @@ class FileSystemUtils {
///
/// Returns false, if [entity] exists, but [referenceFile] does not.
bool isOlderThanReference({
@required FileSystemEntity entity,
@required File referenceFile,
required FileSystemEntity entity,
required File referenceFile,
}) {
if (!entity.existsSync()) {
return true;
......@@ -97,8 +95,8 @@ class FileSystemUtils {
}
/// Return the absolute path of the user's home directory.
String get homeDirPath {
String path = _platform.isWindows
String? get homeDirPath {
String? path = _platform.isWindows
? _platform.environment['USERPROFILE']
: _platform.environment['HOME'];
if (path != null) {
......@@ -123,8 +121,8 @@ String getDisplayPath(String fullPath, FileSystem fileSystem) {
void copyDirectory(
Directory srcDir,
Directory destDir, {
bool Function(File srcFile, File destFile) shouldCopyFile,
void Function(File srcFile, File destFile) onFileCopied,
bool Function(File srcFile, File destFile)? shouldCopyFile,
void Function(File srcFile, File destFile)? onFileCopied,
}) {
if (!srcDir.existsSync()) {
throw Exception('Source directory "${srcDir.path}" does not exist, nothing to copy');
......@@ -167,13 +165,13 @@ class LocalFileSystem extends local_fs.LocalFileSystem {
@visibleForTesting
LocalFileSystem.test({
@required Signals signals,
required Signals signals,
List<ProcessSignal> fatalSignals = Signals.defaultExitSignals,
}) : this(signals, fatalSignals, null);
Directory _systemTemp;
Directory? _systemTemp;
final Map<ProcessSignal, Object> _signalTokens = <ProcessSignal, Object>{};
final ShutdownHooks _shutdownHooks;
final ShutdownHooks? _shutdownHooks;
Future<void> dispose() async {
_tryToDeleteTemp();
......@@ -189,7 +187,7 @@ class LocalFileSystem extends local_fs.LocalFileSystem {
void _tryToDeleteTemp() {
try {
if (_systemTemp?.existsSync() ?? false) {
_systemTemp.deleteSync(recursive: true);
_systemTemp?.deleteSync(recursive: true);
}
} on FileSystemException {
// ignore.
......@@ -225,6 +223,6 @@ class LocalFileSystem extends local_fs.LocalFileSystem {
_tryToDeleteTemp,
);
}
return _systemTemp;
return _systemTemp!;
}
}
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