Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add spaces after flow control statements #126320

Merged
merged 24 commits into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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']}, '
Expand Down
2 changes: 1 addition & 1 deletion dev/devicelab/lib/tasks/gallery.dart
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ class GalleryTransitionBuildTest extends BuildTestTask {

@override
void copyArtifacts() {
if(applicationBinaryPath != null) {
if (applicationBinaryPath != null) {
copy(
file('${galleryDirectory.path}/build/app/outputs/flutter-apk/app-profile.apk'),
Directory(applicationBinaryPath!),
Expand Down
2 changes: 1 addition & 1 deletion dev/devicelab/lib/tasks/plugin_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void configureFlutterEngine(FlutterEngine flutterEngine) {

@Override
public void onMethodCall(MethodCall methodCall, MethodChannel.Result result) {
switch(methodCall.method) {
switch (methodCall.method) {
case "pipeFlutterViewEvents":
result.success(null);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void dispose() {

@Override
public void onMethodCall(MethodCall methodCall, MethodChannel.Result result) {
switch(methodCall.method) {
switch (methodCall.method) {
case "pipeTouchEvents":
touchPipe.enable();
result.success(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void enable() {
}

public void disable() {
if(!mEnabled)
if (!mEnabled)
return;
mEnabled = false;
mView.setOnTouchListener(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void configureFlutterEngine(FlutterEngine flutterEngine) {

@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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void dispose() {}

@Override
public void onMethodCall(MethodCall methodCall, MethodChannel.Result result) {
switch(methodCall.method) {
switch (methodCall.method) {
case "pipeTouchEvents":
touchPipe.enable();
result.success(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void enable() {
}

public void disable() {
if(!mEnabled)
if (!mEnabled)
return;
mEnabled = false;
mView.setOnTouchListener(null);
Expand Down
8 changes: 4 additions & 4 deletions dev/tools/gen_defaults/lib/input_decorator_template.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme {

@override
Color? get prefixIconColor => MaterialStateColor.resolveWith((Set<MaterialState> states) {${componentColor('md.comp.filled-text-field.error.leading-icon') == componentColor('md.comp.filled-text-field.leading-icon') ? '' : '''
if(states.contains(MaterialState.error)) {
if (states.contains(MaterialState.error)) {
if (states.contains(MaterialState.focused)) {
return ${componentColor('md.comp.filled-text-field.error.focus.leading-icon')};
}
Expand All @@ -111,7 +111,7 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme {

@override
Color? get suffixIconColor => MaterialStateColor.resolveWith((Set<MaterialState> states) {
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.focused)) {
return ${componentColor('md.comp.filled-text-field.error.focus.trailing-icon')};
}'''}
Expand All @@ -135,7 +135,7 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme {
@override
TextStyle? get labelStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) {
final TextStyle textStyle = ${textStyle("md.comp.filled-text-field.label-text")} ?? const TextStyle();
if(states.contains(MaterialState.error)) {
if (states.contains(MaterialState.error)) {
if (states.contains(MaterialState.focused)) {
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.error.focus.label-text')});
}
Expand All @@ -159,7 +159,7 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme {
@override
TextStyle? get floatingLabelStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) {
final TextStyle textStyle = ${textStyle("md.comp.filled-text-field.label-text")} ?? const TextStyle();
if(states.contains(MaterialState.error)) {
if (states.contains(MaterialState.error)) {
if (states.contains(MaterialState.focused)) {
return textStyle.copyWith(color: ${componentColor('md.comp.filled-text-field.error.focus.label-text')});
}
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/lib/src/cupertino/date_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/lib/src/cupertino/radio.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/lib/src/cupertino/scrollbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions packages/flutter/lib/src/cupertino/switch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox {
bool get isFocused => _isFocused;
bool _isFocused;
set isFocused(bool value) {
if(value == _isFocused) {
if (value == _isFocused) {
return;
}
_isFocused = value;
Expand Down Expand Up @@ -622,7 +622,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);

Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/lib/src/gestures/monodrag.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions packages/flutter/lib/src/material/bottom_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/lib/src/material/dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/lib/src/material/drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/lib/src/material/expand_icon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions packages/flutter/lib/src/material/input_decorator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4617,7 +4617,7 @@ class _InputDecoratorDefaultsM3 extends InputDecorationTheme {

@override
Color? get suffixIconColor => MaterialStateColor.resolveWith((Set<MaterialState> states) {
if(states.contains(MaterialState.error)) {
if (states.contains(MaterialState.error)) {
if (states.contains(MaterialState.hovered)) {
return _colors.onErrorContainer;
}
Expand All @@ -4632,7 +4632,7 @@ class _InputDecoratorDefaultsM3 extends InputDecorationTheme {
@override
TextStyle? get labelStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) {
final TextStyle textStyle = _textTheme.bodyLarge ?? const TextStyle();
if(states.contains(MaterialState.error)) {
if (states.contains(MaterialState.error)) {
if (states.contains(MaterialState.focused)) {
return textStyle.copyWith(color: _colors.error);
}
Expand All @@ -4656,7 +4656,7 @@ class _InputDecoratorDefaultsM3 extends InputDecorationTheme {
@override
TextStyle? get floatingLabelStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) {
final TextStyle textStyle = _textTheme.bodyLarge ?? const TextStyle();
if(states.contains(MaterialState.error)) {
if (states.contains(MaterialState.error)) {
if (states.contains(MaterialState.focused)) {
return textStyle.copyWith(color: _colors.error);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/lib/src/material/radio.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/lib/src/material/refresh_indicator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/lib/src/material/search.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/lib/src/material/text_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/flutter/lib/src/material/time_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions packages/flutter/lib/src/painting/box_border.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/lib/src/painting/text_painter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down