22// Use of this source code is governed by a BSD-style license that can be
33// found in the LICENSE file.
44
5- // @dart = 2.8
6-
75import 'dart:async' ;
86
97import 'package:flutter_tools/src/android/android_workflow.dart' ;
@@ -36,6 +34,7 @@ import 'package:flutter_tools/src/reporting/crash_reporting.dart';
3634import 'package:flutter_tools/src/reporting/reporting.dart' ;
3735import 'package:flutter_tools/src/version.dart' ;
3836import 'package:meta/meta.dart' ;
37+ import 'package:test/fake.dart' ;
3938
4039import 'common.dart' ;
4140import 'fake_http_client.dart' ;
@@ -48,18 +47,18 @@ export 'package:flutter_tools/src/base/context.dart' show Generator;
4847export 'fake_process_manager.dart' show ProcessManager, FakeProcessManager, FakeCommand;
4948
5049/// Return the test logger. This assumes that the current Logger is a BufferLogger.
51- BufferLogger get testLogger => context.get <Logger >() as BufferLogger ;
50+ BufferLogger get testLogger => context.get <Logger >()! as BufferLogger ;
5251
53- FakeDeviceManager get testDeviceManager => context.get <DeviceManager >() as FakeDeviceManager ;
52+ FakeDeviceManager get testDeviceManager => context.get <DeviceManager >()! as FakeDeviceManager ;
5453
5554@isTest
5655void testUsingContext (
5756 String description,
5857 dynamic Function () testMethod, {
5958 Map <Type , Generator > overrides = const < Type , Generator > {},
6059 bool initializeFlutterRoot = true ,
61- String testOn,
62- bool skip, // should default to `false`, but https://github.com/dart-lang/test/issues/545 doesn't allow this
60+ String ? testOn,
61+ bool ? skip, // should default to `false`, but https://github.com/dart-lang/test/issues/545 doesn't allow this
6362}) {
6463 if (overrides[FileSystem ] != null && overrides[ProcessManager ] == null ) {
6564 throw StateError (
@@ -74,10 +73,10 @@ void testUsingContext(
7473
7574 // Ensure we don't rely on the default [Config] constructor which will
7675 // leak a sticky $HOME/.flutter_settings behind!
77- Directory configDir;
76+ Directory ? configDir;
7877 tearDown (() {
7978 if (configDir != null ) {
80- tryToDelete (configDir);
79+ tryToDelete (configDir! );
8180 configDir = null ;
8281 }
8382 });
@@ -92,7 +91,7 @@ void testUsingContext(
9291 PersistentToolState buildPersistentToolState (FileSystem fs) {
9392 configDir ?? = globals.fs.systemTempDirectory.createTempSync ('flutter_config_dir_test.' );
9493 return PersistentToolState .test (
95- directory: configDir,
94+ directory: configDir! ,
9695 logger: globals.logger,
9796 );
9897 }
@@ -172,7 +171,7 @@ void testUsingContext(
172171
173172void _printBufferedErrors (AppContext testContext) {
174173 if (testContext.get <Logger >() is BufferLogger ) {
175- final BufferLogger bufferLogger = testContext.get <Logger >() as BufferLogger ;
174+ final BufferLogger bufferLogger = testContext.get <Logger >()! as BufferLogger ;
176175 if (bufferLogger.errorText.isNotEmpty) {
177176 // This is where the logger outputting errors is implemented, so it has
178177 // to use `print`.
@@ -185,18 +184,18 @@ void _printBufferedErrors(AppContext testContext) {
185184class FakeDeviceManager implements DeviceManager {
186185 List <Device > devices = < Device > [];
187186
188- String _specifiedDeviceId;
187+ String ? _specifiedDeviceId;
189188
190189 @override
191- String get specifiedDeviceId {
190+ String ? get specifiedDeviceId {
192191 if (_specifiedDeviceId == null || _specifiedDeviceId == 'all' ) {
193192 return null ;
194193 }
195194 return _specifiedDeviceId;
196195 }
197196
198197 @override
199- set specifiedDeviceId (String id) {
198+ set specifiedDeviceId (String ? id) {
200199 _specifiedDeviceId = id;
201200 }
202201
@@ -212,7 +211,7 @@ class FakeDeviceManager implements DeviceManager {
212211 Future <List <Device >> getAllConnectedDevices () async => devices;
213212
214213 @override
215- Future <List <Device >> refreshAllConnectedDevices ({ Duration timeout }) async => devices;
214+ Future <List <Device >> refreshAllConnectedDevices ({ Duration ? timeout }) async => devices;
216215
217216 @override
218217 Future <List <Device >> getDevicesById (String deviceId) async {
@@ -222,7 +221,7 @@ class FakeDeviceManager implements DeviceManager {
222221 @override
223222 Future <List <Device >> getDevices () {
224223 return hasSpecifiedDeviceId
225- ? getDevicesById (specifiedDeviceId)
224+ ? getDevicesById (specifiedDeviceId! )
226225 : getAllConnectedDevices ();
227226 }
228227
@@ -238,17 +237,17 @@ class FakeDeviceManager implements DeviceManager {
238237 List <DeviceDiscovery > get deviceDiscoverers => < DeviceDiscovery > [];
239238
240239 @override
241- bool isDeviceSupportedForProject (Device device, FlutterProject flutterProject) {
242- return device.isSupportedForProject (flutterProject);
240+ bool isDeviceSupportedForProject (Device device, FlutterProject ? flutterProject) {
241+ return device.isSupportedForProject (flutterProject! );
243242 }
244243
245244 @override
246- Future <List <Device >> findTargetDevices (FlutterProject flutterProject, { Duration timeout }) async {
245+ Future <List <Device >> findTargetDevices (FlutterProject ? flutterProject, { Duration ? timeout }) async {
247246 return devices;
248247 }
249248}
250249
251- class FakeAndroidLicenseValidator extends AndroidLicenseValidator {
250+ class FakeAndroidLicenseValidator extends Fake implements AndroidLicenseValidator {
252251 @override
253252 Future <LicensesAccepted > get licensesAccepted async => LicensesAccepted .all;
254253}
@@ -302,7 +301,7 @@ class FakeXcodeProjectInterpreter implements XcodeProjectInterpreter {
302301 @override
303302 Future <Map <String , String >> getBuildSettings (
304303 String projectPath, {
305- XcodeProjectBuildContext buildContext,
304+ XcodeProjectBuildContext ? buildContext,
306305 Duration timeout = const Duration (minutes: 1 ),
307306 }) async {
308307 return < String , String > {};
@@ -313,14 +312,14 @@ class FakeXcodeProjectInterpreter implements XcodeProjectInterpreter {
313312 Directory podXcodeProject, {
314313 Duration timeout = const Duration (minutes: 1 ),
315314 }) async {
316- return null ;
315+ return '' ;
317316 }
318317
319318 @override
320319 Future <void > cleanWorkspace (String workspacePath, String scheme, { bool verbose = false }) async { }
321320
322321 @override
323- Future <XcodeProjectInfo > getInfo (String projectPath, {String projectFilename}) async {
322+ Future <XcodeProjectInfo > getInfo (String projectPath, {String ? projectFilename}) async {
324323 return XcodeProjectInfo (
325324 < String > ['Runner' ],
326325 < String > ['Debug' , 'Release' ],
@@ -358,7 +357,7 @@ class LocalFileSystemBlockingSetCurrentDirectory extends LocalFileSystem {
358357class FakeSignals implements Signals {
359358 @override
360359 Object addHandler (ProcessSignal signal, SignalHandler handler) {
361- return null ;
360+ return Object () ;
362361 }
363362
364363 @override
0 commit comments