[flutter_tools] attempt to fix .first crasher in web loading (#52301)

This commit is contained in:
Jonah Williams 2020-03-10 12:09:37 -07:00 committed by GitHub
parent 2133343a29
commit fdb7bd3c0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -234,6 +234,9 @@ class ChromeLauncher {
final HttpClientRequest request = await client.getUrl(base.resolve('/json/list'));
final HttpClientResponse response = await request.close();
final List<dynamic> jsonObject = await json.fuse(utf8).decoder.bind(response).single as List<dynamic>;
if (jsonObject == null || jsonObject.isEmpty) {
return base;
}
return base.resolve(jsonObject.first['devtoolsFrontendUrl'] as String);
} on Exception {
// If we fail to talk to the remote debugger protocol, give up and return