Return an empty FlutterViews list when the service disappears (#75301)

This commit is contained in:
Jenn Magder 2021-02-03 11:01:03 -08:00 committed by GitHub
parent 9ae10d0fd2
commit 3f163d29a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -779,7 +779,10 @@ extension FlutterVmService on vm_service.VmService {
kListViewsMethod,
);
if (response == null) {
return null;
// The service may have disappeared mid-request.
// Return an empty list now, and let the shutdown logic elsewhere deal
// with cleaning up.
return <FlutterView>[];
}
final List<Object> rawViews = response.json['views'] as List<Object>;
final List<FlutterView> views = <FlutterView>[

View File

@ -356,7 +356,7 @@ void main() {
expect(skSLs, isNull);
final List<FlutterView> views = await fakeVmServiceHost.vmService.getFlutterViews();
expect(views, isNull);
expect(views, isEmpty);
final vm_service.Response screenshot = await fakeVmServiceHost.vmService.screenshot();
expect(screenshot, isNull);