diff --git a/packages/flutter/lib/src/animation/animation_controller.dart b/packages/flutter/lib/src/animation/animation_controller.dart index d4161b3f9d..6491ac5f0e 100644 --- a/packages/flutter/lib/src/animation/animation_controller.dart +++ b/packages/flutter/lib/src/animation/animation_controller.dart @@ -389,8 +389,9 @@ class AnimationController extends Animation /// If [isAnimating] is false, then [value] is not changing and the rate of /// change is zero. double get velocity { - if (!isAnimating) + if (!isAnimating) { return 0.0; + } return _simulation!.dx(lastElapsedDuration!.inMicroseconds.toDouble() / Duration.microsecondsPerSecond); } @@ -456,8 +457,9 @@ class AnimationController extends Animation 'AnimationController methods should not be used after calling dispose.', ); _direction = _AnimationDirection.forward; - if (from != null) + if (from != null) { value = from; + } return _animateToInternal(upperBound); } @@ -489,8 +491,9 @@ class AnimationController extends Animation 'AnimationController methods should not be used after calling dispose.', ); _direction = _AnimationDirection.reverse; - if (from != null) + if (from != null) { value = from; + } return _animateToInternal(lowerBound); } @@ -856,12 +859,13 @@ class _InterpolationSimulation extends Simulation { @override double x(double timeInSeconds) { final double t = clampDouble(timeInSeconds / _durationInSeconds, 0.0, 1.0); - if (t == 0.0) + if (t == 0.0) { return _begin; - else if (t == 1.0) + } else if (t == 1.0) { return _end; - else + } else { return _begin + (_end - _begin) * _curve.transform(t); + } } @override diff --git a/packages/flutter/lib/src/animation/animations.dart b/packages/flutter/lib/src/animation/animations.dart index 1af955ba05..aab34c49b9 100644 --- a/packages/flutter/lib/src/animation/animations.dart +++ b/packages/flutter/lib/src/animation/animations.dart @@ -188,22 +188,27 @@ class ProxyAnimation extends Animation Animation? get parent => _parent; Animation? _parent; set parent(Animation? value) { - if (value == _parent) + if (value == _parent) { return; + } if (_parent != null) { _status = _parent!.status; _value = _parent!.value; - if (isListening) + if (isListening) { didStopListening(); + } } _parent = value; if (_parent != null) { - if (isListening) + if (isListening) { didStartListening(); - if (_value != _parent!.value) + } + if (_value != _parent!.value) { notifyListeners(); - if (_status != _parent!.status) + } + if (_status != _parent!.status) { notifyStatusListeners(_parent!.status); + } _status = null; _value = null; } @@ -233,8 +238,9 @@ class ProxyAnimation extends Animation @override String toString() { - if (parent == null) + if (parent == null) { return '${objectRuntimeType(this, 'ProxyAnimation')}(null; ${super.toStringDetails()} ${value.toStringAsFixed(3)})'; + } return '$parent\u27A9${objectRuntimeType(this, 'ProxyAnimation')}'; } } @@ -441,8 +447,9 @@ class CurvedAnimation extends Animation with AnimationWithParentMixin with AnimationWithParentMixin _lastValue = newValue; } assert(_lastValue != null); - if (hop && onSwitchedTrain != null) + if (hop && onSwitchedTrain != null) { onSwitchedTrain!(); + } } @override @@ -605,8 +615,9 @@ class TrainHoppingAnimation extends Animation @override String toString() { - if (_nextTrain != null) + if (_nextTrain != null) { return '$currentTrain\u27A9${objectRuntimeType(this, 'TrainHoppingAnimation')}(next: $_nextTrain)'; + } return '$currentTrain\u27A9${objectRuntimeType(this, 'TrainHoppingAnimation')}(no next)'; } } @@ -660,8 +671,9 @@ abstract class CompoundAnimation extends Animation /// Otherwise, default to [first]. @override AnimationStatus get status { - if (next.status == AnimationStatus.forward || next.status == AnimationStatus.reverse) + if (next.status == AnimationStatus.forward || next.status == AnimationStatus.reverse) { return next.status; + } return first.status; } diff --git a/packages/flutter/lib/src/animation/curves.dart b/packages/flutter/lib/src/animation/curves.dart index 46ad736a91..2db9676ae9 100644 --- a/packages/flutter/lib/src/animation/curves.dart +++ b/packages/flutter/lib/src/animation/curves.dart @@ -183,15 +183,17 @@ class Interval extends Curve { assert(end <= 1.0); assert(end >= begin); t = clampDouble((t - begin) / (end - begin), 0.0, 1.0); - if (t == 0.0 || t == 1.0) + if (t == 0.0 || t == 1.0) { return t; + } return curve.transform(t); } @override String toString() { - if (curve is! _Linear) + if (curve is! _Linear) { return '${objectRuntimeType(this, 'Interval')}($begin\u22EF$end)\u27A9$curve'; + } return '${objectRuntimeType(this, 'Interval')}($begin\u22EF$end)'; } } @@ -348,12 +350,14 @@ class Cubic extends Curve { while (true) { final double midpoint = (start + end) / 2; final double estimate = _evaluateCubic(a, c, midpoint); - if ((t - estimate).abs() < _cubicErrorBound) + if ((t - estimate).abs() < _cubicErrorBound) { return _evaluateCubic(b, d, midpoint); - if (estimate < t) + } + if (estimate < t) { start = midpoint; - else + } else { end = midpoint; + } } } @@ -1219,10 +1223,11 @@ class _BounceInOutCurve extends Curve { @override double transformInternal(double t) { - if (t < 0.5) + if (t < 0.5) { return (1.0 - _bounce(1.0 - t * 2.0)) * 0.5; - else + } else { return _bounce(t * 2.0 - 1.0) * 0.5 + 0.5; + } } } @@ -1304,10 +1309,11 @@ class ElasticInOutCurve extends Curve { double transformInternal(double t) { final double s = period / 4.0; t = 2.0 * t - 1.0; - if (t < 0.0) + if (t < 0.0) { return -0.5 * math.pow(2.0, 10.0 * t) * math.sin((t - s) * (math.pi * 2.0) / period); - else + } else { return math.pow(2.0, -10.0 * t) * math.sin((t - s) * (math.pi * 2.0) / period) * 0.5 + 1.0; + } } @override diff --git a/packages/flutter/lib/src/animation/listener_helpers.dart b/packages/flutter/lib/src/animation/listener_helpers.dart index 55cbd048e4..9af288c1b1 100644 --- a/packages/flutter/lib/src/animation/listener_helpers.dart +++ b/packages/flutter/lib/src/animation/listener_helpers.dart @@ -26,8 +26,9 @@ mixin AnimationLazyListenerMixin { @protected void didRegisterListener() { assert(_listenerCounter >= 0); - if (_listenerCounter == 0) + if (_listenerCounter == 0) { didStartListening(); + } _listenerCounter += 1; } @@ -41,8 +42,9 @@ mixin AnimationLazyListenerMixin { void didUnregisterListener() { assert(_listenerCounter >= 1); _listenerCounter -= 1; - if (_listenerCounter == 0) + if (_listenerCounter == 0) { didStopListening(); + } } /// Called when the number of listeners changes from zero to one. @@ -151,8 +153,9 @@ mixin AnimationLocalListenersMixin { return true; }()); try { - if (_listeners.contains(listener)) + if (_listeners.contains(listener)) { listener(); + } } catch (exception, stack) { FlutterError.reportError(FlutterErrorDetails( exception: exception, @@ -229,8 +232,9 @@ mixin AnimationLocalStatusListenersMixin { final List localListeners = _statusListeners.toList(growable: false); for (final AnimationStatusListener listener in localListeners) { try { - if (_statusListeners.contains(listener)) + if (_statusListeners.contains(listener)) { listener(status); + } } catch (exception, stack) { InformationCollector? collector; assert(() { diff --git a/packages/flutter/lib/src/animation/tween.dart b/packages/flutter/lib/src/animation/tween.dart index b59985f0ed..47ee563973 100644 --- a/packages/flutter/lib/src/animation/tween.dart +++ b/packages/flutter/lib/src/animation/tween.dart @@ -320,10 +320,12 @@ class Tween extends Animatable { /// subclass. @override T transform(double t) { - if (t == 0.0) + if (t == 0.0) { return begin as T; - if (t == 1.0) + } + if (t == 1.0) { return end as T; + } return lerp(t); } diff --git a/packages/flutter/lib/src/animation/tween_sequence.dart b/packages/flutter/lib/src/animation/tween_sequence.dart index bc1459303f..febf3c55cd 100644 --- a/packages/flutter/lib/src/animation/tween_sequence.dart +++ b/packages/flutter/lib/src/animation/tween_sequence.dart @@ -56,8 +56,9 @@ class TweenSequence extends Animatable { _items.addAll(items); double totalWeight = 0.0; - for (final TweenSequenceItem item in _items) + for (final TweenSequenceItem item in _items) { totalWeight += item.weight; + } assert(totalWeight > 0.0); double start = 0.0; @@ -80,11 +81,13 @@ class TweenSequence extends Animatable { @override T transform(double t) { assert(t >= 0.0 && t <= 1.0); - if (t == 1.0) + if (t == 1.0) { return _evaluateAt(t, _items.length - 1); + } for (int index = 0; index < _items.length; index++) { - if (_intervals[index].contains(t)) + if (_intervals[index].contains(t)) { return _evaluateAt(t, index); + } } // Should be unreachable. throw StateError('TweenSequence.evaluate() could not find an interval for $t'); diff --git a/packages/flutter/lib/src/cupertino/activity_indicator.dart b/packages/flutter/lib/src/cupertino/activity_indicator.dart index 3c4178b0bc..8df6eee006 100644 --- a/packages/flutter/lib/src/cupertino/activity_indicator.dart +++ b/packages/flutter/lib/src/cupertino/activity_indicator.dart @@ -107,10 +107,11 @@ class _CupertinoActivityIndicatorState extends State void didUpdateWidget(CupertinoActivityIndicator oldWidget) { super.didUpdateWidget(oldWidget); if (widget.animating != oldWidget.animating) { - if (widget.animating) + if (widget.animating) { _controller.repeat(); - else + } else { _controller.stop(); + } } } diff --git a/packages/flutter/lib/src/cupertino/bottom_tab_bar.dart b/packages/flutter/lib/src/cupertino/bottom_tab_bar.dart index b031c96cc9..f2628feee0 100644 --- a/packages/flutter/lib/src/cupertino/bottom_tab_bar.dart +++ b/packages/flutter/lib/src/cupertino/bottom_tab_bar.dart @@ -271,8 +271,9 @@ class CupertinoTabBar extends StatelessWidget implements PreferredSizeWidget { /// Change the active tab item's icon and title colors to active. Widget _wrapActiveItem(BuildContext context, Widget item, { required bool active }) { - if (!active) + if (!active) { return item; + } final Color activeColor = CupertinoDynamicColor.resolve( this.activeColor ?? CupertinoTheme.of(context).primaryColor, diff --git a/packages/flutter/lib/src/cupertino/button.dart b/packages/flutter/lib/src/cupertino/button.dart index e976647604..64a5056592 100644 --- a/packages/flutter/lib/src/cupertino/button.dart +++ b/packages/flutter/lib/src/cupertino/button.dart @@ -214,15 +214,17 @@ class _CupertinoButtonState extends State with SingleTickerProv } void _animate() { - if (_animationController.isAnimating) + if (_animationController.isAnimating) { return; + } final bool wasHeldDown = _buttonHeldDown; final TickerFuture ticker = _buttonHeldDown ? _animationController.animateTo(1.0, duration: kFadeOutDuration, curve: Curves.easeInOutCubicEmphasized) : _animationController.animateTo(0.0, duration: kFadeInDuration, curve: Curves.easeOutCubic); ticker.then((void value) { - if (mounted && wasHeldDown != _buttonHeldDown) + if (mounted && wasHeldDown != _buttonHeldDown) { _animate(); + } }); } diff --git a/packages/flutter/lib/src/cupertino/colors.dart b/packages/flutter/lib/src/cupertino/colors.dart index b50784705c..329a39d4bb 100644 --- a/packages/flutter/lib/src/cupertino/colors.dart +++ b/packages/flutter/lib/src/cupertino/colors.dart @@ -928,8 +928,9 @@ class CupertinoDynamicColor extends Color with Diagnosticable { /// * [resolve], which is similar to this function, but returns a /// non-nullable value, and does not allow a null `resolvable` color. static Color? maybeResolve(Color? resolvable, BuildContext context) { - if (resolvable == null) + if (resolvable == null) { return null; + } assert(context != null); return (resolvable is CupertinoDynamicColor) ? resolvable.resolveFrom(context) @@ -1045,10 +1046,12 @@ class CupertinoDynamicColor extends Color with Diagnosticable { @override bool operator ==(Object other) { - if (identical(this, other)) + if (identical(this, other)) { return true; - if (other.runtimeType != runtimeType) + } + if (other.runtimeType != runtimeType) { return false; + } return other is CupertinoDynamicColor && other.value == value && other.color == color @@ -1097,26 +1100,35 @@ class CupertinoDynamicColor extends Color with Diagnosticable { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - if (_debugLabel != null) + if (_debugLabel != null) { properties.add(MessageProperty('debugLabel', _debugLabel!)); + } properties.add(createCupertinoColorProperty('color', color)); - if (_isPlatformBrightnessDependent) + if (_isPlatformBrightnessDependent) { properties.add(createCupertinoColorProperty('darkColor', darkColor)); - if (_isHighContrastDependent) + } + if (_isHighContrastDependent) { properties.add(createCupertinoColorProperty('highContrastColor', highContrastColor)); - if (_isPlatformBrightnessDependent && _isHighContrastDependent) + } + if (_isPlatformBrightnessDependent && _isHighContrastDependent) { properties.add(createCupertinoColorProperty('darkHighContrastColor', darkHighContrastColor)); - if (_isInterfaceElevationDependent) + } + if (_isInterfaceElevationDependent) { properties.add(createCupertinoColorProperty('elevatedColor', elevatedColor)); - if (_isPlatformBrightnessDependent && _isInterfaceElevationDependent) + } + if (_isPlatformBrightnessDependent && _isInterfaceElevationDependent) { properties.add(createCupertinoColorProperty('darkElevatedColor', darkElevatedColor)); - if (_isHighContrastDependent && _isInterfaceElevationDependent) + } + if (_isHighContrastDependent && _isInterfaceElevationDependent) { properties.add(createCupertinoColorProperty('highContrastElevatedColor', highContrastElevatedColor)); - if (_isPlatformBrightnessDependent && _isHighContrastDependent && _isInterfaceElevationDependent) + } + if (_isPlatformBrightnessDependent && _isHighContrastDependent && _isInterfaceElevationDependent) { properties.add(createCupertinoColorProperty('darkHighContrastElevatedColor', darkHighContrastElevatedColor)); + } - if (_debugResolveContext != null) + if (_debugResolveContext != null) { properties.add(DiagnosticsProperty('last resolved', _debugResolveContext)); + } } } diff --git a/packages/flutter/lib/src/cupertino/date_picker.dart b/packages/flutter/lib/src/cupertino/date_picker.dart index dd2744f8b4..f735b75d33 100644 --- a/packages/flutter/lib/src/cupertino/date_picker.dart +++ b/packages/flutter/lib/src/cupertino/date_picker.dart @@ -94,8 +94,9 @@ class _DatePickerLayoutDelegate extends MultiChildLayoutDelegate { void performLayout(Size size) { double remainingWidth = size.width; - for (int i = 0; i < columnWidths.length; i++) + for (int i = 0; i < columnWidths.length; i++) { remainingWidth -= columnWidths[i] + _kDatePickerPadSize * 2; + } double currentHorizontalOffset = 0.0; @@ -103,8 +104,9 @@ class _DatePickerLayoutDelegate extends MultiChildLayoutDelegate { final int index = textDirectionFactor == 1 ? i : columnWidths.length - i - 1; double childWidth = columnWidths[index] + _kDatePickerPadSize * 2; - if (index == 0 || index == columnWidths.length - 1) + if (index == 0 || index == columnWidths.length - 1) { childWidth += remainingWidth / 2; + } // We can't actually assert here because it would break things badly for // semantics, which will expect that we laid things out here. @@ -418,22 +420,25 @@ class CupertinoDatePicker extends StatefulWidget { // An arbitrary date. final String date = localizations.datePickerMediumDate(DateTime(2018, i, 25)); - if (longestText.length < date.length) + if (longestText.length < date.length) { longestText = date; + } } break; case _PickerColumnType.hour: for (int i = 0; i < 24; i++) { final String hour = localizations.datePickerHour(i); - if (longestText.length < hour.length) + if (longestText.length < hour.length) { longestText = hour; + } } break; case _PickerColumnType.minute: for (int i = 0; i < 60; i++) { final String minute = localizations.datePickerMinute(i); - if (longestText.length < minute.length) + if (longestText.length < minute.length) { longestText = minute; + } } break; case _PickerColumnType.dayPeriod: @@ -445,15 +450,17 @@ class CupertinoDatePicker extends StatefulWidget { case _PickerColumnType.dayOfMonth: for (int i = 1; i <=31; i++) { final String dayOfMonth = localizations.datePickerDayOfMonth(i); - if (longestText.length < dayOfMonth.length) + if (longestText.length < dayOfMonth.length) { longestText = dayOfMonth; + } } break; case _PickerColumnType.month: for (int i = 1; i <=12; i++) { final String month = localizations.datePickerMonth(i); - if (longestText.length < month.length) + if (longestText.length < month.length) { longestText = month; + } } break; case _PickerColumnType.year: @@ -678,8 +685,9 @@ class _CupertinoDatePickerDateTimeState extends State { final bool isDateInvalid = (widget.minimumDate?.isAfter(selected) ?? false) || (widget.maximumDate?.isBefore(selected) ?? false); - if (isDateInvalid) + if (isDateInvalid) { return; + } widget.onDateTimeChanged(selected); } @@ -724,10 +732,12 @@ class _CupertinoDatePickerDateTimeState extends State { final DateTime now = DateTime.now(); - if (widget.minimumDate?.isBefore(rangeEnd) == false) + if (widget.minimumDate?.isBefore(rangeEnd) == false) { return null; - if (widget.maximumDate?.isAfter(rangeStart) == false) + } + if (widget.maximumDate?.isAfter(rangeStart) == false) { return null; + } final String dateText = rangeStart == DateTime(now.year, now.month, now.day) ? localizations.todayLabel @@ -922,8 +932,9 @@ class _CupertinoDatePickerDateTimeState extends State { // Call setState to update the greyed out date/hour/minute/meridiem. setState(() { }); - if (isScrolling) + if (isScrolling) { return; + } // Whenever scrolling lands on an invalid entry, the picker // automatically scrolls to a valid one. @@ -1016,16 +1027,18 @@ class _CupertinoDatePickerDateTimeState extends State { if (i == 0) { offAxisFraction = -_kMaximumOffAxisFraction * textDirectionFactor; selectionOverlay = _startSelectionOverlay; - } else if (i >= 2 || columnWidths.length == 2) + } else if (i >= 2 || columnWidths.length == 2) { offAxisFraction = _kMaximumOffAxisFraction * textDirectionFactor; + } EdgeInsets padding = const EdgeInsets.only(right: _kDatePickerPadSize); if (i == columnWidths.length - 1) { padding = padding.flipped; selectionOverlay = _endSelectionOverlay; } - if (textDirectionFactor == -1) + if (textDirectionFactor == -1) { padding = padding.flipped; + } pickers.add(LayoutId( id: i, @@ -1181,8 +1194,9 @@ class _CupertinoDatePickerDateState extends State { squeeze: _kSqueeze, onSelectedItemChanged: (int index) { selectedDay = index + 1; - if (_isCurrentDateValid) + if (_isCurrentDateValid) { widget.onDateTimeChanged(DateTime(selectedYear, selectedMonth, selectedDay)); + } }, looping: true, selectionOverlay: selectionOverlay, @@ -1222,8 +1236,9 @@ class _CupertinoDatePickerDateState extends State { squeeze: _kSqueeze, onSelectedItemChanged: (int index) { selectedMonth = index + 1; - if (_isCurrentDateValid) + if (_isCurrentDateValid) { widget.onDateTimeChanged(DateTime(selectedYear, selectedMonth, selectedDay)); + } }, looping: true, selectionOverlay: selectionOverlay, @@ -1265,15 +1280,18 @@ class _CupertinoDatePickerDateState extends State { backgroundColor: widget.backgroundColor, onSelectedItemChanged: (int index) { selectedYear = index; - if (_isCurrentDateValid) + if (_isCurrentDateValid) { widget.onDateTimeChanged(DateTime(selectedYear, selectedMonth, selectedDay)); + } }, itemBuilder: (BuildContext context, int year) { - if (year < widget.minimumYear) + if (year < widget.minimumYear) { return null; + } - if (widget.maximumYear != null && year > widget.maximumYear!) + if (widget.maximumYear != null && year > widget.maximumYear!) { return null; + } final bool isValidYear = (widget.minimumDate == null || widget.minimumDate!.year <= year) && (widget.maximumDate == null || widget.maximumDate!.year >= year); @@ -1401,14 +1419,16 @@ class _CupertinoDatePickerDateState extends State { final double offAxisFraction = (i - 1) * 0.3 * textDirectionFactor; EdgeInsets padding = const EdgeInsets.only(right: _kDatePickerPadSize); - if (textDirectionFactor == -1) + if (textDirectionFactor == -1) { padding = const EdgeInsets.only(left: _kDatePickerPadSize); + } Widget selectionOverlay = _centerSelectionOverlay; - if (i == 0) + if (i == 0) { selectionOverlay = _startSelectionOverlay; - else if (i == columnWidths.length - 1) + } else if (i == columnWidths.length - 1) { selectionOverlay = _endSelectionOverlay; + } pickers.add(LayoutId( id: i, @@ -1619,11 +1639,13 @@ class _CupertinoTimerPickerState extends State { selectedMinute = widget.initialTimerDuration.inMinutes % 60; - if (widget.mode != CupertinoTimerPickerMode.ms) + if (widget.mode != CupertinoTimerPickerMode.ms) { selectedHour = widget.initialTimerDuration.inHours; + } - if (widget.mode != CupertinoTimerPickerMode.hm) + if (widget.mode != CupertinoTimerPickerMode.hm) { selectedSecond = widget.initialTimerDuration.inSeconds % 60; + } PaintingBinding.instance.systemFonts.addListener(_handleSystemFontsChange); } @@ -1702,13 +1724,15 @@ class _CupertinoTimerPickerState extends State { minuteLabelWidth = _measureLabelsMaxWidth(localizations.timerPickerMinuteLabels, textStyle); - if (widget.mode != CupertinoTimerPickerMode.ms) + if (widget.mode != CupertinoTimerPickerMode.ms) { hourLabelWidth = _measureLabelsMaxWidth(localizations.timerPickerHourLabels, textStyle); + } - if (widget.mode != CupertinoTimerPickerMode.hm) + if (widget.mode != CupertinoTimerPickerMode.hm) { secondLabelWidth = _measureLabelsMaxWidth(localizations.timerPickerSecondLabels, textStyle); + } } // Measures all possible time text labels and return maximum width. @@ -1723,8 +1747,9 @@ class _CupertinoTimerPickerState extends State { textPainter.text = TextSpan(text: label, style: style); textPainter.layout(); textPainter.maxIntrinsicWidth; - if (textPainter.maxIntrinsicWidth > maxWidth) + if (textPainter.maxIntrinsicWidth > maxWidth) { maxWidth = textPainter.maxIntrinsicWidth; + } } return maxWidth; @@ -2030,13 +2055,15 @@ class _CupertinoTimerPickerState extends State { final double hourLabelContentWidth = baseLabelContentWidth + hourLabelWidth; double hourColumnStartPadding = pickerColumnWidth - hourLabelContentWidth - _kTimerPickerHalfColumnPadding; - if (hourColumnStartPadding < _kTimerPickerMinHorizontalPadding) + if (hourColumnStartPadding < _kTimerPickerMinHorizontalPadding) { hourColumnStartPadding = _kTimerPickerMinHorizontalPadding; + } double minuteColumnEndPadding = pickerColumnWidth - minuteLabelContentWidth - _kTimerPickerHalfColumnPadding; - if (minuteColumnEndPadding < _kTimerPickerMinHorizontalPadding) + if (minuteColumnEndPadding < _kTimerPickerMinHorizontalPadding) { minuteColumnEndPadding = _kTimerPickerMinHorizontalPadding; + } columns = [ _buildHourColumn( @@ -2059,13 +2086,15 @@ class _CupertinoTimerPickerState extends State { final double secondLabelContentWidth = baseLabelContentWidth + secondLabelWidth; double secondColumnEndPadding = pickerColumnWidth - secondLabelContentWidth - _kTimerPickerHalfColumnPadding; - if (secondColumnEndPadding < _kTimerPickerMinHorizontalPadding) + if (secondColumnEndPadding < _kTimerPickerMinHorizontalPadding) { secondColumnEndPadding = _kTimerPickerMinHorizontalPadding; + } double minuteColumnStartPadding = pickerColumnWidth - minuteLabelContentWidth - _kTimerPickerHalfColumnPadding; - if (minuteColumnStartPadding < _kTimerPickerMinHorizontalPadding) + if (minuteColumnStartPadding < _kTimerPickerMinHorizontalPadding) { minuteColumnStartPadding = _kTimerPickerMinHorizontalPadding; + } columns = [ _buildMinuteColumn( diff --git a/packages/flutter/lib/src/cupertino/dialog.dart b/packages/flutter/lib/src/cupertino/dialog.dart index 01bd7866f3..435cf2b478 100644 --- a/packages/flutter/lib/src/cupertino/dialog.dart +++ b/packages/flutter/lib/src/cupertino/dialog.dart @@ -1567,8 +1567,9 @@ class _ActionButtonParentDataWidget // Force a repaint. final AbstractNode? targetParent = renderObject.parent; - if (targetParent is RenderObject) + if (targetParent is RenderObject) { targetParent.markNeedsPaint(); + } } } @@ -1905,8 +1906,9 @@ class _RenderCupertinoDialogActions extends RenderBox bool _hasCancelButton; bool get hasCancelButton => _hasCancelButton; set hasCancelButton(bool newValue) { - if (newValue == _hasCancelButton) + if (newValue == _hasCancelButton) { return; + } _hasCancelButton = newValue; markNeedsLayout(); @@ -1915,8 +1917,9 @@ class _RenderCupertinoDialogActions extends RenderBox Color get dialogColor => _buttonBackgroundPaint.color; final Paint _buttonBackgroundPaint; set dialogColor(Color value) { - if (value == _buttonBackgroundPaint.color) + if (value == _buttonBackgroundPaint.color) { return; + } _buttonBackgroundPaint.color = value; markNeedsPaint(); @@ -1925,8 +1928,9 @@ class _RenderCupertinoDialogActions extends RenderBox Color get dialogPressedColor => _pressedButtonBackgroundPaint.color; final Paint _pressedButtonBackgroundPaint; set dialogPressedColor(Color value) { - if (value == _pressedButtonBackgroundPaint.color) + if (value == _pressedButtonBackgroundPaint.color) { return; + } _pressedButtonBackgroundPaint.color = value; markNeedsPaint(); @@ -1935,8 +1939,9 @@ class _RenderCupertinoDialogActions extends RenderBox Color get dividerColor => _dividerPaint.color; final Paint _dividerPaint; set dividerColor(Color value) { - if (value == _dividerPaint.color) + if (value == _dividerPaint.color) { return; + } _dividerPaint.color = value; markNeedsPaint(); @@ -1945,8 +1950,9 @@ class _RenderCupertinoDialogActions extends RenderBox bool get isActionSheet => _isActionSheet; bool _isActionSheet; set isActionSheet(bool value) { - if (value == _isActionSheet) + if (value == _isActionSheet) { return; + } _isActionSheet = value; markNeedsPaint(); @@ -1981,8 +1987,9 @@ class _RenderCupertinoDialogActions extends RenderBox @override void setupParentData(RenderBox child) { - if (child.parentData is! _ActionButtonParentData) + if (child.parentData is! _ActionButtonParentData) { child.parentData = _ActionButtonParentData(); + } } @override @@ -2000,10 +2007,12 @@ class _RenderCupertinoDialogActions extends RenderBox if (childCount == 0) { return 0.0; } else if (isActionSheet) { - if (childCount == 1) + if (childCount == 1) { return firstChild!.computeMaxIntrinsicHeight(width) + dividerThickness; - if (hasCancelButton && childCount < 4) + } + if (hasCancelButton && childCount < 4) { return _computeMinIntrinsicHeightWithCancel(width); + } return _computeMinIntrinsicHeightStacked(width); } else if (childCount == 1) { // If only 1 button, display the button across the entire dialog. @@ -2070,8 +2079,9 @@ class _RenderCupertinoDialogActions extends RenderBox // No buttons. Zero height. return 0.0; } else if (isActionSheet) { - if (childCount == 1) + if (childCount == 1) { return firstChild!.computeMaxIntrinsicHeight(width) + dividerThickness; + } return _computeMaxIntrinsicHeightStacked(width); } else if (childCount == 1) { // One button. Our max intrinsic height is equal to the button's. diff --git a/packages/flutter/lib/src/cupertino/interface_level.dart b/packages/flutter/lib/src/cupertino/interface_level.dart index c4110e93af..7d3095f6df 100644 --- a/packages/flutter/lib/src/cupertino/interface_level.dart +++ b/packages/flutter/lib/src/cupertino/interface_level.dart @@ -66,8 +66,9 @@ class CupertinoUserInterfaceLevel extends InheritedWidget { static CupertinoUserInterfaceLevelData of(BuildContext context) { assert(context != null); final CupertinoUserInterfaceLevel? query = context.dependOnInheritedWidgetOfExactType(); - if (query != null) + if (query != null) { return query._data; + } throw FlutterError( 'CupertinoUserInterfaceLevel.of() called with a context that does not contain a CupertinoUserInterfaceLevel.\n' 'No CupertinoUserInterfaceLevel ancestor could be found starting from the context that was passed ' @@ -95,8 +96,9 @@ class CupertinoUserInterfaceLevel extends InheritedWidget { static CupertinoUserInterfaceLevelData? maybeOf(BuildContext context) { assert(context != null); final CupertinoUserInterfaceLevel? query = context.dependOnInheritedWidgetOfExactType(); - if (query != null) + if (query != null) { return query._data; + } return null; } diff --git a/packages/flutter/lib/src/cupertino/localizations.dart b/packages/flutter/lib/src/cupertino/localizations.dart index 9f8b81c28c..493d4d6a82 100644 --- a/packages/flutter/lib/src/cupertino/localizations.dart +++ b/packages/flutter/lib/src/cupertino/localizations.dart @@ -351,8 +351,9 @@ class DefaultCupertinoLocalizations implements CupertinoLocalizations { @override String datePickerMinuteSemanticsLabel(int minute) { - if (minute == 1) + if (minute == 1) { return '1 minute'; + } return '$minute minutes'; } diff --git a/packages/flutter/lib/src/cupertino/nav_bar.dart b/packages/flutter/lib/src/cupertino/nav_bar.dart index c9e3800769..9f0a76ff49 100644 --- a/packages/flutter/lib/src/cupertino/nav_bar.dart +++ b/packages/flutter/lib/src/cupertino/nav_bar.dart @@ -160,8 +160,9 @@ Widget _wrapWithBackground({ child: result, ); - if (backgroundColor.alpha == 0xFF) + if (backgroundColor.alpha == 0xFF) { return childWithBackground; + } return ClipRect( child: BackdropFilter( diff --git a/packages/flutter/lib/src/cupertino/picker.dart b/packages/flutter/lib/src/cupertino/picker.dart index 1020522a5f..1476d16223 100644 --- a/packages/flutter/lib/src/cupertino/picker.dart +++ b/packages/flutter/lib/src/cupertino/picker.dart @@ -439,12 +439,14 @@ class _RenderCupertinoPickerSemantics extends RenderProxyBox { // This method exists to allow controller to be non-null. It is only called with a null oldValue from constructor. void _updateController(FixedExtentScrollController? oldValue, FixedExtentScrollController value) { - if (value == oldValue) + if (value == oldValue) { return; - if (oldValue != null) + } + if (oldValue != null) { oldValue.removeListener(_handleScrollUpdate); - else + } else { _currentIndex = value.initialItem; + } value.addListener(_handleScrollUpdate); _controller = value; } @@ -452,8 +454,9 @@ class _RenderCupertinoPickerSemantics extends RenderProxyBox { TextDirection get textDirection => _textDirection; TextDirection _textDirection; set textDirection(TextDirection value) { - if (textDirection == value) + if (textDirection == value) { return; + } _textDirection = value; markNeedsSemanticsUpdate(); } @@ -469,8 +472,9 @@ class _RenderCupertinoPickerSemantics extends RenderProxyBox { } void _handleScrollUpdate() { - if (controller.selectedItem == _currentIndex) + if (controller.selectedItem == _currentIndex) { return; + } _currentIndex = controller.selectedItem; markNeedsSemanticsUpdate(); } @@ -483,8 +487,9 @@ class _RenderCupertinoPickerSemantics extends RenderProxyBox { @override void assembleSemanticsNode(SemanticsNode node, SemanticsConfiguration config, Iterable children) { - if (children.isEmpty) + if (children.isEmpty) { return super.assembleSemanticsNode(node, config, children); + } final SemanticsNode scrollable = children.first; final Map indexedChildren = {}; scrollable.visitChildren((SemanticsNode child) { diff --git a/packages/flutter/lib/src/cupertino/refresh.dart b/packages/flutter/lib/src/cupertino/refresh.dart index d106165c4c..dd2622e1dc 100644 --- a/packages/flutter/lib/src/cupertino/refresh.dart +++ b/packages/flutter/lib/src/cupertino/refresh.dart @@ -76,8 +76,9 @@ class _RenderCupertinoSliverRefresh extends RenderSliver set refreshIndicatorLayoutExtent(double value) { assert(value != null); assert(value >= 0.0); - if (value == _refreshIndicatorExtent) + if (value == _refreshIndicatorExtent) { return; + } _refreshIndicatorExtent = value; markNeedsLayout(); } @@ -89,8 +90,9 @@ class _RenderCupertinoSliverRefresh extends RenderSliver bool _hasLayoutExtent; set hasLayoutExtent(bool value) { assert(value != null); - if (value == _hasLayoutExtent) + if (value == _hasLayoutExtent) { return; + } _hasLayoutExtent = value; markNeedsLayout(); } diff --git a/packages/flutter/lib/src/cupertino/route.dart b/packages/flutter/lib/src/cupertino/route.dart index 1968f402f7..f7908506e9 100644 --- a/packages/flutter/lib/src/cupertino/route.dart +++ b/packages/flutter/lib/src/cupertino/route.dart @@ -186,30 +186,37 @@ mixin CupertinoRouteTransitionMixin on PageRoute { static bool _isPopGestureEnabled(PageRoute route) { // If there's nothing to go back to, then obviously we don't support // the back gesture. - if (route.isFirst) + if (route.isFirst) { return false; + } // If the route wouldn't actually pop if we popped it, then the gesture // would be really confusing (or would skip internal routes), so disallow it. - if (route.willHandlePopInternally) + if (route.willHandlePopInternally) { return false; + } // If attempts to dismiss this route might be vetoed such as in a page // with forms, then do not allow the user to dismiss the route with a swipe. - if (route.hasScopedWillPopCallback) + if (route.hasScopedWillPopCallback) { return false; + } // Fullscreen dialogs aren't dismissible by back swipe. - if (route.fullscreenDialog) + if (route.fullscreenDialog) { return false; + } // If we're in an animation already, we cannot be manually swiped. - if (route.animation!.status != AnimationStatus.completed) + if (route.animation!.status != AnimationStatus.completed) { return false; + } // If we're being popped into, we also cannot be swiped until the pop above // it completes. This translates to our secondary animation being // dismissed. - if (route.secondaryAnimation!.status != AnimationStatus.dismissed) + if (route.secondaryAnimation!.status != AnimationStatus.dismissed) { return false; + } // If we're in a gesture already, we cannot start another. - if (isPopGestureInProgress(route)) + if (isPopGestureInProgress(route)) { return false; + } // Looks like a back gesture would be welcome! return true; @@ -657,8 +664,9 @@ class _CupertinoBackGestureDetectorState extends State<_CupertinoBackGestureD } void _handlePointerDown(PointerDownEvent event) { - if (widget.enabledCallback()) + if (widget.enabledCallback()) { _recognizer.addPointer(event); + } } double _convertToLogical(double value) { @@ -746,10 +754,11 @@ class _CupertinoBackGestureController { // If the user releases the page before mid screen with sufficient velocity, // or after mid screen, we should animate the page out. Otherwise, the page // should be animated back in. - if (velocity.abs() >= _kMinFlingVelocity) + if (velocity.abs() >= _kMinFlingVelocity) { animateForward = velocity <= 0; - else + } else { animateForward = controller.value > 0.5; + } if (animateForward) { // The closer the panel is to dismissing, the shorter the animation is. @@ -840,12 +849,15 @@ class _CupertinoEdgeShadowDecoration extends Decoration { double t, ) { assert(t != null); - if (a == null && b == null) + if (a == null && b == null) { return null; - if (a == null) + } + if (a == null) { return b!._colors == null ? b : _CupertinoEdgeShadowDecoration._(b._colors!.map((Color color) => Color.lerp(null, color, t)!).toList()); - if (b == null) + } + if (b == null) { return a._colors == null ? a : _CupertinoEdgeShadowDecoration._(a._colors!.map((Color color) => Color.lerp(null, color, 1.0 - t)!).toList()); + } assert(b._colors != null || a._colors != null); // If it ever becomes necessary, we could allow decorations with different // length' here, similarly to how it is handled in [LinearGradient.lerp]. @@ -860,15 +872,17 @@ class _CupertinoEdgeShadowDecoration extends Decoration { @override _CupertinoEdgeShadowDecoration lerpFrom(Decoration? a, double t) { - if (a is _CupertinoEdgeShadowDecoration) + if (a is _CupertinoEdgeShadowDecoration) { return _CupertinoEdgeShadowDecoration.lerp(a, this, t)!; + } return _CupertinoEdgeShadowDecoration.lerp(null, this, t)!; } @override _CupertinoEdgeShadowDecoration lerpTo(Decoration? b, double t) { - if (b is _CupertinoEdgeShadowDecoration) + if (b is _CupertinoEdgeShadowDecoration) { return _CupertinoEdgeShadowDecoration.lerp(this, b, t)!; + } return _CupertinoEdgeShadowDecoration.lerp(this, null, t)!; } @@ -879,8 +893,9 @@ class _CupertinoEdgeShadowDecoration extends Decoration { @override bool operator ==(Object other) { - if (other.runtimeType != runtimeType) + if (other.runtimeType != runtimeType) { return false; + } return other is _CupertinoEdgeShadowDecoration && other._colors == _colors; } diff --git a/packages/flutter/lib/src/cupertino/search_field.dart b/packages/flutter/lib/src/cupertino/search_field.dart index 14d57a51ab..a91ae89ea2 100644 --- a/packages/flutter/lib/src/cupertino/search_field.dart +++ b/packages/flutter/lib/src/cupertino/search_field.dart @@ -331,8 +331,9 @@ class _CupertinoSearchTextFieldState extends State void _defaultOnSuffixTap() { final bool textChanged = _effectiveController.text.isNotEmpty; _effectiveController.clear(); - if (widget.onChanged != null && textChanged) + if (widget.onChanged != null && textChanged) { widget.onChanged!(_effectiveController.text); + } } @override diff --git a/packages/flutter/lib/src/cupertino/segmented_control.dart b/packages/flutter/lib/src/cupertino/segmented_control.dart index 27ea1255df..d381128d92 100644 --- a/packages/flutter/lib/src/cupertino/segmented_control.dart +++ b/packages/flutter/lib/src/cupertino/segmented_control.dart @@ -303,8 +303,9 @@ class _SegmentedControlState extends State extends State= 0.0 && newValue <= 1.0); - if (newValue == _value) + if (newValue == _value) { return; + } _value = newValue; - if (divisions != null) + if (divisions != null) { _position.animateTo(newValue, curve: Curves.fastOutSlowIn); - else + } else { _position.value = newValue; + } markNeedsSemanticsUpdate(); } int? get divisions => _divisions; int? _divisions; set divisions(int? value) { - if (value == _divisions) + if (value == _divisions) { return; + } _divisions = value; markNeedsPaint(); } @@ -381,8 +384,9 @@ class _RenderCupertinoSlider extends RenderConstrainedBox { Color get activeColor => _activeColor; Color _activeColor; set activeColor(Color value) { - if (value == _activeColor) + if (value == _activeColor) { return; + } _activeColor = value; markNeedsPaint(); } @@ -390,8 +394,9 @@ class _RenderCupertinoSlider extends RenderConstrainedBox { Color get thumbColor => _thumbColor; Color _thumbColor; set thumbColor(Color value) { - if (value == _thumbColor) + if (value == _thumbColor) { return; + } _thumbColor = value; markNeedsPaint(); } @@ -399,8 +404,9 @@ class _RenderCupertinoSlider extends RenderConstrainedBox { Color get trackColor => _trackColor; Color _trackColor; set trackColor(Color value) { - if (value == _trackColor) + if (value == _trackColor) { return; + } _trackColor = value; markNeedsPaint(); } @@ -408,12 +414,14 @@ class _RenderCupertinoSlider extends RenderConstrainedBox { ValueChanged? get onChanged => _onChanged; ValueChanged? _onChanged; set onChanged(ValueChanged? value) { - if (value == _onChanged) + if (value == _onChanged) { return; + } final bool wasInteractive = isInteractive; _onChanged = value; - if (wasInteractive != isInteractive) + if (wasInteractive != isInteractive) { markNeedsSemanticsUpdate(); + } } ValueChanged? onChangeStart; @@ -423,8 +431,9 @@ class _RenderCupertinoSlider extends RenderConstrainedBox { TextDirection _textDirection; set textDirection(TextDirection value) { assert(value != null); - if (_textDirection == value) + if (_textDirection == value) { return; + } _textDirection = value; markNeedsPaint(); } @@ -436,8 +445,9 @@ class _RenderCupertinoSlider extends RenderConstrainedBox { double get _discretizedCurrentDragValue { double dragValue = clampDouble(_currentDragValue, 0.0, 1.0); - if (divisions != null) + if (divisions != null) { dragValue = (dragValue * divisions!).round() / divisions!; + } return dragValue; } @@ -499,8 +509,9 @@ class _RenderCupertinoSlider extends RenderConstrainedBox { @override void handleEvent(PointerEvent event, BoxHitTestEntry entry) { assert(debugHandleEvent(event, entry)); - if (event is PointerDownEvent && isInteractive) + if (event is PointerDownEvent && isInteractive) { _drag.addPointer(event); + } } @override @@ -563,12 +574,14 @@ class _RenderCupertinoSlider extends RenderConstrainedBox { double get _semanticActionUnit => divisions != null ? 1.0 / divisions! : _kAdjustmentUnit; void _increaseAction() { - if (isInteractive) + if (isInteractive) { onChanged!(clampDouble(value + _semanticActionUnit, 0.0, 1.0)); + } } void _decreaseAction() { - if (isInteractive) + if (isInteractive) { onChanged!(clampDouble(value - _semanticActionUnit, 0.0, 1.0)); + } } } diff --git a/packages/flutter/lib/src/cupertino/sliding_segmented_control.dart b/packages/flutter/lib/src/cupertino/sliding_segmented_control.dart index d242e474cd..ab3be16440 100644 --- a/packages/flutter/lib/src/cupertino/sliding_segmented_control.dart +++ b/packages/flutter/lib/src/cupertino/sliding_segmented_control.dart @@ -534,8 +534,9 @@ class _SegmentedControlState extends State extends State extends RenderBox } _thumbScale = value; - if (state.highlighted != null) + if (state.highlighted != null) { markNeedsPaint(); + } } int? get highlightedIndex => _highlightedIndex; @@ -995,8 +999,9 @@ class _RenderSegmentedControl extends RenderBox Rect? moveThumbRectInBound(Rect? thumbRect, List children) { assert(hasSize); assert(children.length >= 2); - if (thumbRect == null) + if (thumbRect == null) { return null; + } final Offset firstChildOffset = (children.first.parentData! as _SegmentedControlContainerBoxParentData).offset; final double leftMost = firstChildOffset.dx; diff --git a/packages/flutter/lib/src/cupertino/switch.dart b/packages/flutter/lib/src/cupertino/switch.dart index 992baaffc1..f690252872 100644 --- a/packages/flutter/lib/src/cupertino/switch.dart +++ b/packages/flutter/lib/src/cupertino/switch.dart @@ -206,8 +206,9 @@ class _CupertinoSwitchState extends State with TickerProviderSt super.didUpdateWidget(oldWidget); _drag.dragStartBehavior = widget.dragStartBehavior; - if (needsPositionAnimation || oldWidget.value != widget.value) + if (needsPositionAnimation || oldWidget.value != widget.value) { _resumePositionAnimation(isLinear: needsPositionAnimation); + } } // `isLinear` must be true if the position animation is trying to move the @@ -221,15 +222,17 @@ class _CupertinoSwitchState extends State with TickerProviderSt position ..curve = isLinear ? Curves.linear : Curves.ease ..reverseCurve = isLinear ? Curves.linear : Curves.ease.flipped; - if (widget.value) + if (widget.value) { _positionController.forward(); - else + } else { _positionController.reverse(); + } } void _handleTapDown(TapDownDetails details) { - if (isInteractive) + if (isInteractive) { needsPositionAnimation = false; + } _reactionController.forward(); } @@ -248,8 +251,9 @@ class _CupertinoSwitchState extends State with TickerProviderSt } void _handleTapCancel() { - if (isInteractive) + if (isInteractive) { _reactionController.reverse(); + } } void _handleDragStart(DragStartDetails details) { @@ -281,8 +285,9 @@ class _CupertinoSwitchState extends State with TickerProviderSt // Deferring the animation to the next build phase. setState(() { needsPositionAnimation = true; }); // Call onChanged when the user's intent to change value is clear. - if (position.value >= 0.5 != widget.value) + if (position.value >= 0.5 != widget.value) { widget.onChanged!(!widget.value); + } _reactionController.reverse(); } @@ -302,8 +307,9 @@ class _CupertinoSwitchState extends State with TickerProviderSt @override Widget build(BuildContext context) { - if (needsPositionAnimation) + if (needsPositionAnimation) { _resumePositionAnimation(); + } return MouseRegion( cursor: isInteractive && kIsWeb ? SystemMouseCursors.click : MouseCursor.defer, child: Opacity( @@ -423,8 +429,9 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox { bool _value; set value(bool value) { assert(value != null); - if (value == _value) + if (value == _value) { return; + } _value = value; markNeedsSemanticsUpdate(); } @@ -433,8 +440,9 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox { Color _activeColor; set activeColor(Color value) { assert(value != null); - if (value == _activeColor) + if (value == _activeColor) { return; + } _activeColor = value; markNeedsPaint(); } @@ -443,8 +451,9 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox { Color _trackColor; set trackColor(Color value) { assert(value != null); - if (value == _trackColor) + if (value == _trackColor) { return; + } _trackColor = value; markNeedsPaint(); } @@ -453,8 +462,9 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox { CupertinoThumbPainter _thumbPainter; set thumbColor(Color value) { assert(value != null); - if (value == thumbColor) + if (value == thumbColor) { return; + } _thumbPainter = CupertinoThumbPainter.switchThumb(color: value); markNeedsPaint(); } @@ -462,8 +472,9 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox { ValueChanged? get onChanged => _onChanged; ValueChanged? _onChanged; set onChanged(ValueChanged? value) { - if (value == _onChanged) + if (value == _onChanged) { return; + } final bool wasInteractive = isInteractive; _onChanged = value; if (wasInteractive != isInteractive) { @@ -476,8 +487,9 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox { TextDirection _textDirection; set textDirection(TextDirection value) { assert(value != null); - if (_textDirection == value) + if (_textDirection == value) { return; + } _textDirection = value; markNeedsPaint(); } @@ -500,8 +512,9 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox { void describeSemanticsConfiguration(SemanticsConfiguration config) { super.describeSemanticsConfiguration(config); - if (isInteractive) + if (isInteractive) { config.onTap = _state._handleTap; + } config.isEnabled = isInteractive; config.isToggled = _value; diff --git a/packages/flutter/lib/src/cupertino/tab_view.dart b/packages/flutter/lib/src/cupertino/tab_view.dart index b4f217836e..3d5948a9c1 100644 --- a/packages/flutter/lib/src/cupertino/tab_view.dart +++ b/packages/flutter/lib/src/cupertino/tab_view.dart @@ -190,8 +190,9 @@ class _CupertinoTabViewState extends State { settings: settings, ); } - if (widget.onGenerateRoute != null) + if (widget.onGenerateRoute != null) { return widget.onGenerateRoute!(settings); + } return null; } diff --git a/packages/flutter/lib/src/cupertino/text_field.dart b/packages/flutter/lib/src/cupertino/text_field.dart index a8bc08b1c8..9a5e69dc7a 100644 --- a/packages/flutter/lib/src/cupertino/text_field.dart +++ b/packages/flutter/lib/src/cupertino/text_field.dart @@ -930,21 +930,26 @@ class _CupertinoTextFieldState extends State with Restoratio bool _shouldShowSelectionHandles(SelectionChangedCause? cause) { // When the text field is activated by something that doesn't trigger the // selection overlay, we shouldn't show the handles either. - if (!_selectionGestureDetectorBuilder.shouldShowSelectionToolbar) + if (!_selectionGestureDetectorBuilder.shouldShowSelectionToolbar) { return false; + } // On iOS, we don't show handles when the selection is collapsed. - if (_effectiveController.selection.isCollapsed) + if (_effectiveController.selection.isCollapsed) { return false; + } - if (cause == SelectionChangedCause.keyboard) + if (cause == SelectionChangedCause.keyboard) { return false; + } - if (cause == SelectionChangedCause.scribble) + if (cause == SelectionChangedCause.scribble) { return true; + } - if (_effectiveController.text.isNotEmpty) + if (_effectiveController.text.isNotEmpty) { return true; + } return false; } @@ -1088,8 +1093,9 @@ class _CupertinoTextFieldState extends State with Restoratio // Also call onChanged when the clear button is tapped. final bool textChanged = _effectiveController.text.isNotEmpty; _effectiveController.clear(); - if (widget.onChanged != null && textChanged) + if (widget.onChanged != null && textChanged) { widget.onChanged!(_effectiveController.text); + } } : null, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 6.0), diff --git a/packages/flutter/lib/src/cupertino/text_selection_toolbar.dart b/packages/flutter/lib/src/cupertino/text_selection_toolbar.dart index bb2c24c616..ebb968e957 100644 --- a/packages/flutter/lib/src/cupertino/text_selection_toolbar.dart +++ b/packages/flutter/lib/src/cupertino/text_selection_toolbar.dart @@ -580,8 +580,9 @@ class _CupertinoTextSelectionToolbarItemsElement extends RenderObjectElement { void visitChildren(ElementVisitor visitor) { slotToChild.values.forEach(visitor); for (final Element child in _children) { - if (!_forgottenChildren.contains(child)) + if (!_forgottenChildren.contains(child)) { visitor(child); + } } } diff --git a/packages/flutter/lib/src/cupertino/thumb_painter.dart b/packages/flutter/lib/src/cupertino/thumb_painter.dart index c5a56c1c03..3c7d696d06 100644 --- a/packages/flutter/lib/src/cupertino/thumb_painter.dart +++ b/packages/flutter/lib/src/cupertino/thumb_painter.dart @@ -79,8 +79,9 @@ class CupertinoThumbPainter { Radius.circular(rect.shortestSide / 2.0), ); - for (final BoxShadow shadow in shadows) + for (final BoxShadow shadow in shadows) { canvas.drawRRect(rrect.shift(shadow.offset), shadow.toPaint()); + } canvas.drawRRect( rrect.inflate(0.5), diff --git a/packages/flutter/test/cupertino/nav_bar_transition_test.dart b/packages/flutter/test/cupertino/nav_bar_transition_test.dart index 67cdfaf921..dc4dbebc38 100644 --- a/packages/flutter/test/cupertino/nav_bar_transition_test.dart +++ b/packages/flutter/test/cupertino/nav_bar_transition_test.dart @@ -1016,8 +1016,9 @@ void main() { await tester.pump(const Duration(milliseconds: 1)); expect(flying(tester, find.text('Page 2')), findsOneWidget); final Size size = tester.getSize(flying(tester, find.text('Page 2'))); - if (previousSize != null) + if (previousSize != null) { expect(size, previousSize); + } previousSize = size; } }); diff --git a/packages/flutter/test/cupertino/route_test.dart b/packages/flutter/test/cupertino/route_test.dart index a60a7b6c12..8e5d4345bf 100644 --- a/packages/flutter/test/cupertino/route_test.dart +++ b/packages/flutter/test/cupertino/route_test.dart @@ -981,20 +981,24 @@ void main() { testWidgets('when route is not fullscreenDialog, it has a _CupertinoEdgeShadowDecoration', (WidgetTester tester) async { PaintPattern paintsShadowRect({required double dx, required Color color}) { return paints..everything((Symbol methodName, List arguments) { - if (methodName != #drawRect) + if (methodName != #drawRect) { return true; + } final Rect rect = arguments[0] as Rect; final Color paintColor = (arguments[1] as Paint).color; - if (rect.top != 0 || rect.width != 1.0 || rect.height != 600) - // _CupertinoEdgeShadowDecoration draws the shadows with a series of - // differently colored 1px-wide rects. Skip rects that aren't being - // drawn by the _CupertinoEdgeShadowDecoration. + // _CupertinoEdgeShadowDecoration draws the shadows with a series of + // differently colored 1px-wide rects. Skip rects that aren't being + // drawn by the _CupertinoEdgeShadowDecoration. + if (rect.top != 0 || rect.width != 1.0 || rect.height != 600) { return true; - if ((rect.left - dx).abs() >= 1) - // Skip calls for rects until the one with the given position offset + } + // Skip calls for rects until the one with the given position offset + if ((rect.left - dx).abs() >= 1) { return true; - if (paintColor.value == color.value) + } + if (paintColor.value == color.value) { return true; + } throw ''' For a rect with an expected left-side position: $dx (drawn at ${rect.left}): Expected a rect with color: $color, @@ -1067,14 +1071,16 @@ void main() { testWidgets('when route is fullscreenDialog, it has no visible _CupertinoEdgeShadowDecoration', (WidgetTester tester) async { PaintPattern paintsNoShadows() { return paints..everything((Symbol methodName, List arguments) { - if (methodName != #drawRect) + if (methodName != #drawRect) { return true; + } final Rect rect = arguments[0] as Rect; // _CupertinoEdgeShadowDecoration draws the shadows with a series of // differently colored 1px rects. Skip all rects not drawn by a // _CupertinoEdgeShadowDecoration. - if (rect.width != 1.0) + if (rect.width != 1.0) { return true; + } throw ''' Expected: no rects with a width of 1px. Found: $rect. diff --git a/packages/flutter/test/cupertino/sliding_segmented_control_test.dart b/packages/flutter/test/cupertino/sliding_segmented_control_test.dart index f676563dcd..08bc092057 100644 --- a/packages/flutter/test/cupertino/sliding_segmented_control_test.dart +++ b/packages/flutter/test/cupertino/sliding_segmented_control_test.dart @@ -25,8 +25,9 @@ Rect currentUnscaledThumbRect(WidgetTester tester, { bool useGlobalCoordinate = // Using dynamic to access private class in test. // ignore: avoid_dynamic_calls final Rect local = renderSegmentedControl.currentThumbRect as Rect; - if (!useGlobalCoordinate) + if (!useGlobalCoordinate) { return local; + } final RenderBox segmentedControl = renderSegmentedControl as RenderBox; return local.shift(segmentedControl.localToGlobal(Offset.zero));