Reland "if chains → switch expressions" (#148634)
I did a goof a while back:

Now that [the bug is fixed](e9d403541f), I think we're good to re-implement the if-chains cleanup!
Related:
- https://github.com/flutter/flutter/pull/147793
- https://github.com/flutter/flutter/pull/148556
- https://github.com/flutter/flutter/issues/148548
This commit is contained in:
@@ -103,21 +103,16 @@ bool _findBGR10Color(
|
||||
return foundDeepRed;
|
||||
}
|
||||
|
||||
bool _findColor(List<Object?> result, List<double> color) {
|
||||
bool _findColor(List<dynamic> result, List<double> color) {
|
||||
expect(result, isNotNull);
|
||||
expect(result.length, 4);
|
||||
final int width = (result[0] as int?)!;
|
||||
final int height = (result[1] as int?)!;
|
||||
final String format = (result[2] as String?)!;
|
||||
if (format == 'MTLPixelFormatBGR10_XR') {
|
||||
return _findBGR10Color((result[3] as Uint8List?)!, width, height, color);
|
||||
} else if (format == 'MTLPixelFormatBGRA10_XR') {
|
||||
return _findBGRA10Color((result[3] as Uint8List?)!, width, height, color);
|
||||
} else if (format == 'MTLPixelFormatRGBA16Float') {
|
||||
return _findRGBAF16Color((result[3] as Uint8List?)!, width, height, color);
|
||||
} else {
|
||||
fail('Unsupported pixel format: $format');
|
||||
}
|
||||
final [int width, int height, String format, Uint8List bytes] = result;
|
||||
return switch (format) {
|
||||
'MTLPixelFormatBGR10_XR' => _findBGR10Color(bytes, width, height, color),
|
||||
'MTLPixelFormatBGRA10_XR' => _findBGRA10Color(bytes, width, height, color),
|
||||
'MTLPixelFormatRGBA16Float' => _findRGBAF16Color(bytes, width, height, color),
|
||||
_ => fail('Unsupported pixel format: $format'),
|
||||
};
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
||||
Reference in New Issue
Block a user