migrate some file to null safety (#92957)

This commit is contained in:
嘟囔 2021-12-17 03:39:12 +08:00 committed by GitHub
parent a8c780972d
commit 4f5cc21be2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 15 additions and 31 deletions

View File

@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
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 '../src/common.dart'; import '../src/common.dart';
@ -12,12 +10,12 @@ import 'test_utils.dart';
final String analyzerSeparator = platform.isWindows ? '-' : ''; final String analyzerSeparator = platform.isWindows ? '-' : '';
void main() { void main() {
Directory tempDir; late Directory tempDir;
String projectPath; late String projectPath;
File libMain; late File libMain;
Future<void> runCommand({ Future<void> runCommand({
List<String> arguments, List<String> arguments = const <String>[],
List<String> statusTextContains = const <String>[], List<String> statusTextContains = const <String>[],
List<String> errorTextContains = const <String>[], List<String> errorTextContains = const <String>[],
String exitMessageContains = '', String exitMessageContains = '',

View File

@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import 'package:file/file.dart'; import 'package:file/file.dart';
import 'package:file_testing/file_testing.dart'; import 'package:file_testing/file_testing.dart';
import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/base/io.dart';

View File

@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import 'package:file_testing/file_testing.dart'; import 'package:file_testing/file_testing.dart';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
@ -11,7 +9,7 @@ import '../src/common.dart';
import 'test_utils.dart'; import 'test_utils.dart';
void main() { void main() {
Directory tempDir; late Directory tempDir;
setUp(() async { setUp(() async {
tempDir = createResolvedTempDirectorySync('flutter_plugin_test.'); tempDir = createResolvedTempDirectorySync('flutter_plugin_test.');

View File

@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import 'dart:async'; import 'dart:async';
import 'package:file/file.dart'; import 'package:file/file.dart';
@ -14,7 +12,7 @@ import 'test_driver.dart';
import 'test_utils.dart'; import 'test_utils.dart';
void main() { void main() {
Directory tempDir; late Directory tempDir;
setUp(() async { setUp(() async {
tempDir = createResolvedTempDirectorySync('hot_reload_test.'); tempDir = createResolvedTempDirectorySync('hot_reload_test.');
@ -56,7 +54,7 @@ void main() {
// Wait a tiny amount of time in case we did not kill the background isolate. // Wait a tiny amount of time in case we did not kill the background isolate.
await Future<void>.delayed(const Duration(milliseconds: 10)); await Future<void>.delayed(const Duration(milliseconds: 10));
await subscription.cancel(); await subscription.cancel();
await flutter?.stop(); await flutter.stop();
}); });
testWithoutContext('Hot reload updates background isolates', () async { testWithoutContext('Hot reload updates background isolates', () async {
@ -84,6 +82,6 @@ void main() {
await flutter.hotReload(); await flutter.hotReload();
await sawNewBackgroundMessage.future; await sawNewBackgroundMessage.future;
await subscription.cancel(); await subscription.cancel();
await flutter?.stop(); await flutter.stop();
}); });
} }

View File

@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import 'package:file_testing/file_testing.dart'; import 'package:file_testing/file_testing.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';

View File

@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import 'dart:convert'; import 'dart:convert';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
@ -138,11 +136,11 @@ void main() {
'--machine', '--machine',
]); ]);
final Map<String, Object> versionInfo = json.decode(result.stdout final Map<String, Object?> versionInfo = json.decode(result.stdout
.toString() .toString()
.replaceAll('Building flutter tool...', '') .replaceAll('Building flutter tool...', '')
.replaceAll('Waiting for another flutter command to release the startup lock...', '') .replaceAll('Waiting for another flutter command to release the startup lock...', '')
.trim()) as Map<String, Object>; .trim()) as Map<String, Object?>;
expect(versionInfo, containsPair('flutterRoot', isNotNull)); expect(versionInfo, containsPair('flutterRoot', isNotNull));
}); });

View File

@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import 'package:file/file.dart'; import 'package:file/file.dart';
import 'package:file_testing/file_testing.dart'; import 'package:file_testing/file_testing.dart';
@ -14,7 +12,7 @@ import 'test_driver.dart';
import 'test_utils.dart'; import 'test_utils.dart';
void main() { void main() {
Directory tempDir; late Directory tempDir;
setUp(() async { setUp(() async {
tempDir = createResolvedTempDirectorySync('flutter_coverage_collection_test.'); tempDir = createResolvedTempDirectorySync('flutter_coverage_collection_test.');

View File

@ -2,8 +2,6 @@
// 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.
// @dart = 2.8
import 'package:file/file.dart'; import 'package:file/file.dart';
import '../src/common.dart'; import '../src/common.dart';
@ -12,7 +10,7 @@ import 'test_driver.dart';
import 'test_utils.dart'; import 'test_utils.dart';
void main() { void main() {
Directory tempDir; late Directory tempDir;
setUp(() async { setUp(() async {
tempDir = createResolvedTempDirectorySync('debugger_stepping_test.'); tempDir = createResolvedTempDirectorySync('debugger_stepping_test.');
@ -32,13 +30,13 @@ void main() {
await _flutter.addBreakpoint(_project.breakpointUri, _project.breakpointLine); await _flutter.addBreakpoint(_project.breakpointUri, _project.breakpointLine);
await _flutter.resume(waitForNextPause: true); // Now we should be on the breakpoint. await _flutter.resume(waitForNextPause: true); // Now we should be on the breakpoint.
expect((await _flutter.getSourceLocation()).line, equals(_project.breakpointLine)); expect((await _flutter.getSourceLocation())?.line, equals(_project.breakpointLine));
// Issue 5 steps, ensuring that we end up on the annotated lines each time. // Issue 5 steps, ensuring that we end up on the annotated lines each time.
for (int i = 1; i <= _project.numberOfSteps; i += 1) { for (int i = 1; i <= _project.numberOfSteps; i += 1) {
await _flutter.stepOverOrOverAsyncSuspension(); await _flutter.stepOverOrOverAsyncSuspension();
final SourcePosition location = await _flutter.getSourceLocation(); final SourcePosition? location = await _flutter.getSourceLocation();
final int actualLine = location.line; final int? actualLine = location?.line;
// Get the line we're expected to stop at by searching for the comment // Get the line we're expected to stop at by searching for the comment
// within the source code. // within the source code.