Add spaces after flow control statements (#126320)

This commit is contained in:
Tomasz Gucio 2023-05-15 11:07:30 +02:00 committed by GitHub
parent 231e00d26b
commit 99c7e9f088
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
116 changed files with 264 additions and 174 deletions

View File

@ -68,7 +68,7 @@ class ResampleFlagVariant extends TestVariant<TestScenario> {
late TestScenario currentValue;
bool get resample {
switch(currentValue) {
switch (currentValue) {
case TestScenario.resampleOn90Hz:
case TestScenario.resampleOn59Hz:
return true;
@ -78,7 +78,7 @@ class ResampleFlagVariant extends TestVariant<TestScenario> {
}
}
double get frequency {
switch(currentValue) {
switch (currentValue) {
case TestScenario.resampleOn90Hz:
case TestScenario.resampleOff90Hz:
return 90.0;
@ -92,7 +92,7 @@ class ResampleFlagVariant extends TestVariant<TestScenario> {
@override
String describeValue(TestScenario value) {
switch(value) {
switch (value) {
case TestScenario.resampleOn90Hz:
return 'resample on with 90Hz input';
case TestScenario.resampleOn59Hz:

View File

@ -13,7 +13,7 @@ Future<void> main() => driver.integrationDriver(
final Map<String, dynamic> fullyLiveResult =
data?['fullyLive'] as Map<String,dynamic>;
if(benchmarkLiveResult['frame_count'] as int < 10
if (benchmarkLiveResult['frame_count'] as int < 10
|| fullyLiveResult['frame_count'] as int < 10) {
print('Failure Details:\nNot Enough frames collected: '
'benchmarkLive ${benchmarkLiveResult['frameCount']}, '

View File

@ -112,6 +112,9 @@ Future<void> run(List<String> arguments) async {
printProgress('Trailing spaces...');
await verifyNoTrailingSpaces(flutterRoot); // assumes no unexpected binaries, so should be after verifyNoBinaries
printProgress('Spaces after flow control statements...');
await verifySpacesAfterFlowControlStatements(flutterRoot);
printProgress('Deprecations...');
await verifyDeprecations(flutterRoot);
@ -1040,6 +1043,38 @@ Future<void> verifyNoTrailingSpaces(String workingDirectory, { int minimumMatche
}
}
final RegExp _flowControlStatementWithoutSpace = RegExp(r'(^|[ \t])(if|switch|for|do|while|catch)\(', multiLine: true);
Future<void> verifySpacesAfterFlowControlStatements(String workingDirectory, { int minimumMatches = 4000 }) async {
const Set<String> extensions = <String>{
'.dart',
'.java',
'.js',
'.kt',
'.swift',
'.c',
'.cc',
'.cpp',
'.h',
'.m',
};
final List<File> files = await _allFiles(workingDirectory, null, minimumMatches: minimumMatches)
.where((File file) => extensions.contains(path.extension(file.path)))
.toList();
final List<String> problems = <String>[];
for (final File file in files) {
final List<String> lines = file.readAsLinesSync();
for (int index = 0; index < lines.length; index += 1) {
if (lines[index].contains(_flowControlStatementWithoutSpace)) {
problems.add('${file.path}:${index + 1}: no space after flow control statement');
}
}
}
if (problems.isNotEmpty) {
foundError(problems);
}
}
String _bullets(String value) => ' * $value';
Future<void> verifyIssueLinks(String workingDirectory) async {

View File

@ -0,0 +1,37 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// ignore_for_file: type=lint
bool isThereMeaningOfLife = true;
void main() {
if (isThereMeaningOfLife) {}
if(isThereMeaningOfLife) {}
//^
switch (isThereMeaningOfLife) {
case false:
case true:
}
switch(isThereMeaningOfLife) {
// ^
case false:
case true:
}
for (int index = 0; index < 10; index++) {}
for(int index = 0; index < 10; index++) {}
// ^
while (isThereMeaningOfLife) {}
while(isThereMeaningOfLife) {}
// ^
try {
} catch (e) {}
try {
} catch(e) {}
// ^
}

View File

@ -124,6 +124,24 @@ void main() {
);
});
test('analyze.dart - verifySpacesAfterFlowControlStatements', () async {
final String result = await capture(() => verifySpacesAfterFlowControlStatements(testRootPath, minimumMatches: 2), shouldHaveErrors: true);
final String lines = <String>[
'║ test/analyze-test-input/root/packages/foo/spaces_after_flow.dart:11: no space after flow control statement',
'║ test/analyze-test-input/root/packages/foo/spaces_after_flow.dart:18: no space after flow control statement',
'║ test/analyze-test-input/root/packages/foo/spaces_after_flow.dart:25: no space after flow control statement',
'║ test/analyze-test-input/root/packages/foo/spaces_after_flow.dart:29: no space after flow control statement',
'║ test/analyze-test-input/root/packages/foo/spaces_after_flow.dart:35: no space after flow control statement',
]
.map((String line) => line.replaceAll('/', Platform.isWindows ? r'\' : '/'))
.join('\n');
expect(result,
'╔═╡ERROR╞═══════════════════════════════════════════════════════════════════════\n'
'$lines\n'
'╚═══════════════════════════════════════════════════════════════════════════════\n'
);
});
test('analyze.dart - verifyNoBinaries - positive', () async {
final String result = await capture(() => verifyNoBinaries(
testRootPath,

View File

@ -44,7 +44,7 @@ Future<void> main(List<String> rawArgs) async {
test = ABTest.fromJsonMap(
const JsonDecoder().convert(await file.readAsString()) as Map<String, dynamic>
);
} catch(error) {
} catch (error) {
_usage('Could not parse json file "$filename"');
return;
}

View File

@ -36,7 +36,7 @@ String getArtifactPath() {
String? _findMatchId(List<String> idList, String idPattern) {
String? candidate;
idPattern = idPattern.toLowerCase();
for(final String id in idList) {
for (final String id in idList) {
if (id.toLowerCase() == idPattern) {
return id;
}

View File

@ -252,7 +252,7 @@ public class $pluginClass: NSObject, FlutterPlugin {
// build files.
await build(buildTarget, validateNativeBuildProject: false);
switch(buildTarget) {
switch (buildTarget) {
case 'apk':
if (await exec(
path.join('.', 'gradlew'),

View File

@ -47,7 +47,7 @@ public class MainActivity extends FlutterActivity implements MethodChannel.Metho
@Override
public void onMethodCall(MethodCall methodCall, MethodChannel.Result result) {
switch(methodCall.method) {
switch (methodCall.method) {
case "pipeFlutterViewEvents":
result.success(null);
return;

View File

@ -49,7 +49,7 @@ public class SimplePlatformView implements PlatformView, MethodChannel.MethodCal
@Override
public void onMethodCall(MethodCall methodCall, MethodChannel.Result result) {
switch(methodCall.method) {
switch (methodCall.method) {
case "pipeTouchEvents":
touchPipe.enable();
result.success(null);

View File

@ -31,7 +31,7 @@ class TouchPipe implements View.OnTouchListener {
}
public void disable() {
if(!mEnabled)
if (!mEnabled)
return;
mEnabled = false;
mView.setOnTouchListener(null);

View File

@ -162,7 +162,7 @@ class MotionEventsBodyState extends State<MotionEventsBody> {
diff.write(currentDiff);
}
return diff.toString();
} catch(e) {
} catch (e) {
return e.toString();
}
}

View File

@ -111,7 +111,7 @@ class WindowManagerBodyState extends State<WindowManagerBody> {
setState(() {
_lastTestStatus = _LastTestStatus.success;
});
} catch(e) {
} catch (e) {
setState(() {
_lastTestStatus = _LastTestStatus.error;
lastError = '$e';
@ -125,7 +125,7 @@ class WindowManagerBodyState extends State<WindowManagerBody> {
setState(() {
windowClickCount++;
});
} catch(e) {
} catch (e) {
setState(() {
_lastTestStatus = _LastTestStatus.error;
lastError = '$e';

View File

@ -224,7 +224,7 @@ class _LeaveBehindListItem extends StatelessWidget {
}
},
confirmDismiss: !confirmDismiss ? null : (DismissDirection dismissDirection) async {
switch(dismissDirection) {
switch (dismissDirection) {
case DismissDirection.endToStart:
return await _showConfirmationDialog(context, 'archive') ?? false;
case DismissDirection.startToEnd:

View File

@ -72,7 +72,7 @@ class ScrollableTabsDemoState extends State<ScrollableTabsDemo> with SingleTicke
return const UnderlineTabIndicator();
}
switch(_demoStyle) {
switch (_demoStyle) {
case TabsDemoStyle.iconsAndText:
return ShapeDecoration(
shape: const RoundedRectangleBorder(

View File

@ -26,7 +26,7 @@ Set<String> _unTestedDemos = Set<String>.from(_allDemos);
class _MessageHandler {
static LiveWidgetController? controller;
Future<String> call(String message) async {
switch(message) {
switch (message) {
case 'demoNames':
return const JsonEncoder.withIndent(' ').convert(_allDemos);
case 'profileDemos':

View File

@ -110,7 +110,7 @@ public class MainActivity extends FlutterActivity implements MethodChannel.Metho
@Override
public void onMethodCall(MethodCall methodCall, MethodChannel.Result result) {
switch(methodCall.method) {
switch (methodCall.method) {
case "getStoragePermission":
if (permissionResult != null) {
result.error("error", "already waiting for permissions", null);

View File

@ -50,7 +50,7 @@ public class SimplePlatformView implements PlatformView, MethodChannel.MethodCal
@Override
public void onMethodCall(MethodCall methodCall, MethodChannel.Result result) {
switch(methodCall.method) {
switch (methodCall.method) {
case "pipeTouchEvents":
touchPipe.enable();
result.success(null);

View File

@ -31,7 +31,7 @@ class TouchPipe implements View.OnTouchListener {
}
public void disable() {
if(!mEnabled)
if (!mEnabled)
return;
mEnabled = false;
mView.setOnTouchListener(null);

View File

@ -144,7 +144,7 @@ class MotionEventsBodyState extends State<MotionEventsBody> {
diff.write(currentDiff);
}
return diff.toString();
} catch(e) {
} catch (e) {
return e.toString();
}
}

View File

@ -145,7 +145,7 @@ class NestedViewEventBodyState extends State<NestedViewEventBody> {
setState(() {
_lastTestStatus = _LastTestStatus.success;
});
} catch(e) {
} catch (e) {
setState(() {
_lastTestStatus = _LastTestStatus.error;
lastError = '$e';
@ -165,7 +165,7 @@ class NestedViewEventBodyState extends State<NestedViewEventBody> {
setState(() {
nestedViewClickCount++;
});
} catch(e) {
} catch (e) {
setState(() {
_lastTestStatus = _LastTestStatus.error;
lastError = '$e';

View File

@ -91,7 +91,7 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme {
if (states.contains(MaterialState.disabled)) {
return ${componentColor('md.comp.filled-text-field.disabled.leading-icon')};
}
if(states.contains(MaterialState.error)) {
if (states.contains(MaterialState.error)) {
if (states.contains(MaterialState.hovered)) {
return ${componentColor('md.comp.filled-text-field.error.hover.leading-icon')};
}
@ -114,7 +114,7 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme {
if (states.contains(MaterialState.disabled)) {
return ${componentColor('md.comp.filled-text-field.disabled.trailing-icon')};
}
if(states.contains(MaterialState.error)) {${componentColor('md.comp.filled-text-field.error.trailing-icon') == componentColor('md.comp.filled-text-field.error.focus.trailing-icon') ? '' : '''
if (states.contains(MaterialState.error)) {${componentColor('md.comp.filled-text-field.error.trailing-icon') == componentColor('md.comp.filled-text-field.error.focus.trailing-icon') ? '' : '''
if (states.contains(MaterialState.hovered)) {
return ${componentColor('md.comp.filled-text-field.error.hover.trailing-icon')};
}
@ -138,7 +138,7 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme {
if (states.contains(MaterialState.disabled)) {
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.disabled.label-text')});
}
if(states.contains(MaterialState.error)) {
if (states.contains(MaterialState.error)) {
if (states.contains(MaterialState.hovered)) {
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.error.hover.label-text')});
}
@ -162,7 +162,7 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme {
if (states.contains(MaterialState.disabled)) {
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.disabled.label-text')});
}
if(states.contains(MaterialState.error)) {
if (states.contains(MaterialState.error)) {
if (states.contains(MaterialState.hovered)) {
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.error.hover.label-text')});
}

View File

@ -2078,7 +2078,7 @@ class _CupertinoTimerPickerState extends State<CupertinoTimerPicker> {
double maxWidth = double.negativeInfinity;
for (int i = 0; i < labels.length; i++) {
final String? label = labels[i];
if(label == null) {
if (label == null) {
continue;
}

View File

@ -236,7 +236,7 @@ class _CupertinoRadioState<T> extends State<CupertinoRadio<T>> with TickerProvid
final bool? accessibilitySelected;
// Apple devices also use `selected` to annotate radio button's semantics
// state.
switch(defaultTargetPlatform) {
switch (defaultTargetPlatform) {
case TargetPlatform.android:
case TargetPlatform.fuchsia:
case TargetPlatform.linux:

View File

@ -212,7 +212,7 @@ class _CupertinoScrollbarState extends RawScrollbarState<CupertinoScrollbar> {
}
_thicknessAnimationController.reverse();
super.handleThumbPressEnd(localPosition, velocity);
switch(direction) {
switch (direction) {
case Axis.vertical:
if (velocity.pixelsPerSecond.dy.abs() < 10 &&
(localPosition.dy - _pressStartAxisPosition).abs() > 0) {

View File

@ -577,7 +577,7 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox {
bool get isFocused => _isFocused;
bool _isFocused;
set isFocused(bool value) {
if(value == _isFocused) {
if (value == _isFocused) {
return;
}
_isFocused = value;
@ -637,7 +637,7 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox {
final RRect trackRRect = RRect.fromRectAndRadius(trackRect, const Radius.circular(_kTrackRadius));
canvas.drawRRect(trackRRect, paint);
if(_isFocused) {
if (_isFocused) {
// Paints a border around the switch in the focus color.
final RRect borderTrackRRect = trackRRect.inflate(1.75);

View File

@ -443,7 +443,7 @@ mixin class ChangeNotifier implements Listenable {
if (_listeners[i] == null) {
// We swap this item with the next not null item.
int swapIndex = i + 1;
while(_listeners[swapIndex] == null) {
while (_listeners[swapIndex] == null) {
swapIndex += 1;
}
_listeners[i] = _listeners[swapIndex];

View File

@ -451,7 +451,7 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
@override
void didStopTrackingLastPointer(int pointer) {
assert(_state != _DragState.ready);
switch(_state) {
switch (_state) {
case _DragState.ready:
break;

View File

@ -324,7 +324,7 @@ class _BottomSheetState extends State<BottomSheet> {
void _handleDragHandleHover(bool hovering) {
if (hovering != dragHandleMaterialState.contains(MaterialState.hovered)) {
setState(() {
if(hovering){
if (hovering){
dragHandleMaterialState.add(MaterialState.hovered);
}
else{
@ -360,7 +360,7 @@ class _BottomSheetState extends State<BottomSheet> {
// Only add [GestureDetector] to the drag handle when the rest of the
// bottom sheet is not draggable. If the whole bottom sheet is draggable,
// no need to add it.
if(!widget.enableDrag) {
if (!widget.enableDrag) {
dragHandle = GestureDetector(
onVerticalDragStart: _handleDragStart,
onVerticalDragUpdate: _handleDragUpdate,

View File

@ -930,7 +930,7 @@ class _AdaptiveAlertDialog extends AlertDialog {
@override
Widget build(BuildContext context) {
final ThemeData theme = Theme.of(context);
switch(theme.platform) {
switch (theme.platform) {
case TargetPlatform.android:
case TargetPlatform.fuchsia:
case TargetPlatform.linux:

View File

@ -502,7 +502,7 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro
_scrimColorTween = _buildScrimColorTween();
}
if (widget.isDrawerOpen != oldWidget.isDrawerOpen) {
switch(_controller.status) {
switch (_controller.status) {
case AnimationStatus.completed:
case AnimationStatus.dismissed:
_controller.value = widget.isDrawerOpen ? 1.0 : 0.0;

View File

@ -152,7 +152,7 @@ class _ExpandIconState extends State<ExpandIcon> with SingleTickerProviderStateM
return widget.color!;
}
switch(Theme.of(context).brightness) {
switch (Theme.of(context).brightness) {
case Brightness.light:
return Colors.black54;
case Brightness.dark:

View File

@ -556,7 +556,7 @@ class FloatingActionButton extends StatelessWidget {
data: IconThemeData(size: iconSize),
child: child!,
) : child;
switch(_floatingActionButtonType) {
switch (_floatingActionButtonType) {
case _FloatingActionButtonType.regular:
sizeConstraints = floatingActionButtonTheme.sizeConstraints ?? defaults.sizeConstraints!;
case _FloatingActionButtonType.small:

View File

@ -4617,7 +4617,7 @@ class _InputDecoratorDefaultsM3 extends InputDecorationTheme {
if (states.contains(MaterialState.disabled)) {
return _colors.onSurface.withOpacity(0.38);
}
if(states.contains(MaterialState.error)) {
if (states.contains(MaterialState.error)) {
return _colors.error;
}
return _colors.onSurfaceVariant;
@ -4629,7 +4629,7 @@ class _InputDecoratorDefaultsM3 extends InputDecorationTheme {
if (states.contains(MaterialState.disabled)) {
return textStyle.copyWith(color: _colors.onSurface.withOpacity(0.38));
}
if(states.contains(MaterialState.error)) {
if (states.contains(MaterialState.error)) {
if (states.contains(MaterialState.hovered)) {
return textStyle.copyWith(color: _colors.onErrorContainer);
}
@ -4653,7 +4653,7 @@ class _InputDecoratorDefaultsM3 extends InputDecorationTheme {
if (states.contains(MaterialState.disabled)) {
return textStyle.copyWith(color: _colors.onSurface.withOpacity(0.38));
}
if(states.contains(MaterialState.error)) {
if (states.contains(MaterialState.error)) {
if (states.contains(MaterialState.hovered)) {
return textStyle.copyWith(color: _colors.onErrorContainer);
}

View File

@ -502,7 +502,7 @@ class _RadioState<T> extends State<Radio<T>> with TickerProviderStateMixin, Togg
final bool? accessibilitySelected;
// Apple devices also use `selected` to annotate radio button's semantics
// state.
switch(defaultTargetPlatform) {
switch (defaultTargetPlatform) {
case TargetPlatform.android:
case TargetPlatform.fuchsia:
case TargetPlatform.linux:

View File

@ -596,7 +596,7 @@ class RefreshIndicatorState extends State<RefreshIndicator> with TickerProviderS
color: widget.color,
);
switch(widget._indicatorType) {
switch (widget._indicatorType) {
case _IndicatorType.material:
return materialIndicator;

View File

@ -538,7 +538,7 @@ class _SearchPageState<T> extends State<_SearchPage<T>> {
final String searchFieldLabel = widget.delegate.searchFieldLabel
?? MaterialLocalizations.of(context).searchFieldLabel;
Widget? body;
switch(widget.delegate._currentBody) {
switch (widget.delegate._currentBody) {
case _SearchBody.suggestions:
body = KeyedSubtree(
key: const ValueKey<_SearchBody>(_SearchBody.suggestions),

View File

@ -1058,7 +1058,7 @@ class _TextFieldState extends State<TextField> with RestorationMixin implements
_effectiveFocusNode.canRequestFocus = _canRequestFocus;
if (_effectiveFocusNode.hasFocus && widget.readOnly != oldWidget.readOnly && _isEnabled) {
if(_effectiveController.selection.isCollapsed) {
if (_effectiveController.selection.isCollapsed) {
_showSelectionHandles = !widget.readOnly;
}
}

View File

@ -2291,7 +2291,7 @@ class _TimePickerDialogState extends State<TimePickerDialog> with RestorationMix
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
final TimeOfDayFormat timeOfDayFormat = localizations.timeOfDayFormat(alwaysUse24HourFormat: MediaQuery.alwaysUse24HourFormatOf(context));
final double timePickerWidth;
switch(timeOfDayFormat) {
switch (timeOfDayFormat) {
case TimeOfDayFormat.HH_colon_mm:
case TimeOfDayFormat.HH_dot_mm:
case TimeOfDayFormat.frenchCanadian:
@ -2331,7 +2331,7 @@ class _TimePickerDialogState extends State<TimePickerDialog> with RestorationMix
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
final TimeOfDayFormat timeOfDayFormat = localizations.timeOfDayFormat(alwaysUse24HourFormat: MediaQuery.alwaysUse24HourFormatOf(context));
final double timePickerWidth;
switch(timeOfDayFormat) {
switch (timeOfDayFormat) {
case TimeOfDayFormat.HH_colon_mm:
case TimeOfDayFormat.HH_dot_mm:
case TimeOfDayFormat.frenchCanadian:

View File

@ -254,7 +254,7 @@ abstract class BoxBorder extends ShapeBorder {
required BorderSide bottom,
}) {
final RRect borderRect;
switch(shape) {
switch (shape) {
case BoxShape.rectangle:
borderRect = (borderRadius ?? BorderRadius.zero)
.resolve(textDirection)
@ -605,7 +605,7 @@ class Border extends BoxBorder {
// Allow painting non-uniform borders if the color and style are uniform.
if (_colorIsUniform && _styleIsUniform) {
switch(top.style) {
switch (top.style) {
case BorderStyle.none:
return;
case BorderStyle.solid:
@ -964,7 +964,7 @@ class BorderDirectional extends BoxBorder {
// Allow painting non-uniform borders if the color and style are uniform.
if (_colorIsUniform && _styleIsUniform) {
switch(top.style) {
switch (top.style) {
case BorderStyle.none:
return;
case BorderStyle.solid:

View File

@ -1199,7 +1199,7 @@ class TextPainter {
// TODO(LongCatIsLooong): make this case impossible; see https://github.com/flutter/flutter/issues/79495
return null;
}
return switch(_computeCaretMetrics(position)) {
return switch (_computeCaretMetrics(position)) {
_LineCaretMetrics(:final double fullHeight) => fullHeight,
_EmptyLineCaretMetrics() => null,
};

View File

@ -1322,7 +1322,7 @@ class ContainerLayer extends Layer {
}
final List<Layer> children = <Layer>[];
Layer? child = firstChild;
while(child != null) {
while (child != null) {
children.add(child);
if (child is ContainerLayer) {
children.addAll(child.depthFirstIterateChildren());

View File

@ -1524,7 +1524,7 @@ class _SelectableFragment with Selectable, ChangeNotifier implements TextLayoutM
SelectionResult _handleDirectionallyExtendSelection(double horizontalBaseline, bool isExtent, SelectionExtendDirection movement) {
final Matrix4 transform = paragraph.getTransformTo(null);
if (transform.invert() == 0.0) {
switch(movement) {
switch (movement) {
case SelectionExtendDirection.previousLine:
case SelectionExtendDirection.backward:
return SelectionResult.previous;
@ -1537,7 +1537,7 @@ class _SelectableFragment with Selectable, ChangeNotifier implements TextLayoutM
assert(!baselineInParagraphCoordinates.isNaN);
final TextPosition newPosition;
final SelectionResult result;
switch(movement) {
switch (movement) {
case SelectionExtendDirection.previousLine:
case SelectionExtendDirection.nextLine:
assert(_textSelectionEnd != null && _textSelectionStart != null);

View File

@ -153,7 +153,7 @@ abstract class RenderSliverFixedExtentBoxAdaptor extends RenderSliverMultiBoxAda
int _calculateLeadingGarbage(int firstIndex) {
RenderBox? walker = firstChild;
int leadingGarbage = 0;
while(walker != null && indexOf(walker) < firstIndex) {
while (walker != null && indexOf(walker) < firstIndex) {
leadingGarbage += 1;
walker = childAfter(walker);
}
@ -163,7 +163,7 @@ abstract class RenderSliverFixedExtentBoxAdaptor extends RenderSliverMultiBoxAda
int _calculateTrailingGarbage(int targetLastIndex) {
RenderBox? walker = lastChild;
int trailingGarbage = 0;
while(walker != null && indexOf(walker) > targetLastIndex) {
while (walker != null && indexOf(walker) > targetLastIndex) {
trailingGarbage += 1;
walker = childBefore(walker);
}

View File

@ -151,7 +151,7 @@ class RenderSliverCrossAxisGroup extends RenderSliver with ContainerRenderObject
}
bool _assertOutOfExtent(double extent) {
if(extent <= 0.0) {
if (extent <= 0.0) {
throw FlutterError.fromParts(<DiagnosticsNode>[
ErrorSummary('SliverCrossAxisGroup ran out of extent before child could be laid out.'),
ErrorDescription(

View File

@ -250,7 +250,7 @@ class TableBorder {
}
}
}
if(!isUniform || borderRadius == BorderRadius.zero) {
if (!isUniform || borderRadius == BorderRadius.zero) {
paintBorder(canvas, rect, top: top, right: right, bottom: bottom, left: left);
} else {
final RRect outer = borderRadius.toRRect(rect);

View File

@ -72,7 +72,7 @@ class PlatformViewsService {
static final PlatformViewsService _instance = PlatformViewsService._();
Future<void> _onMethodCall(MethodCall call) {
switch(call.method) {
switch (call.method) {
case 'viewFocused':
final int id = call.arguments as int;
if (_focusCallbacks.containsKey(id)) {

View File

@ -1137,7 +1137,7 @@ abstract class _SliverAnimatedMultiBoxAdaptorState<T extends _SliverAnimatedMult
/// This method's semantics are the same as Dart's [List.clear] method: it
/// removes all the items in the list.
void removeAllItems(AnimatedRemovedItemBuilder builder, { Duration duration = _kDuration }) {
for(int i = _itemsCount - 1 ; i >= 0; i--) {
for (int i = _itemsCount - 1 ; i >= 0; i--) {
removeItem(i, builder, duration: duration);
}
}

View File

@ -439,7 +439,7 @@ class _DismissibleState extends State<Dismissible> with TickerProviderStateMixin
}
void _handleDismissUpdateValueChanged() {
if(widget.onUpdate != null) {
if (widget.onUpdate != null) {
final bool oldDismissThresholdReached = _dismissThresholdReached;
_dismissThresholdReached = _moveController!.value > (widget.dismissThresholds[_dismissDirection] ?? _kDismissThreshold);
final DismissUpdateDetails details = DismissUpdateDetails(

View File

@ -2896,7 +2896,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
_floatingCursorResetController ??= AnimationController(
vsync: this,
)..addListener(_onFloatingCursorResetTick);
switch(point.state) {
switch (point.state) {
case FloatingCursorDragState.Start:
if (_floatingCursorResetController!.isAnimating) {
_floatingCursorResetController!.stop();

View File

@ -250,7 +250,7 @@ class FormState extends State<Form> {
errorMessage += field.errorText ?? '';
}
if(errorMessage.isNotEmpty) {
if (errorMessage.isNotEmpty) {
final TextDirection directionality = Directionality.of(context);
if (defaultTargetPlatform == TargetPlatform.iOS) {
unawaited(Future<void>(() async {

View File

@ -1117,7 +1117,7 @@ class _ImageState extends State<Image> with WidgetsBindingObserver {
ImageStreamListener? _imageStreamListener;
ImageStreamListener _getListener({bool recreateListener = false}) {
if(_imageStreamListener == null || recreateListener) {
if (_imageStreamListener == null || recreateListener) {
_lastException = null;
_lastStack = null;
_imageStreamListener = ImageStreamListener(

View File

@ -958,10 +958,10 @@ class _AnimatedAlignState extends AnimatedWidgetBaseState<AnimatedAlign> {
@override
void forEachTween(TweenVisitor<dynamic> visitor) {
_alignment = visitor(_alignment, widget.alignment, (dynamic value) => AlignmentGeometryTween(begin: value as AlignmentGeometry)) as AlignmentGeometryTween?;
if(widget.heightFactor != null) {
if (widget.heightFactor != null) {
_heightFactorTween = visitor(_heightFactorTween, widget.heightFactor, (dynamic value) => Tween<double>(begin: value as double)) as Tween<double>?;
}
if(widget.widthFactor != null) {
if (widget.widthFactor != null) {
_widthFactorTween = visitor(_widthFactorTween, widget.widthFactor, (dynamic value) => Tween<double>(begin: value as double)) as Tween<double>?;
}
}
@ -2171,10 +2171,10 @@ class _AnimatedFractionallySizedBoxState extends AnimatedWidgetBaseState<Animate
@override
void forEachTween(TweenVisitor<dynamic> visitor) {
_alignment = visitor(_alignment, widget.alignment, (dynamic value) => AlignmentGeometryTween(begin: value as AlignmentGeometry)) as AlignmentGeometryTween?;
if(widget.heightFactor != null) {
if (widget.heightFactor != null) {
_heightFactorTween = visitor(_heightFactorTween, widget.heightFactor, (dynamic value) => Tween<double>(begin: value as double)) as Tween<double>?;
}
if(widget.widthFactor != null) {
if (widget.widthFactor != null) {
_widthFactorTween = visitor(_widthFactorTween, widget.widthFactor, (dynamic value) => Tween<double>(begin: value as double)) as Tween<double>?;
}
}

View File

@ -608,7 +608,7 @@ class _InteractiveViewerState extends State<InteractiveViewer> with TickerProvid
late final Offset alignedTranslation;
if (_currentAxis != null) {
switch(widget.panAxis){
switch (widget.panAxis){
case PanAxis.horizontal:
alignedTranslation = _alignAxis(translation, Axis.horizontal);
case PanAxis.vertical:

View File

@ -70,7 +70,7 @@ class _RenderSemanticsClipper extends RenderProxyBox {
if (_clipDetailsNotifier == newNotifier) {
return;
}
if(attached) {
if (attached) {
_clipDetailsNotifier.removeListener(markNeedsSemanticsUpdate);
}
_clipDetailsNotifier = newNotifier;

View File

@ -3722,7 +3722,7 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res
// We found the page for all the consecutive pageless routes below. Attach these
// pageless routes to the page.
if(unattachedPagelessRoutes.isNotEmpty) {
if (unattachedPagelessRoutes.isNotEmpty) {
pageRouteToPagelessRoutes.putIfAbsent(
oldEntry,
() => List<_RouteEntry>.from(unattachedPagelessRoutes),
@ -4113,7 +4113,7 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res
}
int _getIndexBefore(int index, _RouteEntryPredicate predicate) {
while(index >= 0 && !predicate(_history[index])) {
while (index >= 0 && !predicate(_history[index])) {
index -= 1;
}
return index;
@ -5013,7 +5013,7 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res
/// {@end-tool}
void popUntil(RoutePredicate predicate) {
_RouteEntry? candidate = _lastRouteEntryWhereOrNull(_RouteEntry.isPresentPredicate);
while(candidate != null) {
while (candidate != null) {
if (predicate(candidate.route)) {
return;
}

View File

@ -303,7 +303,7 @@ class _OverlayEntryWidgetState extends State<_OverlayEntryWidget> {
return;
}
_OverlayEntryLocation? candidate = reversed ? children.last : children.first;
while(candidate != null) {
while (candidate != null) {
final RenderBox? renderBox = candidate._overlayChildRenderBox;
candidate = reversed ? candidate.previous : candidate.next;
if (renderBox != null) {
@ -912,7 +912,7 @@ class _RenderTheater extends RenderBox with ContainerRenderObjectMixin<RenderBox
final _TheaterParentData childParentData = child.parentData! as _TheaterParentData;
final Iterator<RenderBox>? iterator = childParentData.paintOrderIterator;
if (iterator != null) {
while(iterator.moveNext()) {
while (iterator.moveNext()) {
iterator.current.attach(owner);
}
}

View File

@ -404,7 +404,7 @@ class ScrollDragController implements Drag {
// substantially lower than the carried momentum.
final bool isVelocityNotSubstantiallyLessThanCarriedMomentum =
velocity.abs() > carriedVelocity!.abs() * momentumRetainVelocityThresholdFactor;
if(isFlingingInSameDirection && isVelocityNotSubstantiallyLessThanCarriedMomentum) {
if (isFlingingInSameDirection && isVelocityNotSubstantiallyLessThanCarriedMomentum) {
velocity += carriedVelocity!;
}
}

View File

@ -261,7 +261,7 @@ class ScrollbarPainter extends ChangeNotifier implements CustomPainter {
OutlinedBorder? _shape;
set shape(OutlinedBorder? value){
assert(radius == null || value == null);
if(shape == value) {
if (shape == value) {
return;
}
@ -384,7 +384,7 @@ class ScrollbarPainter extends ChangeNotifier implements CustomPainter {
// The track is offset by only padding.
double get _totalTrackMainAxisOffsets => _isVertical ? padding.vertical : padding.horizontal;
double get _leadingTrackMainAxisOffset {
switch(_resolvedOrientation) {
switch (_resolvedOrientation) {
case ScrollbarOrientation.left:
case ScrollbarOrientation.right:
return padding.top;
@ -402,7 +402,7 @@ class ScrollbarPainter extends ChangeNotifier implements CustomPainter {
// Thumb Offsets
// The thumb is offset by padding and margins.
double get _leadingThumbMainAxisOffset {
switch(_resolvedOrientation) {
switch (_resolvedOrientation) {
case ScrollbarOrientation.left:
case ScrollbarOrientation.right:
return padding.top + mainAxisMargin;
@ -558,7 +558,7 @@ class ScrollbarPainter extends ChangeNotifier implements CustomPainter {
final Size thumbSize, trackSize;
final Offset trackOffset, borderStart, borderEnd;
_debugAssertIsValidOrientation(_resolvedOrientation);
switch(_resolvedOrientation) {
switch (_resolvedOrientation) {
case ScrollbarOrientation.left:
thumbSize = Size(thickness, _thumbExtent);
trackSize = Size(thickness + 2 * crossAxisMargin, _trackExtent);
@ -1711,7 +1711,7 @@ class RawScrollbarState<T extends RawScrollbar> extends State<T> with TickerProv
// The physics may allow overscroll when actually *scrolling*, but
// dragging on the scrollbar does not always allow us to enter overscroll.
switch(ScrollConfiguration.of(context).getPlatform(context)) {
switch (ScrollConfiguration.of(context).getPlatform(context)) {
case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.macOS:
@ -2133,7 +2133,7 @@ class RawScrollbarState<T extends RawScrollbar> extends State<T> with TickerProv
gestures: _gestures,
child: MouseRegion(
onExit: (PointerExitEvent event) {
switch(event.kind) {
switch (event.kind) {
case PointerDeviceKind.mouse:
case PointerDeviceKind.trackpad:
if (enableGestures) {
@ -2147,7 +2147,7 @@ class RawScrollbarState<T extends RawScrollbar> extends State<T> with TickerProv
}
},
onHover: (PointerHoverEvent event) {
switch(event.kind) {
switch (event.kind) {
case PointerDeviceKind.mouse:
case PointerDeviceKind.trackpad:
if (enableGestures) {

View File

@ -399,7 +399,7 @@ class SelectableRegionState extends State<SelectableRegion> with TextSelectionDe
void _updateSelectionStatus() {
final TextSelection selection;
final SelectionGeometry geometry = _selectionDelegate.value;
switch(geometry.status) {
switch (geometry.status) {
case SelectionStatus.uncollapsed:
case SelectionStatus.collapsed:
selection = const TextSelection(baseOffset: 0, extentOffset: 1);
@ -1961,7 +1961,7 @@ abstract class MultiSelectableSelectionContainerDelegate extends SelectionContai
SelectionResult handleDirectionallyExtendSelection(DirectionallyExtendSelectionEvent event) {
assert((currentSelectionStartIndex == -1) == (currentSelectionEndIndex == -1));
if (currentSelectionStartIndex == -1) {
switch(event.direction) {
switch (event.direction) {
case SelectionExtendDirection.previousLine:
case SelectionExtendDirection.backward:
currentSelectionStartIndex = currentSelectionEndIndex = selectables.length;

View File

@ -1178,7 +1178,7 @@ class SelectionOverlay {
if (!listEquals(_selectionEndpoints, value)) {
markNeedsBuild();
if (_isDraggingEndHandle || _isDraggingStartHandle) {
switch(defaultTargetPlatform) {
switch (defaultTargetPlatform) {
case TargetPlatform.android:
HapticFeedback.selectionClick();
case TargetPlatform.fuchsia:

View File

@ -193,7 +193,7 @@ class UndoHistoryState<T> extends State<UndoHistory<T>> with UndoManagerClient {
@override
void handlePlatformUndo(UndoDirection direction) {
switch(direction) {
switch (direction) {
case UndoDirection.undo:
undo();
case UndoDirection.redo:

View File

@ -1417,7 +1417,7 @@ mixin WidgetInspectorService {
pubRootDirectories = pubRootDirectories.map<String>((String directory) => Uri.parse(directory).path).toList();
final Set<String> directorySet = Set<String>.from(pubRootDirectories);
if(_pubRootDirectories != null) {
if (_pubRootDirectories != null) {
directorySet.addAll(_pubRootDirectories!);
}

View File

@ -445,7 +445,7 @@ void main() {
const ScrollableDetails details = ScrollableDetails(direction: AxisDirection.down);
final Widget child = Container();
switch(defaultTargetPlatform) {
switch (defaultTargetPlatform) {
case TargetPlatform.android:
case TargetPlatform.fuchsia:
case TargetPlatform.iOS:

View File

@ -80,7 +80,7 @@ class PathBoundsMatcher extends Matcher {
final List<dynamic> values = <dynamic> [bounds, bounds.top, bounds.left, bounds.right, bounds.bottom];
final Map<Matcher, dynamic> failedMatcher = <Matcher, dynamic> {};
for(int idx = 0; idx < matchers.length; idx++) {
for (int idx = 0; idx < matchers.length; idx++) {
if (!(matchers[idx]?.matches(values[idx], matchState) ?? true)) {
failedMatcher[matchers[idx]!] = values[idx];
}

View File

@ -1476,7 +1476,7 @@ void main() {
);
final Widget child = Container();
switch(defaultTargetPlatform) {
switch (defaultTargetPlatform) {
case TargetPlatform.android:
case TargetPlatform.fuchsia:
case TargetPlatform.iOS:
@ -1522,7 +1522,7 @@ void main() {
);
final Widget child = Container();
switch(defaultTargetPlatform) {
switch (defaultTargetPlatform) {
case TargetPlatform.android:
case TargetPlatform.fuchsia:
case TargetPlatform.iOS:

View File

@ -198,7 +198,7 @@ void main() {
await tester.pumpAndSettle();
final String? expectedLabel;
switch(defaultTargetPlatform) {
switch (defaultTargetPlatform) {
case TargetPlatform.android:
expectedLabel = 'Back';
case TargetPlatform.fuchsia:
@ -241,7 +241,7 @@ void main() {
await tester.pumpAndSettle();
final String? expectedLabel;
switch(defaultTargetPlatform) {
switch (defaultTargetPlatform) {
case TargetPlatform.android:
expectedLabel = 'Close';
case TargetPlatform.fuchsia:

View File

@ -2206,7 +2206,7 @@ void main() {
return const AlertDialog(title: Text('Title'));
},
);
} catch(exception) {
} catch (exception) {
error = exception;
}

View File

@ -157,7 +157,7 @@ TextStyle? getIconStyle(WidgetTester tester, IconData icon) {
}
void main() {
for(final bool useMaterial3 in <bool>[true, false]){
for (final bool useMaterial3 in <bool>[true, false]){
testWidgets('InputDecorator input/label text layout', (WidgetTester tester) async {
// The label appears above the input text
await tester.pumpWidget(
@ -380,7 +380,7 @@ void main() {
);
await tester.pumpAndSettle();
expect(tester.getSize(find.byType(InputDecorator)), const Size(800.0, 56.0));
if(!useMaterial3) {
if (!useMaterial3) {
expect(tester.getTopLeft(find.text('label')).dy, tester.getTopLeft(find.text('hint')).dy);
expect(tester.getBottomLeft(find.text('label')).dy, tester.getBottomLeft(find.text('hint')).dy);
}
@ -723,7 +723,7 @@ void main() {
);
await tester.pumpAndSettle();
expect(tester.getSize(find.byType(InputDecorator)), const Size(800.0, 56.0));
if(!useMaterial3) {
if (!useMaterial3) {
expect(tester.getTopLeft(find.byKey(key)).dy, tester.getTopLeft(find.text('hint')).dy);
expect(tester.getBottomLeft(find.byKey(key)).dy, tester.getBottomLeft(find.text('hint')).dy);
}

View File

@ -160,7 +160,7 @@ void main() {
scaffoldKey,
NavigationDrawer(
children: <Widget>[
for(int i = 0; i < 100; i++)
for (int i = 0; i < 100; i++)
NavigationDrawerDestination(
icon: const Icon(Icons.ac_unit),
label: Text('Label$i'),
@ -213,7 +213,7 @@ void main() {
key: scaffoldKey,
drawer: NavigationDrawer(
children: <Widget>[
for(int i = 0; i < 10; i++)
for (int i = 0; i < 10; i++)
NavigationDrawerDestination(
icon: const Icon(Icons.ac_unit),
label: Text('Label$i'),

View File

@ -2081,7 +2081,7 @@ void main() {
Widget buildApp() {
final PageTransitionsTheme pageTransitionTheme = PageTransitionsTheme(
builders: <TargetPlatform, PageTransitionsBuilder>{
for(final TargetPlatform platform in TargetPlatform.values)
for (final TargetPlatform platform in TargetPlatform.values)
platform: const CupertinoPageTransitionsBuilder(),
},
);

View File

@ -931,7 +931,7 @@ testWidgets('Stepper custom indexed controls test', (WidgetTester tester) async
testWidgets('Vertical and Horizontal Stepper physics test', (WidgetTester tester) async {
const ScrollPhysics physics = NeverScrollableScrollPhysics();
for(final StepperType type in StepperType.values) {
for (final StepperType type in StepperType.values) {
await tester.pumpWidget(
MaterialApp(
home: Material(

View File

@ -16183,9 +16183,9 @@ void main() {
await click(find.text('Outside'));
switch(pointerDeviceKind) {
switch (pointerDeviceKind) {
case PointerDeviceKind.touch:
switch(defaultTargetPlatform) {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
case TargetPlatform.android:
case TargetPlatform.fuchsia:

View File

@ -70,7 +70,7 @@ void main() {
final TestClipPaintingContext context = TestClipPaintingContext();
final RenderBox child = box200x200;
final RenderStack stack;
switch(clip){
switch (clip){
case Clip.none:
case Clip.hardEdge:
case Clip.antiAlias:

View File

@ -210,7 +210,7 @@ void main() {
for (final Clip? clip in <Clip?>[null, ...Clip.values]) {
final RenderWrap wrap;
switch(clip){
switch (clip){
case Clip.none:
case Clip.hardEdge:
case Clip.antiAlias:

View File

@ -188,7 +188,7 @@ class FakeAndroidPlatformViewsController {
}
Future<dynamic> _onMethodCall(MethodCall call) {
switch(call.method) {
switch (call.method) {
case 'create':
return _create(call);
case 'dispose':
@ -400,7 +400,7 @@ class FakeIosPlatformViewsController {
}
Future<dynamic> _onMethodCall(MethodCall call) {
switch(call.method) {
switch (call.method) {
case 'create':
return _create(call);
case 'dispose':
@ -490,7 +490,7 @@ class FakeHtmlPlatformViewsController {
}
Future<dynamic> _onMethodCall(MethodCall call) {
switch(call.method) {
switch (call.method) {
case 'create':
return _create(call);
case 'dispose':

View File

@ -286,7 +286,7 @@ void main() {
final RenderAnimatedSize renderObject = tester.renderObject(find.byType(AnimatedSize));
expect(renderObject.clipBehavior, equals(Clip.hardEdge));
for(final Clip clip in Clip.values) {
for (final Clip clip in Clip.values) {
await tester.pumpWidget(
Center(
child: AnimatedSize(

View File

@ -607,7 +607,7 @@ void main() {
// Defaults to Clip.none
expect(renderObject.clipBehavior, equals(clip ?? Clip.none), reason: 'for clip = $clip');
switch(clip) {
switch (clip) {
case null:
case Clip.none:
// the UnconstrainedBox overflows.

View File

@ -172,7 +172,7 @@ void main() {
final RenderFlow renderObject = tester.renderObject(find.byType(Flow));
expect(renderObject.clipBehavior, equals(Clip.hardEdge));
for(final Clip clip in Clip.values) {
for (final Clip clip in Clip.values) {
await tester.pumpWidget(
Flow(
delegate: OpacityFlowDelegate(opacity),
@ -201,7 +201,7 @@ void main() {
final RenderFlow renderObject = tester.renderObject(find.byType(Flow));
expect(renderObject.clipBehavior, equals(Clip.hardEdge));
for(final Clip clip in Clip.values) {
for (final Clip clip in Clip.values) {
await tester.pumpWidget(
Flow.unwrapped(
delegate: OpacityFlowDelegate(opacity),

View File

@ -384,7 +384,7 @@ void main() {
Error? error;
try {
nav.currentState!.pushNamed<Object>('/second');
} on Error catch(e) {
} on Error catch (e) {
error = e;
}
expect(error, isNull);

View File

@ -1102,7 +1102,7 @@ void main() {
bool visited = false;
renderObject.visitChildren((RenderObject child) {
visited = true;
switch(clip) {
switch (clip) {
case Clip.none:
expect(renderObject.describeApproximatePaintClip(child), null);
case Clip.hardEdge:

View File

@ -53,7 +53,7 @@ void main() {
const ScrollableDetails details = ScrollableDetails(direction: AxisDirection.down);
final Widget child = Container();
switch(defaultTargetPlatform) {
switch (defaultTargetPlatform) {
case TargetPlatform.android:
case TargetPlatform.fuchsia:
case TargetPlatform.iOS:

View File

@ -366,7 +366,7 @@ void main() {
await pumpTest(tester, TargetPlatform.fuchsia, controller: controller);
controller.addListener(() {
if(controller.position.userScrollDirection != ScrollDirection.idle) {
if (controller.position.userScrollDirection != ScrollDirection.idle) {
lastUserScrollingDirection = controller.position.userScrollDirection;
}
});

View File

@ -380,7 +380,7 @@ void main() {
await gesture.moveTo(endPos);
expect(paragraph.selections[0], const TextSelection(baseOffset: 4, extentOffset: 8));
// Only Android vibrate when dragging the handle.
switch(defaultTargetPlatform) {
switch (defaultTargetPlatform) {
case TargetPlatform.android:
expect(
log.last,
@ -1273,7 +1273,7 @@ void main() {
final bool alt;
final bool control;
switch(defaultTargetPlatform) {
switch (defaultTargetPlatform) {
case TargetPlatform.android:
case TargetPlatform.fuchsia:
case TargetPlatform.linux:
@ -1381,7 +1381,7 @@ void main() {
final bool alt;
final bool meta;
switch(defaultTargetPlatform) {
switch (defaultTargetPlatform) {
case TargetPlatform.android:
case TargetPlatform.fuchsia:
case TargetPlatform.linux:
@ -1470,7 +1470,7 @@ void main() {
final bool alt;
final bool meta;
switch(defaultTargetPlatform) {
switch (defaultTargetPlatform) {
case TargetPlatform.android:
case TargetPlatform.fuchsia:
case TargetPlatform.linux:
@ -1759,7 +1759,7 @@ void main() {
final SelectableRegionState regionState = tester.state<SelectableRegionState>(find.byType(SelectableRegion));
// In Android copy should clear the selection.
switch(defaultTargetPlatform) {
switch (defaultTargetPlatform) {
case TargetPlatform.android:
case TargetPlatform.fuchsia:
expect(regionState.selectionOverlay, isNull);
@ -1812,7 +1812,7 @@ void main() {
final SelectableRegionState regionState = tester.state<SelectableRegionState>(find.byType(SelectableRegion));
switch(defaultTargetPlatform) {
switch (defaultTargetPlatform) {
case TargetPlatform.android:
case TargetPlatform.iOS:
case TargetPlatform.fuchsia:

View File

@ -325,7 +325,7 @@ void main() {
// interpreted as a gesture by the semantics debugger and sent to the widget
// as a semantic action that always moves by 10% of the complete track.
await tester.fling(find.byType(Slider), const Offset(-100.0, 0.0), 2000.0, warnIfMissed: false); // hitting the debugger
switch(defaultTargetPlatform) {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
case TargetPlatform.macOS:
expect(value, equals(0.65));

View File

@ -41,7 +41,7 @@ mixin DeserializeCommandFactory {
/// Deserializes the finder from JSON generated by [Command.serialize] or [CommandWithTarget.serialize].
Command deserializeCommand(Map<String, String> params, DeserializeFinderFactory finderFactory) {
final String? kind = params['command'];
switch(kind) {
switch (kind) {
case 'get_health': return GetHealth.deserialize(params);
case 'get_layer_tree': return GetLayerTree.deserialize(params);
case 'get_render_tree': return GetRenderTree.deserialize(params);

View File

@ -155,7 +155,7 @@ mixin CommandHandlerFactory {
/// Deserializes the finder from JSON generated by [Command.serialize] or [CommandWithTarget.serialize].
Future<Result> handleCommand(Command command, WidgetController prober, CreateFinderFactory finderFactory) {
switch(command.kind) {
switch (command.kind) {
case 'get_health': return _getHealth(command);
case 'get_layer_tree': return _getLayerTree(command);
case 'get_render_tree': return _getRenderTree(command);

View File

@ -448,7 +448,7 @@ class VMServiceFlutterDriver extends FlutterDriver {
Future<bool> _isPrecompiledMode() async {
final List<Map<String, dynamic>> flags = await getVmFlags();
for(final Map<String, dynamic> flag in flags) {
for (final Map<String, dynamic> flag in flags) {
if (flag['name'] == 'precompiled_mode') {
return flag['valueAsString'] == 'true';
}

View File

@ -136,7 +136,7 @@ class WebFlutterDriver extends FlutterDriver {
}
_logCommunication('<<< $response');
} on DriverError catch(_) {
} on DriverError catch (_) {
rethrow;
} catch (error, stackTrace) {
throw DriverError(

View File

@ -477,7 +477,7 @@ class FlutterLocalFileComparator extends FlutterGoldenFileComparator with LocalC
platform,
);
if(!baseDirectory.existsSync()) {
if (!baseDirectory.existsSync()) {
baseDirectory.createSync(recursive: true);
}

View File

@ -221,7 +221,7 @@ class SkiaGoldClient {
final File resultFile = workDirectory.childFile(fs.path.join(
'result-state.json',
));
if(await resultFile.exists()) {
if (await resultFile.exists()) {
resultContents = await resultFile.readAsString();
}
@ -344,7 +344,7 @@ class SkiaGoldClient {
final File resultFile = workDirectory.childFile(fs.path.join(
'result-state.json',
));
if(await resultFile.exists()) {
if (await resultFile.exists()) {
resultContents = await resultFile.readAsString();
}
final StringBuffer buf = StringBuffer()
@ -514,7 +514,7 @@ class SkiaGoldClient {
'auth_opt.json',
))/*!*/;
if(await authFile.exists()) {
if (await authFile.exists()) {
final String contents = await authFile.readAsString();
final Map<String, dynamic> decoded = json.decode(contents) as Map<String, dynamic>;
return !(decoded['GSUtil'] as bool/*!*/);

View File

@ -1091,7 +1091,7 @@ abstract class WidgetController {
),
]),
...<PointerEventRecord>[
for(int t = 0; t <= intervals; t += 1)
for (int t = 0; t <= intervals; t += 1)
PointerEventRecord(timeStamps[t], <PointerEvent>[
PointerMoveEvent(
timeStamp: timeStamps[t],

View File

@ -2445,7 +2445,7 @@ class _MatchesSemanticsData extends Matcher {
final bool actionExpected = actionEntry.value;
final bool actionPresent = (action.index & data.actions) == action.index;
if (actionPresent != actionExpected) {
if(actionExpected) {
if (actionExpected) {
missingActions.add(action);
} else {
unexpectedActions.add(action);
@ -2490,7 +2490,7 @@ class _MatchesSemanticsData extends Matcher {
final bool flagExpected = flagEntry.value;
final bool flagPresent = flag.index & data.flags == flag.index;
if (flagPresent != flagExpected) {
if(flagExpected) {
if (flagExpected) {
missingFlags.add(flag);
} else {
unexpectedFlags.add(flag);

View File

@ -285,7 +285,7 @@ void main() {
await tester.tap(find.text('test'), buttons: kSecondaryMouseButton);
const String b = '$kSecondaryMouseButton';
for(int i = 0; i < logs.length; i++) {
for (int i = 0; i < logs.length; i++) {
if (i == 0) {
expect(logs[i], 'down $b');
} else if (i != logs.length - 1) {
@ -342,7 +342,7 @@ void main() {
await tester.pumpAndSettle();
const String b = '$kSecondaryMouseButton';
for(int i = 0; i < logs.length; i++) {
for (int i = 0; i < logs.length; i++) {
if (i == 0) {
expect(logs[i], 'down $b');
} else if (i != logs.length - 1) {
@ -374,7 +374,7 @@ void main() {
await tester.drag(find.text('test'), const Offset(-150.0, 200.0), buttons: kSecondaryMouseButton);
const String b = '$kSecondaryMouseButton';
for(int i = 0; i < logs.length; i++) {
for (int i = 0; i < logs.length; i++) {
if (i == 0) {
expect(logs[i], 'down $b');
} else if (i != logs.length - 1) {
@ -408,7 +408,7 @@ void main() {
await tester.drag(find.text('test'), const Offset(-150.0, 200.0), kind: PointerDeviceKind.trackpad);
for(int i = 0; i < logs.length; i++) {
for (int i = 0; i < logs.length; i++) {
if (i == 0) {
expect(logs[i], 'panZoomStart');
} else if (i != logs.length - 1) {
@ -441,7 +441,7 @@ void main() {
await tester.pumpAndSettle();
const String b = '$kSecondaryMouseButton';
for(int i = 0; i < logs.length; i++) {
for (int i = 0; i < logs.length; i++) {
if (i == 0) {
expect(logs[i], 'down $b');
} else if (i != logs.length - 1) {
@ -506,7 +506,7 @@ void main() {
await tester.pumpAndSettle();
const String b = '$kSecondaryMouseButton';
for(int i = 0; i < logs.length; i++) {
for (int i = 0; i < logs.length; i++) {
if (i == 0) {
expect(logs[i], 'down $b');
} else if (i != logs.length - 1) {

View File

@ -159,7 +159,7 @@ final GradleHandledError multidexErrorHandler = GradleHandledError(
prompt: 'Do you want to continue with adding multidex support for Android?',
defaultChoiceIndex: 0,
);
} on StateError catch(e) {
} on StateError catch (e) {
globals.printError(
e.message,
indent: 0,
@ -273,7 +273,7 @@ final GradleHandledError zipExceptionHandler = GradleHandledError(
defaultChoiceIndex: 0,
);
shouldDeleteUserGradle = selection == 'y';
} on StateError catch(e) {
} on StateError catch (e) {
globals.printError(
e.message,
indent: 0,

View File

@ -340,7 +340,7 @@ class _LinuxUtils extends _PosixUtils {
for (String entry in osReleaseSplit) {
entry = entry.trim();
final List<String> entryKeyValuePair = entry.split('=');
if(entryKeyValuePair[0] == key) {
if (entryKeyValuePair[0] == key) {
final String value = entryKeyValuePair[1];
// Remove quotes from either end of the value if they exist
final String quote = value[0];

View File

@ -260,7 +260,7 @@ class AssembleCommand extends FlutterCommand {
final Map<String, Object>? defineConfigJsonMap = extractDartDefineConfigJsonMap();
final List<String> dartDefines = extractDartDefines(defineConfigJsonMap: defineConfigJsonMap);
if(dartDefines.isNotEmpty){
if (dartDefines.isNotEmpty){
results[kDartDefines] = dartDefines.join(',');
}

View File

@ -342,7 +342,7 @@ class DriveCommand extends RunCommandBase {
if (testResult != 0) {
throwToolExit(null);
}
} on Exception catch(_) {
} on Exception catch (_) {
// On exceptions, including ToolExit, take a screenshot on the device
// unless a screenshot was already taken on test failure.
if (!screenshotTaken && screenshot != null) {

View File

@ -316,8 +316,8 @@ class PackagesGetCommand extends FlutterCommand {
name,
...subArgs,
// `dart pub get` and friends defaults to `--no-example`.
if(!exampleWasParsed && target != null) '--example',
if(directoryOption == null && relativeTarget != null) ...<String>['--directory', relativeTarget],
if (!exampleWasParsed && target != null) '--example',
if (directoryOption == null && relativeTarget != null) ...<String>['--directory', relativeTarget],
],
project: rootProject,
context: _context,

View File

@ -200,7 +200,7 @@ class DwarfSymbolizationService {
.listen((String line) {
try {
output.writeln(line);
} on Exception catch(e, s) {
} on Exception catch (e, s) {
subscription?.cancel().whenComplete(() {
if (!onDone.isCompleted) {
onDone.completeError(e, s);

Some files were not shown because too many files have changed in this diff Show More