Control flow collections: flutter_tools/ (#147450)
This pull request aims for improved readability, based on issue #146600. ```dart // before List<SupportedPlatform> getSupportedPlatforms({bool includeRoot = false}) { final List<SupportedPlatform> platforms = includeRoot ? <SupportedPlatform>[SupportedPlatform.root] : <SupportedPlatform>[]; if (android.existsSync()) { platforms.add(SupportedPlatform.android); } if (ios.exists) { platforms.add(SupportedPlatform.ios); } if (web.existsSync()) { platforms.add(SupportedPlatform.web); } if (macos.existsSync()) { platforms.add(SupportedPlatform.macos); } if (linux.existsSync()) { platforms.add(SupportedPlatform.linux); } if (windows.existsSync()) { platforms.add(SupportedPlatform.windows); } if (fuchsia.existsSync()) { platforms.add(SupportedPlatform.fuchsia); } return platforms; } // after List<SupportedPlatform> getSupportedPlatforms({bool includeRoot = false}) { return <SupportedPlatform>[ if (includeRoot) SupportedPlatform.root, if (android.existsSync()) SupportedPlatform.android, if (ios.exists) SupportedPlatform.ios, if (web.existsSync()) SupportedPlatform.web, if (macos.existsSync()) SupportedPlatform.macos, if (linux.existsSync()) SupportedPlatform.linux, if (windows.existsSync()) SupportedPlatform.windows, if (fuchsia.existsSync()) SupportedPlatform.fuchsia, ]; } ```
This commit is contained in:
@@ -836,14 +836,12 @@ class _FakeDeviceManager extends DeviceManager {
|
||||
|
||||
@override
|
||||
Future<List<Device>> getAllDevices({DeviceDiscoveryFilter? filter}) async {
|
||||
final List<Device> devices = <Device>[];
|
||||
for (final FakeDeviceJsonData deviceJson in fakeDevices) {
|
||||
if (filter?.deviceConnectionInterface == null ||
|
||||
deviceJson.dev.connectionInterface == filter?.deviceConnectionInterface) {
|
||||
devices.add(deviceJson.dev);
|
||||
}
|
||||
}
|
||||
return devices;
|
||||
final DeviceConnectionInterface? interface = filter?.deviceConnectionInterface;
|
||||
return <Device>[
|
||||
for (final FakeDeviceJsonData deviceJson in fakeDevices)
|
||||
if (interface == null || deviceJson.dev.connectionInterface == interface)
|
||||
deviceJson.dev,
|
||||
];
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user