Unverified Commit 1371b8dc authored by Christopher Fujino's avatar Christopher Fujino Committed by GitHub

[flutter_tools] Fix null check errors in attach command (#107864)

parent 8dfad230
...@@ -215,7 +215,11 @@ known, it can be explicitly provided to attach via the command-line, e.g. ...@@ -215,7 +215,11 @@ known, it can be explicitly provided to attach via the command-line, e.g.
Future<FlutterCommandResult> runCommand() async { Future<FlutterCommandResult> runCommand() async {
await _validateArguments(); await _validateArguments();
final Device device = await (findTargetDevice() as FutureOr<Device>); final Device? device = await findTargetDevice();
if (device == null) {
throwToolExit('Did not find any valid target devices.');
}
final Artifacts? overrideArtifacts = device.artifactOverrides ?? globals.artifacts; final Artifacts? overrideArtifacts = device.artifactOverrides ?? globals.artifacts;
await context.run<void>( await context.run<void>(
...@@ -272,7 +276,7 @@ known, it can be explicitly provided to attach via the command-line, e.g. ...@@ -272,7 +276,7 @@ known, it can be explicitly provided to attach via the command-line, e.g.
} else if ((device is IOSDevice) || (device is IOSSimulator) || (device is MacOSDesignedForIPadDevice)) { } else if ((device is IOSDevice) || (device is IOSSimulator) || (device is MacOSDesignedForIPadDevice)) {
final Uri? uriFromMdns = final Uri? uriFromMdns =
await MDnsObservatoryDiscovery.instance!.getObservatoryUri( await MDnsObservatoryDiscovery.instance!.getObservatoryUri(
appId!, appId,
device, device,
usesIpv6: usesIpv6, usesIpv6: usesIpv6,
deviceVmservicePort: deviceVmservicePort, deviceVmservicePort: deviceVmservicePort,
...@@ -317,12 +321,12 @@ known, it can be explicitly provided to attach via the command-line, e.g. ...@@ -317,12 +321,12 @@ known, it can be explicitly provided to attach via the command-line, e.g.
try { try {
int? result; int? result;
if (daemon != null) { if (daemon != null) {
final ResidentRunner runner = await (createResidentRunner( final ResidentRunner runner = await createResidentRunner(
observatoryUris: observatoryUri, observatoryUris: observatoryUri,
device: device, device: device,
flutterProject: flutterProject, flutterProject: flutterProject,
usesIpv6: usesIpv6, usesIpv6: usesIpv6,
) as FutureOr<ResidentRunner>); );
late AppInstance app; late AppInstance app;
try { try {
app = await daemon.appDomain.launch( app = await daemon.appDomain.launch(
...@@ -351,12 +355,12 @@ known, it can be explicitly provided to attach via the command-line, e.g. ...@@ -351,12 +355,12 @@ known, it can be explicitly provided to attach via the command-line, e.g.
return; return;
} }
while (true) { while (true) {
final ResidentRunner runner = await (createResidentRunner( final ResidentRunner runner = await createResidentRunner(
observatoryUris: observatoryUri, observatoryUris: observatoryUri,
device: device, device: device,
flutterProject: flutterProject, flutterProject: flutterProject,
usesIpv6: usesIpv6, usesIpv6: usesIpv6,
) as FutureOr<ResidentRunner>); );
final Completer<void> onAppStart = Completer<void>.sync(); final Completer<void> onAppStart = Completer<void>.sync();
TerminalHandler? terminalHandler; TerminalHandler? terminalHandler;
unawaited(onAppStart.future.whenComplete(() { unawaited(onAppStart.future.whenComplete(() {
...@@ -400,7 +404,7 @@ known, it can be explicitly provided to attach via the command-line, e.g. ...@@ -400,7 +404,7 @@ known, it can be explicitly provided to attach via the command-line, e.g.
} }
} }
Future<ResidentRunner?> createResidentRunner({ Future<ResidentRunner> createResidentRunner({
required Stream<Uri> observatoryUris, required Stream<Uri> observatoryUris,
required Device device, required Device device,
required FlutterProject flutterProject, required FlutterProject flutterProject,
...@@ -452,7 +456,7 @@ known, it can be explicitly provided to attach via the command-line, e.g. ...@@ -452,7 +456,7 @@ known, it can be explicitly provided to attach via the command-line, e.g.
} }
class HotRunnerFactory { class HotRunnerFactory {
HotRunner? build( HotRunner build(
List<FlutterDevice> devices, { List<FlutterDevice> devices, {
required String target, required String target,
required DebuggingOptions debuggingOptions, required DebuggingOptions debuggingOptions,
......
...@@ -145,7 +145,7 @@ class MDnsObservatoryDiscovery { ...@@ -145,7 +145,7 @@ class MDnsObservatoryDiscovery {
} }
} }
Future<Uri?> getObservatoryUri(String applicationId, Device device, { Future<Uri?> getObservatoryUri(String? applicationId, Device device, {
bool usesIpv6 = false, bool usesIpv6 = false,
int? hostVmservicePort, int? hostVmservicePort,
int? deviceVmservicePort, int? deviceVmservicePort,
......
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