diff --git a/packages/flutter/lib/src/material/animated_icons/animated_icons.dart b/packages/flutter/lib/src/material/animated_icons/animated_icons.dart index 272cc75c8d0b..42765fcc067c 100644 --- a/packages/flutter/lib/src/material/animated_icons/animated_icons.dart +++ b/packages/flutter/lib/src/material/animated_icons/animated_icons.dart @@ -110,8 +110,9 @@ class AnimatedIcon extends StatelessWidget { final TextDirection textDirection = this.textDirection ?? Directionality.of(context); final double iconOpacity = iconTheme.opacity!; Color iconColor = color ?? iconTheme.color!; - if (iconOpacity != 1.0) + if (iconOpacity != 1.0) { iconColor = iconColor.withOpacity(iconColor.opacity * iconOpacity); + } return Semantics( label: semanticLabel, child: CustomPaint( @@ -162,8 +163,9 @@ class _AnimatedIconPainter extends CustomPainter { canvas.scale(scale, scale); final double clampedProgress = clampDouble(progress.value, 0.0, 1.0); - for (final _PathFrames path in paths) + for (final _PathFrames path in paths) { path.paint(canvas, color, uiPathFactory, clampedProgress); + } } @@ -203,8 +205,9 @@ class _PathFrames { ..style = PaintingStyle.fill ..color = color.withOpacity(color.opacity * opacity); final ui.Path path = uiPathFactory(); - for (final _PathCommand command in commands) + for (final _PathCommand command in commands) { command.apply(path, progress); + } canvas.drawPath(path, paint); } } @@ -291,8 +294,9 @@ class _PathClose extends _PathCommand { T _interpolate(List values, double progress, _Interpolator interpolator) { assert(progress <= 1.0); assert(progress >= 0.0); - if (values.length == 1) + if (values.length == 1) { return values[0]; + } final double targetIdx = lerpDouble(0, values.length -1, progress)!; final int lowIdx = targetIdx.floor(); final int highIdx = targetIdx.ceil(); diff --git a/packages/flutter/lib/src/material/app.dart b/packages/flutter/lib/src/material/app.dart index 9cd1719ed40c..dd8a4a07bff6 100644 --- a/packages/flutter/lib/src/material/app.dart +++ b/packages/flutter/lib/src/material/app.dart @@ -1000,8 +1000,9 @@ class _MaterialAppState extends State { result = Focus( canRequestFocus: false, onKey: (FocusNode node, RawKeyEvent event) { - if (event is! RawKeyDownEvent || event.logicalKey != LogicalKeyboardKey.escape) + if (event is! RawKeyDownEvent || event.logicalKey != LogicalKeyboardKey.escape) { return KeyEventResult.ignored; + } return Tooltip.dismissAllToolTips() ? KeyEventResult.handled : KeyEventResult.ignored; }, child: result, diff --git a/packages/flutter/lib/src/material/app_bar.dart b/packages/flutter/lib/src/material/app_bar.dart index 569acfe8830e..92986d542bdd 100644 --- a/packages/flutter/lib/src/material/app_bar.dart +++ b/packages/flutter/lib/src/material/app_bar.dart @@ -803,11 +803,13 @@ class _AppBarState extends State { @override void didChangeDependencies() { super.didChangeDependencies(); - if (_scrollNotificationObserver != null) + if (_scrollNotificationObserver != null) { _scrollNotificationObserver!.removeListener(_handleScrollNotification); + } _scrollNotificationObserver = ScrollNotificationObserver.of(context); - if (_scrollNotificationObserver != null) + if (_scrollNotificationObserver != null) { _scrollNotificationObserver!.addListener(_handleScrollNotification); + } } @override @@ -949,10 +951,12 @@ class _AppBarState extends State { if (widget.toolbarOpacity != 1.0) { final double opacity = const Interval(0.25, 1.0, curve: Curves.fastOutSlowIn).transform(widget.toolbarOpacity); - if (titleTextStyle?.color != null) + if (titleTextStyle?.color != null) { titleTextStyle = titleTextStyle!.copyWith(color: titleTextStyle.color!.withOpacity(opacity)); - if (toolbarTextStyle?.color != null) + } + if (toolbarTextStyle?.color != null) { toolbarTextStyle = toolbarTextStyle!.copyWith(color: toolbarTextStyle.color!.withOpacity(opacity)); + } overallIconTheme = overallIconTheme.copyWith( opacity: opacity * (overallIconTheme.opacity ?? 1.0), ); @@ -2050,10 +2054,12 @@ class _SliverAppBarState extends State with TickerProviderStateMix @override void didUpdateWidget(SliverAppBar oldWidget) { super.didUpdateWidget(oldWidget); - if (widget.snap != oldWidget.snap || widget.floating != oldWidget.floating) + if (widget.snap != oldWidget.snap || widget.floating != oldWidget.floating) { _updateSnapConfiguration(); - if (widget.stretch != oldWidget.stretch) + } + if (widget.stretch != oldWidget.stretch) { _updateStretchConfiguration(); + } } @override diff --git a/packages/flutter/lib/src/material/app_bar_theme.dart b/packages/flutter/lib/src/material/app_bar_theme.dart index 5eb0ff430490..a7e81a13440f 100644 --- a/packages/flutter/lib/src/material/app_bar_theme.dart +++ b/packages/flutter/lib/src/material/app_bar_theme.dart @@ -353,10 +353,12 @@ class AppBarTheme 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 AppBarTheme && other.brightness == brightness && other.backgroundColor == backgroundColor diff --git a/packages/flutter/lib/src/material/arc.dart b/packages/flutter/lib/src/material/arc.dart index c76d933f96bb..384a17e52473 100644 --- a/packages/flutter/lib/src/material/arc.dart +++ b/packages/flutter/lib/src/material/arc.dart @@ -92,10 +92,12 @@ class MaterialPointArcTween extends Tween { /// The center of the circular arc, null if [begin] and [end] are horizontally or /// vertically aligned, or if either is null. Offset? get center { - if (begin == null || end == null) + if (begin == null || end == null) { return null; - if (_dirty) + } + if (_dirty) { _initialize(); + } return _center; } Offset? _center; @@ -103,10 +105,12 @@ class MaterialPointArcTween extends Tween { /// The radius of the circular arc, null if [begin] and [end] are horizontally or /// vertically aligned, or if either is null. double? get radius { - if (begin == null || end == null) + if (begin == null || end == null) { return null; - if (_dirty) + } + if (_dirty) { _initialize(); + } return _radius; } double? _radius; @@ -117,10 +121,12 @@ class MaterialPointArcTween extends Tween { /// This will be null if [begin] and [end] are horizontally or vertically /// aligned, or if either is null. double? get beginAngle { - if (begin == null || end == null) + if (begin == null || end == null) { return null; - if (_dirty) + } + if (_dirty) { _initialize(); + } return _beginAngle; } double? _beginAngle; @@ -131,10 +137,12 @@ class MaterialPointArcTween extends Tween { /// This will be null if [begin] and [end] are horizontally or vertically /// aligned, or if either is null. double? get endAngle { - if (begin == null || end == null) + if (begin == null || end == null) { return null; - if (_dirty) + } + if (_dirty) { _initialize(); + } return _beginAngle; } double? _endAngle; @@ -157,14 +165,18 @@ class MaterialPointArcTween extends Tween { @override Offset lerp(double t) { - if (_dirty) + if (_dirty) { _initialize(); - if (t == 0.0) + } + if (t == 0.0) { return begin!; - if (t == 1.0) + } + if (t == 1.0) { return end!; - if (_beginAngle == null || _endAngle == null) + } + if (_beginAngle == null || _endAngle == null) { return Offset.lerp(begin, end, t)!; + } final double angle = lerpDouble(_beginAngle, _endAngle, t)!; final double x = math.cos(angle) * _radius!; final double y = math.sin(angle) * _radius!; @@ -279,10 +291,12 @@ class MaterialRectArcTween extends RectTween { /// The path of the corresponding [begin], [end] rectangle corners that lead /// the animation. MaterialPointArcTween? get beginArc { - if (begin == null) + if (begin == null) { return null; - if (_dirty) + } + if (_dirty) { _initialize(); + } return _beginArc; } late MaterialPointArcTween _beginArc; @@ -290,10 +304,12 @@ class MaterialRectArcTween extends RectTween { /// The path of the corresponding [begin], [end] rectangle corners that trail /// the animation. MaterialPointArcTween? get endArc { - if (end == null) + if (end == null) { return null; - if (_dirty) + } + if (_dirty) { _initialize(); + } return _endArc; } late MaterialPointArcTween _endArc; @@ -316,12 +332,15 @@ class MaterialRectArcTween extends RectTween { @override Rect lerp(double t) { - if (_dirty) + if (_dirty) { _initialize(); - if (t == 0.0) + } + if (t == 0.0) { return begin!; - if (t == 1.0) + } + if (t == 1.0) { return end!; + } return Rect.fromPoints(_beginArc.lerp(t), _endArc.lerp(t)); } @@ -373,10 +392,12 @@ class MaterialRectCenterArcTween extends RectTween { /// If [begin] and [end] are non-null, returns a tween that interpolates along /// a circular arc between [begin]'s [Rect.center] and [end]'s [Rect.center]. MaterialPointArcTween? get centerArc { - if (begin == null || end == null) + if (begin == null || end == null) { return null; - if (_dirty) + } + if (_dirty) { _initialize(); + } return _centerArc; } late MaterialPointArcTween _centerArc; @@ -399,12 +420,15 @@ class MaterialRectCenterArcTween extends RectTween { @override Rect lerp(double t) { - if (_dirty) + if (_dirty) { _initialize(); - if (t == 0.0) + } + if (t == 0.0) { return begin!; - if (t == 1.0) + } + if (t == 1.0) { return end!; + } final Offset center = _centerArc.lerp(t); final double width = lerpDouble(begin!.width, end!.width, t)!; final double height = lerpDouble(begin!.height, end!.height, t)!; diff --git a/packages/flutter/lib/src/material/banner.dart b/packages/flutter/lib/src/material/banner.dart index c1741b4d1532..c5959862f28e 100644 --- a/packages/flutter/lib/src/material/banner.dart +++ b/packages/flutter/lib/src/material/banner.dart @@ -332,8 +332,9 @@ class _MaterialBannerState extends State { ); // This provides a static banner for backwards compatibility. - if (widget.animation == null) + if (widget.animation == null) { return materialBanner; + } materialBanner = SafeArea( child: materialBanner, diff --git a/packages/flutter/lib/src/material/banner_theme.dart b/packages/flutter/lib/src/material/banner_theme.dart index 9f65d0574bc2..e114a4a7fe93 100644 --- a/packages/flutter/lib/src/material/banner_theme.dart +++ b/packages/flutter/lib/src/material/banner_theme.dart @@ -101,10 +101,12 @@ class MaterialBannerThemeData 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 MaterialBannerThemeData && other.backgroundColor == backgroundColor && other.contentTextStyle == contentTextStyle diff --git a/packages/flutter/lib/src/material/bottom_app_bar.dart b/packages/flutter/lib/src/material/bottom_app_bar.dart index f1b958bc84d4..150732455ec7 100644 --- a/packages/flutter/lib/src/material/bottom_app_bar.dart +++ b/packages/flutter/lib/src/material/bottom_app_bar.dart @@ -180,8 +180,9 @@ class _BottomAppBarClipper extends CustomClipper { // Material widget. double get bottomNavigationBarTop { final double? bottomNavigationBarTop = geometry.value.bottomNavigationBarTop; - if (bottomNavigationBarTop != null) + if (bottomNavigationBarTop != null) { return bottomNavigationBarTop; + } final RenderBox? box = materialKey.currentContext?.findRenderObject() as RenderBox?; return box?.localToGlobal(Offset.zero).dy ?? 0; } diff --git a/packages/flutter/lib/src/material/bottom_app_bar_theme.dart b/packages/flutter/lib/src/material/bottom_app_bar_theme.dart index 5f05734a2aba..df76ca8c52ba 100644 --- a/packages/flutter/lib/src/material/bottom_app_bar_theme.dart +++ b/packages/flutter/lib/src/material/bottom_app_bar_theme.dart @@ -87,10 +87,12 @@ class BottomAppBarTheme 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 BottomAppBarTheme && other.color == color && other.elevation == elevation diff --git a/packages/flutter/lib/src/material/bottom_navigation_bar.dart b/packages/flutter/lib/src/material/bottom_navigation_bar.dart index 9f37a9952cf7..ca0c9c54b64c 100644 --- a/packages/flutter/lib/src/material/bottom_navigation_bar.dart +++ b/packages/flutter/lib/src/material/bottom_navigation_bar.dart @@ -760,10 +760,12 @@ class _BottomNavigationBarState extends State with TickerPr static final Animatable _flexTween = Tween(begin: 1.0, end: 1.5); void _resetState() { - for (final AnimationController controller in _controllers) + for (final AnimationController controller in _controllers) { controller.dispose(); - for (final _Circle circle in _circles) + } + for (final _Circle circle in _circles) { circle.dispose(); + } _circles.clear(); _controllers = List.generate(widget.items.length, (int index) { @@ -823,10 +825,12 @@ class _BottomNavigationBarState extends State with TickerPr @override void dispose() { - for (final AnimationController controller in _controllers) + for (final AnimationController controller in _controllers) { controller.dispose(); - for (final _Circle circle in _circles) + } + for (final _Circle circle in _circles) { circle.dispose(); + } super.dispose(); } @@ -882,8 +886,9 @@ class _BottomNavigationBarState extends State with TickerPr _controllers[oldWidget.currentIndex].reverse(); _controllers[widget.currentIndex].forward(); } else { - if (_backgroundColor != widget.items[widget.currentIndex].backgroundColor) + if (_backgroundColor != widget.items[widget.currentIndex].backgroundColor) { _backgroundColor = widget.items[widget.currentIndex].backgroundColor; + } } } @@ -1151,15 +1156,20 @@ class _RadialPainter extends CustomPainter { @override bool shouldRepaint(_RadialPainter oldPainter) { - if (textDirection != oldPainter.textDirection) + if (textDirection != oldPainter.textDirection) { return true; - if (circles == oldPainter.circles) + } + if (circles == oldPainter.circles) { return false; - if (circles.length != oldPainter.circles.length) + } + if (circles.length != oldPainter.circles.length) { return true; - for (int i = 0; i < circles.length; i += 1) - if (circles[i] != oldPainter.circles[i]) + } + for (int i = 0; i < circles.length; i += 1) { + if (circles[i] != oldPainter.circles[i]) { return true; + } + } return false; } diff --git a/packages/flutter/lib/src/material/bottom_navigation_bar_theme.dart b/packages/flutter/lib/src/material/bottom_navigation_bar_theme.dart index 8746f24aa288..4f83db84f71c 100644 --- a/packages/flutter/lib/src/material/bottom_navigation_bar_theme.dart +++ b/packages/flutter/lib/src/material/bottom_navigation_bar_theme.dart @@ -210,10 +210,12 @@ class BottomNavigationBarThemeData 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 BottomNavigationBarThemeData && other.backgroundColor == backgroundColor && other.elevation == elevation diff --git a/packages/flutter/lib/src/material/bottom_sheet.dart b/packages/flutter/lib/src/material/bottom_sheet.dart index 33c72093d472..4da220fdcb73 100644 --- a/packages/flutter/lib/src/material/bottom_sheet.dart +++ b/packages/flutter/lib/src/material/bottom_sheet.dart @@ -219,8 +219,9 @@ class _BottomSheetState extends State { "'BottomSheet.animationController' can not be null when 'BottomSheet.enableDrag' is true. " "Use 'BottomSheet.createAnimationController' to create one, or provide another AnimationController.", ); - if (_dismissUnderway) + if (_dismissUnderway) { return; + } widget.animationController!.value -= details.primaryDelta! / _childHeight; } @@ -230,8 +231,9 @@ class _BottomSheetState extends State { "'BottomSheet.animationController' can not be null when 'BottomSheet.enableDrag' is true. " "Use 'BottomSheet.createAnimationController' to create one, or provide another AnimationController.", ); - if (_dismissUnderway) + if (_dismissUnderway) { return; + } bool isClosing = false; if (details.velocity.pixelsPerSecond.dy > _minFlingVelocity) { final double flingVelocity = -details.velocity.pixelsPerSecond.dy / _childHeight; @@ -242,8 +244,9 @@ class _BottomSheetState extends State { isClosing = true; } } else if (widget.animationController!.value < _closeProgressThreshold) { - if (widget.animationController!.value > 0.0) + if (widget.animationController!.value > 0.0) { widget.animationController!.fling(velocity: -1.0); + } isClosing = true; } else { widget.animationController!.forward(); diff --git a/packages/flutter/lib/src/material/bottom_sheet_theme.dart b/packages/flutter/lib/src/material/bottom_sheet_theme.dart index b8bdc5a61f43..2304d28faf7c 100644 --- a/packages/flutter/lib/src/material/bottom_sheet_theme.dart +++ b/packages/flutter/lib/src/material/bottom_sheet_theme.dart @@ -102,8 +102,9 @@ class BottomSheetThemeData with Diagnosticable { /// {@macro dart.ui.shadow.lerp} static BottomSheetThemeData? lerp(BottomSheetThemeData? a, BottomSheetThemeData? b, double t) { assert(t != null); - if (a == null && b == null) + if (a == null && b == null) { return null; + } return BottomSheetThemeData( backgroundColor: Color.lerp(a?.backgroundColor, b?.backgroundColor, t), elevation: lerpDouble(a?.elevation, b?.elevation, t), @@ -128,10 +129,12 @@ class BottomSheetThemeData 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 BottomSheetThemeData && other.backgroundColor == backgroundColor && other.elevation == elevation diff --git a/packages/flutter/lib/src/material/button.dart b/packages/flutter/lib/src/material/button.dart index dcc6ee04be03..9ee96c048d17 100644 --- a/packages/flutter/lib/src/material/button.dart +++ b/packages/flutter/lib/src/material/button.dart @@ -467,37 +467,42 @@ class _RenderInputPadding extends RenderShiftedBox { Size get minSize => _minSize; Size _minSize; set minSize(Size value) { - if (_minSize == value) + if (_minSize == value) { return; + } _minSize = value; markNeedsLayout(); } @override double computeMinIntrinsicWidth(double height) { - if (child != null) + if (child != null) { return math.max(child!.getMinIntrinsicWidth(height), minSize.width); + } return 0.0; } @override double computeMinIntrinsicHeight(double width) { - if (child != null) + if (child != null) { return math.max(child!.getMinIntrinsicHeight(width), minSize.height); + } return 0.0; } @override double computeMaxIntrinsicWidth(double height) { - if (child != null) + if (child != null) { return math.max(child!.getMaxIntrinsicWidth(height), minSize.width); + } return 0.0; } @override double computeMaxIntrinsicHeight(double width) { - if (child != null) + if (child != null) { return math.max(child!.getMaxIntrinsicHeight(width), minSize.height); + } return 0.0; } diff --git a/packages/flutter/lib/src/material/button_bar.dart b/packages/flutter/lib/src/material/button_bar.dart index cfe54c413d9f..3e48ba914fbb 100644 --- a/packages/flutter/lib/src/material/button_bar.dart +++ b/packages/flutter/lib/src/material/button_bar.dart @@ -308,8 +308,9 @@ class _RenderButtonBarRow extends RenderFlex { @override BoxConstraints get constraints { - if (_hasCheckedLayoutWidth) + if (_hasCheckedLayoutWidth) { return super.constraints; + } return super.constraints.copyWith(maxWidth: double.infinity); } @@ -326,8 +327,9 @@ class _RenderButtonBarRow extends RenderFlex { final Size childSize = child.getDryLayout(childConstraints); currentHeight += childSize.height; child = childAfter(child); - if (overflowButtonSpacing != null && child != null) + if (overflowButtonSpacing != null && child != null) { currentHeight += overflowButtonSpacing!; + } } return constraints.constrain(Size(constraints.maxWidth, currentHeight)); } @@ -420,8 +422,9 @@ class _RenderButtonBarRow extends RenderFlex { break; } - if (overflowButtonSpacing != null && child != null) + if (overflowButtonSpacing != null && child != null) { currentHeight += overflowButtonSpacing!; + } } size = constraints.constrain(Size(constraints.maxWidth, currentHeight)); } diff --git a/packages/flutter/lib/src/material/button_bar_theme.dart b/packages/flutter/lib/src/material/button_bar_theme.dart index 04e7642e4b2b..0b61682d72d0 100644 --- a/packages/flutter/lib/src/material/button_bar_theme.dart +++ b/packages/flutter/lib/src/material/button_bar_theme.dart @@ -144,8 +144,9 @@ class ButtonBarThemeData with Diagnosticable { /// {@macro dart.ui.shadow.lerp} static ButtonBarThemeData? lerp(ButtonBarThemeData? a, ButtonBarThemeData? b, double t) { assert(t != null); - if (a == null && b == null) + if (a == null && b == null) { return null; + } return ButtonBarThemeData( alignment: t < 0.5 ? a?.alignment : b?.alignment, mainAxisSize: t < 0.5 ? a?.mainAxisSize : b?.mainAxisSize, @@ -174,10 +175,12 @@ class ButtonBarThemeData 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 ButtonBarThemeData && other.alignment == alignment && other.mainAxisSize == mainAxisSize diff --git a/packages/flutter/lib/src/material/button_style.dart b/packages/flutter/lib/src/material/button_style.dart index f9b38983ff52..739d72b107dc 100644 --- a/packages/flutter/lib/src/material/button_style.dart +++ b/packages/flutter/lib/src/material/button_style.dart @@ -340,8 +340,9 @@ class ButtonStyle with Diagnosticable { /// In other words, [style] is used to fill in unspecified (null) fields /// this ButtonStyle. ButtonStyle merge(ButtonStyle? style) { - if (style == null) + if (style == null) { return this; + } return copyWith( textStyle: textStyle ?? style.textStyle, backgroundColor: backgroundColor ?? style.backgroundColor, @@ -392,10 +393,12 @@ class ButtonStyle 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 ButtonStyle && other.textStyle == textStyle && other.backgroundColor == backgroundColor @@ -446,8 +449,9 @@ class ButtonStyle with Diagnosticable { /// Linearly interpolate between two [ButtonStyle]s. static ButtonStyle? lerp(ButtonStyle? a, ButtonStyle? b, double t) { assert (t != null); - if (a == null && b == null) + if (a == null && b == null) { return null; + } return ButtonStyle( textStyle: _lerpProperties(a?.textStyle, b?.textStyle, t, TextStyle.lerp), backgroundColor: _lerpProperties(a?.backgroundColor, b?.backgroundColor, t, Color.lerp), @@ -474,22 +478,25 @@ class ButtonStyle with Diagnosticable { static MaterialStateProperty? _lerpProperties(MaterialStateProperty? a, MaterialStateProperty? b, double t, T? Function(T?, T?, double) lerpFunction ) { // Avoid creating a _LerpProperties object for a common case. - if (a == null && b == null) + if (a == null && b == null) { return null; + } return _LerpProperties(a, b, t, lerpFunction); } // Special case because BorderSide.lerp() doesn't support null arguments static MaterialStateProperty? _lerpSides(MaterialStateProperty? a, MaterialStateProperty? b, double t) { - if (a == null && b == null) + if (a == null && b == null) { return null; + } return _LerpSides(a, b, t); } // TODO(hansmuller): OutlinedBorder needs a lerp method - https://github.com/flutter/flutter/issues/60555. static MaterialStateProperty? _lerpShapes(MaterialStateProperty? a, MaterialStateProperty? b, double t) { - if (a == null && b == null) + if (a == null && b == null) { return null; + } return _LerpShapes(a, b, t); } } @@ -521,12 +528,15 @@ class _LerpSides implements MaterialStateProperty { BorderSide? resolve(Set states) { final BorderSide? resolvedA = a?.resolve(states); final BorderSide? resolvedB = b?.resolve(states); - if (resolvedA == null && resolvedB == null) + if (resolvedA == null && resolvedB == null) { return null; - if (resolvedA == null) + } + if (resolvedA == null) { return BorderSide.lerp(BorderSide(width: 0, color: resolvedB!.color.withAlpha(0)), resolvedB, t); - if (resolvedB == null) + } + if (resolvedB == null) { return BorderSide.lerp(resolvedA, BorderSide(width: 0, color: resolvedA.color.withAlpha(0)), t); + } return BorderSide.lerp(resolvedA, resolvedB, t); } } diff --git a/packages/flutter/lib/src/material/button_style_button.dart b/packages/flutter/lib/src/material/button_style_button.dart index 7cc021538d95..097aa3c2f4eb 100644 --- a/packages/flutter/lib/src/material/button_style_button.dart +++ b/packages/flutter/lib/src/material/button_style_button.dart @@ -453,37 +453,42 @@ class _RenderInputPadding extends RenderShiftedBox { Size get minSize => _minSize; Size _minSize; set minSize(Size value) { - if (_minSize == value) + if (_minSize == value) { return; + } _minSize = value; markNeedsLayout(); } @override double computeMinIntrinsicWidth(double height) { - if (child != null) + if (child != null) { return math.max(child!.getMinIntrinsicWidth(height), minSize.width); + } return 0.0; } @override double computeMinIntrinsicHeight(double width) { - if (child != null) + if (child != null) { return math.max(child!.getMinIntrinsicHeight(width), minSize.height); + } return 0.0; } @override double computeMaxIntrinsicWidth(double height) { - if (child != null) + if (child != null) { return math.max(child!.getMaxIntrinsicWidth(height), minSize.width); + } return 0.0; } @override double computeMaxIntrinsicHeight(double width) { - if (child != null) + if (child != null) { return math.max(child!.getMaxIntrinsicHeight(width), minSize.height); + } return 0.0; } diff --git a/packages/flutter/lib/src/material/button_theme.dart b/packages/flutter/lib/src/material/button_theme.dart index 6e90139e4788..b35b38212e79 100644 --- a/packages/flutter/lib/src/material/button_theme.dart +++ b/packages/flutter/lib/src/material/button_theme.dart @@ -257,8 +257,9 @@ class ButtonThemeData with Diagnosticable { /// * [getPadding], which is used to calculate padding for the [button]'s /// child (typically the button's label). EdgeInsetsGeometry get padding { - if (_padding != null) + if (_padding != null) { return _padding!; + } switch (textTheme) { case ButtonTextTheme.normal: case ButtonTextTheme.accent: @@ -284,8 +285,9 @@ class ButtonThemeData with Diagnosticable { /// * [getShape], which is used to calculate the shape of the [button]'s /// [Material]. ShapeBorder get shape { - if (_shape != null) + if (_shape != null) { return _shape!; + } switch (textTheme) { case ButtonTextTheme.normal: case ButtonTextTheme.accent: @@ -460,14 +462,17 @@ class ButtonThemeData with Diagnosticable { /// with opacity 0.12. Color? getFillColor(MaterialButton button) { final Color? fillColor = button.enabled ? button.color : button.disabledColor; - if (fillColor != null) + if (fillColor != null) { return fillColor; + } - if (button.runtimeType == MaterialButton) + if (button.runtimeType == MaterialButton) { return null; + } - if (button.enabled && _buttonColor != null) + if (button.enabled && _buttonColor != null) { return _buttonColor; + } switch (getTextTheme(button)) { case ButtonTextTheme.normal: @@ -497,11 +502,13 @@ class ButtonThemeData with Diagnosticable { /// * [ButtonTextTheme.primary]: If [getFillColor] is dark then [Colors.white], /// otherwise [Colors.black]. Color getTextColor(MaterialButton button) { - if (!button.enabled) + if (!button.enabled) { return getDisabledTextColor(button); + } - if (button.textColor != null) + if (button.textColor != null) { return button.textColor!; + } switch (getTextTheme(button)) { case ButtonTextTheme.normal: @@ -532,8 +539,9 @@ class ButtonThemeData with Diagnosticable { /// /// Otherwise, returns [getTextColor] with an opacity of 0.12. Color getSplashColor(MaterialButton button) { - if (button.splashColor != null) + if (button.splashColor != null) { return button.splashColor!; + } if (_splashColor != null) { switch (getTextTheme(button)) { @@ -584,8 +592,9 @@ class ButtonThemeData with Diagnosticable { /// otherwise the value of [getTextColor] with opacity 0.16. /// * [ButtonTextTheme.primary], returns [Colors.transparent]. Color getHighlightColor(MaterialButton button) { - if (button.highlightColor != null) + if (button.highlightColor != null) { return button.highlightColor!; + } switch (getTextTheme(button)) { case ButtonTextTheme.normal: @@ -638,14 +647,17 @@ class ButtonThemeData with Diagnosticable { /// [getTextTheme] is [ButtonTextTheme.primary], 16.0 on the left and right /// otherwise. EdgeInsetsGeometry getPadding(MaterialButton button) { - if (button.padding != null) + if (button.padding != null) { return button.padding!; + } - if (button is MaterialButtonWithIconMixin) + if (button is MaterialButtonWithIconMixin) { return const EdgeInsetsDirectional.only(start: 12.0, end: 16.0); + } - if (_padding != null) + if (_padding != null) { return _padding!; + } switch (getTextTheme(button)) { case ButtonTextTheme.normal: @@ -729,8 +741,9 @@ class ButtonThemeData with Diagnosticable { @override bool operator ==(Object other) { - if (other.runtimeType != runtimeType) + if (other.runtimeType != runtimeType) { return false; + } return other is ButtonThemeData && other.textTheme == textTheme && other.minWidth == minWidth diff --git a/packages/flutter/lib/src/material/calendar_date_picker.dart b/packages/flutter/lib/src/material/calendar_date_picker.dart index 64f86040c286..09934e0976e1 100644 --- a/packages/flutter/lib/src/material/calendar_date_picker.dart +++ b/packages/flutter/lib/src/material/calendar_date_picker.dart @@ -576,15 +576,17 @@ class _MonthPickerState extends State<_MonthPicker> { // Can we use the preferred day in this month? if (preferredDay <= daysInMonth) { final DateTime newFocus = DateTime(month.year, month.month, preferredDay); - if (_isSelectable(newFocus)) + if (_isSelectable(newFocus)) { return newFocus; + } } // Start at the 1st and take the first selectable date. for (int day = 1; day <= daysInMonth; day++) { final DateTime newFocus = DateTime(month.year, month.month, day); - if (_isSelectable(newFocus)) + if (_isSelectable(newFocus)) { return newFocus; + } } return null; } @@ -696,10 +698,11 @@ class _MonthPickerState extends State<_MonthPicker> { int _dayDirectionOffset(TraversalDirection traversalDirection, TextDirection textDirection) { // Swap left and right if the text direction if RTL if (textDirection == TextDirection.rtl) { - if (traversalDirection == TraversalDirection.left) + if (traversalDirection == TraversalDirection.left) { traversalDirection = TraversalDirection.right; - else if (traversalDirection == TraversalDirection.right) + } else if (traversalDirection == TraversalDirection.right) { traversalDirection = TraversalDirection.left; + } } return _directionOffset[traversalDirection]!; } @@ -923,8 +926,9 @@ class _DayPickerState extends State<_DayPicker> { result.add(ExcludeSemantics( child: Center(child: Text(weekday, style: headerStyle)), )); - if (i == (localizations.firstDayOfWeekIndex - 1) % 7) + if (i == (localizations.firstDayOfWeekIndex - 1) % 7) { break; + } } return result; } diff --git a/packages/flutter/lib/src/material/card_theme.dart b/packages/flutter/lib/src/material/card_theme.dart index 8862a8e5f547..0bf223484825 100644 --- a/packages/flutter/lib/src/material/card_theme.dart +++ b/packages/flutter/lib/src/material/card_theme.dart @@ -139,10 +139,12 @@ class CardTheme 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 CardTheme && other.clipBehavior == clipBehavior && other.color == color diff --git a/packages/flutter/lib/src/material/checkbox.dart b/packages/flutter/lib/src/material/checkbox.dart index ca20f5abbebd..fe6d4f855aa4 100644 --- a/packages/flutter/lib/src/material/checkbox.dart +++ b/packages/flutter/lib/src/material/checkbox.dart @@ -392,10 +392,12 @@ class _CheckboxState extends State with TickerProviderStateMixin, Togg } BorderSide? _resolveSide(BorderSide? side) { - if (side is MaterialStateBorderSide) + if (side is MaterialStateBorderSide) { return MaterialStateProperty.resolveAs(side, states); - if (!states.contains(MaterialState.selected)) + } + if (!states.contains(MaterialState.selected)) { return side; + } return null; } @@ -647,10 +649,11 @@ class _CheckboxPainter extends ToggleablePainter { } else { _drawBox(canvas, outer, paint, side, true); final double tShrink = (t - 0.5) * 2.0; - if (previousValue == null || value == null) + if (previousValue == null || value == null) { _drawDash(canvas, origin, tShrink, strokePaint); - else + } else { _drawCheck(canvas, origin, tShrink, strokePaint); + } } } else { // Two cases: null to true, true to null final Rect outer = _outerRectAt(origin, 1.0); @@ -659,16 +662,18 @@ class _CheckboxPainter extends ToggleablePainter { _drawBox(canvas, outer, paint, side, true); if (tNormalized <= 0.5) { final double tShrink = 1.0 - tNormalized * 2.0; - if (previousValue ?? false) + if (previousValue ?? false) { _drawCheck(canvas, origin, tShrink, strokePaint); - else + } else { _drawDash(canvas, origin, tShrink, strokePaint); + } } else { final double tExpand = (tNormalized - 0.5) * 2.0; - if (value ?? false) + if (value ?? false) { _drawCheck(canvas, origin, tExpand, strokePaint); - else + } else { _drawDash(canvas, origin, tExpand, strokePaint); + } } } } diff --git a/packages/flutter/lib/src/material/checkbox_theme.dart b/packages/flutter/lib/src/material/checkbox_theme.dart index 5419b0a85fd9..360b2cf6634e 100644 --- a/packages/flutter/lib/src/material/checkbox_theme.dart +++ b/packages/flutter/lib/src/material/checkbox_theme.dart @@ -155,10 +155,12 @@ class CheckboxThemeData 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 CheckboxThemeData && other.mouseCursor == mouseCursor && other.fillColor == fillColor @@ -192,15 +194,17 @@ class CheckboxThemeData with Diagnosticable { T Function(T?, T?, double) lerpFunction, ) { // Avoid creating a _LerpProperties object for a common case. - if (a == null && b == null) + if (a == null && b == null) { return null; + } return _LerpProperties(a, b, t, lerpFunction); } // Special case because BorderSide.lerp() doesn't support null arguments static BorderSide? _lerpSides(BorderSide? a, BorderSide? b, double t) { - if (a == null && b == null) + if (a == null && b == null) { return null; + } return BorderSide.lerp(a!, b!, t); } } diff --git a/packages/flutter/lib/src/material/chip.dart b/packages/flutter/lib/src/material/chip.dart index 65922875af3a..700726259bb0 100644 --- a/packages/flutter/lib/src/material/chip.dart +++ b/packages/flutter/lib/src/material/chip.dart @@ -1296,8 +1296,9 @@ class _RenderChipRedirectingHitDetection extends RenderConstrainedBox { @override bool hitTest(BoxHitTestResult result, { required Offset position }) { - if (!size.contains(position)) + if (!size.contains(position)) { return false; + } // Only redirects hit detection which occurs above and below the render object. // In order to make this assumption true, I have removed the minimum width // constraints, since any reasonable chip would be at least that wide. diff --git a/packages/flutter/lib/src/material/chip_theme.dart b/packages/flutter/lib/src/material/chip_theme.dart index 364ea0f3b132..1cdd7c8f2c1b 100644 --- a/packages/flutter/lib/src/material/chip_theme.dart +++ b/packages/flutter/lib/src/material/chip_theme.dart @@ -459,8 +459,9 @@ class ChipThemeData with Diagnosticable { /// {@macro dart.ui.shadow.lerp} static ChipThemeData? lerp(ChipThemeData? a, ChipThemeData? b, double t) { assert(t != null); - if (a == null && b == null) + if (a == null && b == null) { return null; + } return ChipThemeData( backgroundColor: Color.lerp(a?.backgroundColor, b?.backgroundColor, t), deleteIconColor: Color.lerp(a?.deleteIconColor, b?.deleteIconColor, t), @@ -484,19 +485,23 @@ class ChipThemeData with Diagnosticable { // Special case because BorderSide.lerp() doesn't support null arguments. static BorderSide? _lerpSides(BorderSide? a, BorderSide? b, double t) { - if (a == null && b == null) + if (a == null && b == null) { return null; - if (a == null) + } + if (a == null) { return BorderSide.lerp(BorderSide(width: 0, color: b!.color.withAlpha(0)), b, t); - if (b == null) + } + if (b == null) { return BorderSide.lerp(BorderSide(width: 0, color: a.color.withAlpha(0)), a, t); + } return BorderSide.lerp(a, b, t); } // TODO(perclasson): OutlinedBorder needs a lerp method - https://github.com/flutter/flutter/issues/60555. static OutlinedBorder? _lerpShapes(OutlinedBorder? a, OutlinedBorder? b, double t) { - if (a == null && b == null) + if (a == null && b == null) { return null; + } return ShapeBorder.lerp(a, b, t) as OutlinedBorder?; } diff --git a/packages/flutter/lib/src/material/color_scheme.dart b/packages/flutter/lib/src/material/color_scheme.dart index ba449b19aa20..bceecd88ab3f 100644 --- a/packages/flutter/lib/src/material/color_scheme.dart +++ b/packages/flutter/lib/src/material/color_scheme.dart @@ -882,10 +882,12 @@ class ColorScheme 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 ColorScheme && other.brightness == brightness && other.primary == primary diff --git a/packages/flutter/lib/src/material/data_table.dart b/packages/flutter/lib/src/material/data_table.dart index 11c8ea330d61..73eb1ef53c6e 100644 --- a/packages/flutter/lib/src/material/data_table.dart +++ b/packages/flutter/lib/src/material/data_table.dart @@ -631,8 +631,9 @@ class DataTable extends StatelessWidget { for (int index = 0; index < columns.length; index += 1) { final DataColumn column = columns[index]; if (!column.numeric) { - if (result != null) + if (result != null) { return null; + } result = index; } } @@ -654,8 +655,9 @@ class DataTable extends StatelessWidget { onSelectAll!(effectiveChecked); } else { for (final DataRow row in rows) { - if (row.onSelectChanged != null && row.selected != effectiveChecked) + if (row.onSelectChanged != null && row.selected != effectiveChecked) { row.onSelectChanged!(effectiveChecked); + } } } } @@ -875,8 +877,9 @@ class DataTable extends StatelessWidget { ?? theme.dataTableTheme.dataRowColor; final MaterialStateProperty defaultRowColor = MaterialStateProperty.resolveWith( (Set states) { - if (states.contains(MaterialState.selected)) + if (states.contains(MaterialState.selected)) { return theme.colorScheme.primary.withOpacity(0.08); + } return null; }, ); @@ -1102,8 +1105,9 @@ class TableRowInkWell extends InkResponse { // TableRowInkWell's coordinate space. table.applyPaintTransform(cell, transform); final Offset? offset = MatrixUtils.getAsTranslation(transform); - if (offset != null) + if (offset != null) { return rect.shift(-offset); + } } return Rect.zero; }; @@ -1166,8 +1170,9 @@ class _SortArrowState extends State<_SortArrow> with TickerProviderStateMixin { _orientationAnimation = _orientationController.drive(_turnTween) ..addListener(_rebuild) ..addStatusListener(_resetOrientationAnimation); - if (widget.visible) + if (widget.visible) { _orientationOffset = widget.up! ? 0.0 : math.pi; + } } void _rebuild() { diff --git a/packages/flutter/lib/src/material/data_table_theme.dart b/packages/flutter/lib/src/material/data_table_theme.dart index f060c3a20aa1..69f92227aae4 100644 --- a/packages/flutter/lib/src/material/data_table_theme.dart +++ b/packages/flutter/lib/src/material/data_table_theme.dart @@ -152,10 +152,12 @@ class DataTableThemeData 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 DataTableThemeData && other.decoration == decoration && other.dataRowColor == dataRowColor @@ -188,8 +190,9 @@ class DataTableThemeData with Diagnosticable { static MaterialStateProperty? _lerpProperties(MaterialStateProperty? a, MaterialStateProperty? b, double t, T Function(T?, T?, double) lerpFunction ) { // Avoid creating a _LerpProperties object for a common case. - if (a == null && b == null) + if (a == null && b == null) { return null; + } return _LerpProperties(a, b, t, lerpFunction); } } diff --git a/packages/flutter/lib/src/material/date.dart b/packages/flutter/lib/src/material/date.dart index 2efd2c490e71..6f08f7dc4c95 100644 --- a/packages/flutter/lib/src/material/date.dart +++ b/packages/flutter/lib/src/material/date.dart @@ -231,8 +231,9 @@ class DateTimeRange { @override bool operator ==(Object other) { - if (other.runtimeType != runtimeType) + if (other.runtimeType != runtimeType) { return false; + } return other is DateTimeRange && other.start == start && other.end == end; diff --git a/packages/flutter/lib/src/material/date_picker.dart b/packages/flutter/lib/src/material/date_picker.dart index b8264148172f..69629b9827c1 100644 --- a/packages/flutter/lib/src/material/date_picker.dart +++ b/packages/flutter/lib/src/material/date_picker.dart @@ -1887,10 +1887,11 @@ class _CalendarKeyboardNavigatorState extends State<_CalendarKeyboardNavigator> int _dayDirectionOffset(TraversalDirection traversalDirection, TextDirection textDirection) { // Swap left and right if the text direction if RTL if (textDirection == TextDirection.rtl) { - if (traversalDirection == TraversalDirection.left) + if (traversalDirection == TraversalDirection.left) { traversalDirection = TraversalDirection.right; - else if (traversalDirection == TraversalDirection.right) + } else if (traversalDirection == TraversalDirection.right) { traversalDirection = TraversalDirection.left; + } } return _directionOffset[traversalDirection]!; } @@ -1971,8 +1972,9 @@ class _DayHeaders extends StatelessWidget { result.add(ExcludeSemantics( child: Center(child: Text(weekday, style: headerStyle)), )); - if (i == (localizations.firstDayOfWeekIndex - 1) % 7) + if (i == (localizations.firstDayOfWeekIndex - 1) % 7) { break; + } } return result; } @@ -2385,8 +2387,9 @@ class _MonthItemState extends State<_MonthItem> { // 1-based day of month, e.g. 1-31 for January, and 1-29 for February on // a leap year. final int day = i - dayOffset + 1; - if (day > daysInMonth) + if (day > daysInMonth) { break; + } if (day < 1) { dayItems.add(Container()); } else { diff --git a/packages/flutter/lib/src/material/dialog.dart b/packages/flutter/lib/src/material/dialog.dart index f6a0bb547a72..2cb733479447 100644 --- a/packages/flutter/lib/src/material/dialog.dart +++ b/packages/flutter/lib/src/material/dialog.dart @@ -611,7 +611,7 @@ class AlertDialog extends StatelessWidget { ), ); - if (label != null) + if (label != null) { dialogChild = Semantics( scopesRoute: true, explicitChildNodes: true, @@ -619,6 +619,7 @@ class AlertDialog extends StatelessWidget { label: label, child: dialogChild, ); + } return Dialog( backgroundColor: backgroundColor, @@ -947,7 +948,7 @@ class SimpleDialog extends StatelessWidget { ), ); - if (label != null) + if (label != null) { dialogChild = Semantics( scopesRoute: true, explicitChildNodes: true, @@ -955,6 +956,7 @@ class SimpleDialog extends StatelessWidget { label: label, child: dialogChild, ); + } return Dialog( backgroundColor: backgroundColor, elevation: elevation, diff --git a/packages/flutter/lib/src/material/dialog_theme.dart b/packages/flutter/lib/src/material/dialog_theme.dart index 9621050a9f87..4228fafe353e 100644 --- a/packages/flutter/lib/src/material/dialog_theme.dart +++ b/packages/flutter/lib/src/material/dialog_theme.dart @@ -115,10 +115,12 @@ class DialogTheme 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 DialogTheme && other.backgroundColor == backgroundColor && other.elevation == elevation diff --git a/packages/flutter/lib/src/material/divider_theme.dart b/packages/flutter/lib/src/material/divider_theme.dart index ad3144c471ca..d7f377c06cf1 100644 --- a/packages/flutter/lib/src/material/divider_theme.dart +++ b/packages/flutter/lib/src/material/divider_theme.dart @@ -105,10 +105,12 @@ class DividerThemeData 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 DividerThemeData && other.color == color && other.space == space diff --git a/packages/flutter/lib/src/material/drawer.dart b/packages/flutter/lib/src/material/drawer.dart index 3297793262b9..8f708aa49fec 100644 --- a/packages/flutter/lib/src/material/drawer.dart +++ b/packages/flutter/lib/src/material/drawer.dart @@ -373,8 +373,9 @@ class DrawerControllerState extends State with SingleTickerPro @override void didUpdateWidget(DrawerController oldWidget) { super.didUpdateWidget(oldWidget); - if (widget.scrimColor != oldWidget.scrimColor) + if (widget.scrimColor != oldWidget.scrimColor) { _scrimColorTween = _buildScrimColorTween(); + } if (widget.isDrawerOpen != oldWidget.isDrawerOpen) { switch(_controller.status) { case AnimationStatus.completed: @@ -437,8 +438,9 @@ class DrawerControllerState extends State with SingleTickerPro } void _handleDragCancel() { - if (_controller.isDismissed || _controller.isAnimating) + if (_controller.isDismissed || _controller.isAnimating) { return; + } if (_controller.value < 0.5) { close(); } else { @@ -450,8 +452,9 @@ class DrawerControllerState extends State with SingleTickerPro double get _width { final RenderBox? box = _drawerKey.currentContext?.findRenderObject() as RenderBox?; - if (box != null) + if (box != null) { return box.size.width; + } return _kWidth; // drawer not being shown currently } @@ -476,14 +479,16 @@ class DrawerControllerState extends State with SingleTickerPro } final bool opened = _controller.value > 0.5; - if (opened != _previouslyOpened && widget.drawerCallback != null) + if (opened != _previouslyOpened && widget.drawerCallback != null) { widget.drawerCallback!(opened); + } _previouslyOpened = opened; } void _settle(DragEndDetails details) { - if (_controller.isDismissed) + if (_controller.isDismissed) { return; + } if (details.velocity.pixelsPerSecond.dx.abs() >= _kMinFlingVelocity) { double visualVelocity = details.velocity.pixelsPerSecond.dx / _width; switch (widget.alignment) { diff --git a/packages/flutter/lib/src/material/drawer_theme.dart b/packages/flutter/lib/src/material/drawer_theme.dart index bbd2f05f1c11..d60e3343e75a 100644 --- a/packages/flutter/lib/src/material/drawer_theme.dart +++ b/packages/flutter/lib/src/material/drawer_theme.dart @@ -79,8 +79,9 @@ class DrawerThemeData with Diagnosticable { /// {@macro dart.ui.shadow.lerp} static DrawerThemeData? lerp(DrawerThemeData? a, DrawerThemeData? b, double t) { assert(t != null); - if (a == null && b == null) + if (a == null && b == null) { return null; + } return DrawerThemeData( backgroundColor: Color.lerp(a?.backgroundColor, b?.backgroundColor, t), scrimColor: Color.lerp(a?.scrimColor, b?.scrimColor, t), @@ -101,10 +102,12 @@ class DrawerThemeData 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 DrawerThemeData && other.backgroundColor == backgroundColor && other.scrimColor == scrimColor diff --git a/packages/flutter/lib/src/material/dropdown.dart b/packages/flutter/lib/src/material/dropdown.dart index 7606d9f6f899..61587a873e21 100644 --- a/packages/flutter/lib/src/material/dropdown.dart +++ b/packages/flutter/lib/src/material/dropdown.dart @@ -518,8 +518,9 @@ class _DropdownRoute extends PopupRoute<_DropdownRouteResult> { double menuTop = (buttonTop - selectedItemOffset) - (itemHeights[selectedIndex] - buttonRect.height) / 2.0; double preferredMenuHeight = kMaterialListPadding.vertical; - if (items.isNotEmpty) + if (items.isNotEmpty) { preferredMenuHeight += itemHeights.reduce((double total, double height) => total + height); + } // If there are too many elements in the menu, we need to shrink it down // so it is at most the computedMaxHeight. @@ -1276,8 +1277,9 @@ class _DropdownButtonState extends State> with WidgetsBindi // of each menu item before laying them out, not having the _DropdownRoute // collect each item's height to lay out is fine since the route is // already on its way out. - if (_dropdownRoute == null) + if (_dropdownRoute == null) { return; + } _dropdownRoute!.itemHeights[index] = size.height; }, @@ -1307,8 +1309,9 @@ class _DropdownButtonState extends State> with WidgetsBindi focusNode?.requestFocus(); navigator.push(_dropdownRoute!).then((_DropdownRouteResult? newValue) { _removeDropdownRoute(); - if (!mounted || newValue == null) + if (!mounted || newValue == null) { return; + } widget.onChanged?.call(newValue.result); }); @@ -1327,8 +1330,9 @@ class _DropdownButtonState extends State> with WidgetsBindi Color get _iconColor { // These colors are not defined in the Material Design spec. if (_enabled) { - if (widget.iconEnabledColor != null) + if (widget.iconEnabledColor != null) { return widget.iconEnabledColor!; + } switch (Theme.of(context).brightness) { case Brightness.light: @@ -1337,8 +1341,9 @@ class _DropdownButtonState extends State> with WidgetsBindi return Colors.white70; } } else { - if (widget.iconDisabledColor != null) + if (widget.iconDisabledColor != null) { return widget.iconDisabledColor!; + } switch (Theme.of(context).brightness) { case Brightness.light: @@ -1385,8 +1390,9 @@ class _DropdownButtonState extends State> with WidgetsBindi int? hintIndex; if (widget.hint != null || (!_enabled && widget.disabledHint != null)) { Widget displayedHint = _enabled ? widget.hint! : widget.disabledHint ?? widget.hint!; - if (widget.selectedItemBuilder == null) + if (widget.selectedItemBuilder == null) { displayedHint = _DropdownMenuItemContainer(alignment: widget.alignment, child: displayedHint); + } hintIndex = items.length; items.add(DefaultTextStyle( diff --git a/packages/flutter/lib/src/material/elevated_button.dart b/packages/flutter/lib/src/material/elevated_button.dart index 6b42d930f94a..cb570834ce0c 100644 --- a/packages/flutter/lib/src/material/elevated_button.dart +++ b/packages/flutter/lib/src/material/elevated_button.dart @@ -366,8 +366,9 @@ class _ElevatedButtonDefaultBackground extends MaterialStateProperty wit @override Color? resolve(Set states) { - if (states.contains(MaterialState.disabled)) + if (states.contains(MaterialState.disabled)) { return onSurface?.withOpacity(0.12); + } return primary; } } @@ -381,8 +382,9 @@ class _ElevatedButtonDefaultForeground extends MaterialStateProperty wit @override Color? resolve(Set states) { - if (states.contains(MaterialState.disabled)) + if (states.contains(MaterialState.disabled)) { return onSurface?.withOpacity(0.38); + } return onPrimary; } } @@ -395,10 +397,12 @@ class _ElevatedButtonDefaultOverlay extends MaterialStateProperty with D @override Color? resolve(Set states) { - if (states.contains(MaterialState.hovered)) + if (states.contains(MaterialState.hovered)) { return onPrimary.withOpacity(0.08); - if (states.contains(MaterialState.focused) || states.contains(MaterialState.pressed)) + } + if (states.contains(MaterialState.focused) || states.contains(MaterialState.pressed)) { return onPrimary.withOpacity(0.24); + } return null; } } @@ -411,14 +415,18 @@ class _ElevatedButtonDefaultElevation extends MaterialStateProperty with @override double resolve(Set states) { - if (states.contains(MaterialState.disabled)) + if (states.contains(MaterialState.disabled)) { return 0; - if (states.contains(MaterialState.hovered)) + } + if (states.contains(MaterialState.hovered)) { return elevation + 2; - if (states.contains(MaterialState.focused)) + } + if (states.contains(MaterialState.focused)) { return elevation + 2; - if (states.contains(MaterialState.pressed)) + } + if (states.contains(MaterialState.pressed)) { return elevation + 6; + } return elevation; } } @@ -432,8 +440,9 @@ class _ElevatedButtonDefaultMouseCursor extends MaterialStateProperty states) { - if (states.contains(MaterialState.disabled)) + if (states.contains(MaterialState.disabled)) { return disabledCursor; + } return enabledCursor; } } @@ -515,28 +524,33 @@ class _TokenDefaultsM3 extends ButtonStyle { @override MaterialStateProperty? get backgroundColor => MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.disabled)) + if (states.contains(MaterialState.disabled)) { return _colors.onSurface.withOpacity(0.12); + } return _colors.surface; }); @override MaterialStateProperty? get foregroundColor => MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.disabled)) + if (states.contains(MaterialState.disabled)) { return _colors.onSurface.withOpacity(0.38); + } return _colors.primary; }); @override MaterialStateProperty? get overlayColor => MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.hovered)) + if (states.contains(MaterialState.hovered)) { return _colors.primary.withOpacity(0.08); - if (states.contains(MaterialState.focused)) + } + if (states.contains(MaterialState.focused)) { return _colors.primary.withOpacity(0.12); - if (states.contains(MaterialState.pressed)) + } + if (states.contains(MaterialState.pressed)) { return _colors.primary.withOpacity(0.12); + } return null; }); @@ -551,14 +565,18 @@ class _TokenDefaultsM3 extends ButtonStyle { @override MaterialStateProperty? get elevation => MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.disabled)) + if (states.contains(MaterialState.disabled)) { return 0.0; - if (states.contains(MaterialState.hovered)) + } + if (states.contains(MaterialState.hovered)) { return 3.0; - if (states.contains(MaterialState.focused)) + } + if (states.contains(MaterialState.focused)) { return 1.0; - if (states.contains(MaterialState.pressed)) + } + if (states.contains(MaterialState.pressed)) { return 1.0; + } return 1.0; }); @@ -585,8 +603,9 @@ class _TokenDefaultsM3 extends ButtonStyle { @override MaterialStateProperty? get mouseCursor => MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.disabled)) + if (states.contains(MaterialState.disabled)) { return SystemMouseCursors.basic; + } return SystemMouseCursors.click; }); diff --git a/packages/flutter/lib/src/material/elevated_button_theme.dart b/packages/flutter/lib/src/material/elevated_button_theme.dart index c3232fdd6dbc..6287b41cd8bf 100644 --- a/packages/flutter/lib/src/material/elevated_button_theme.dart +++ b/packages/flutter/lib/src/material/elevated_button_theme.dart @@ -47,8 +47,9 @@ class ElevatedButtonThemeData with Diagnosticable { /// Linearly interpolate between two elevated button themes. static ElevatedButtonThemeData? lerp(ElevatedButtonThemeData? a, ElevatedButtonThemeData? b, double t) { assert (t != null); - if (a == null && b == null) + if (a == null && b == null) { return null; + } return ElevatedButtonThemeData( style: ButtonStyle.lerp(a?.style, b?.style, t), ); @@ -59,10 +60,12 @@ class ElevatedButtonThemeData 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 ElevatedButtonThemeData && other.style == style; } diff --git a/packages/flutter/lib/src/material/expansion_panel.dart b/packages/flutter/lib/src/material/expansion_panel.dart index 1ec94f6a1a95..d2925007f914 100644 --- a/packages/flutter/lib/src/material/expansion_panel.dart +++ b/packages/flutter/lib/src/material/expansion_panel.dart @@ -25,8 +25,9 @@ class _SaltedKey extends LocalKey { @override bool operator ==(Object other) { - if (other.runtimeType != runtimeType) + if (other.runtimeType != runtimeType) { return false; + } return other is _SaltedKey && other.salt == salt && other.value == value; @@ -312,8 +313,9 @@ class _ExpansionPanelListState extends State { final ExpansionPanelRadio child = widget.children[childIndex] as ExpansionPanelRadio; if (widget.expansionCallback != null && childIndex != index && - child.value == _currentOpenPanel?.value) + child.value == _currentOpenPanel?.value) { widget.expansionCallback!(childIndex, false); + } } setState(() { @@ -324,8 +326,9 @@ class _ExpansionPanelListState extends State { ExpansionPanelRadio? searchPanelByValue(List panels, Object? value) { for (final ExpansionPanelRadio panel in panels) { - if (panel.value == value) + if (panel.value == value) { return panel; + } } return null; } @@ -340,8 +343,9 @@ class _ExpansionPanelListState extends State { final List items = []; for (int index = 0; index < widget.children.length; index += 1) { - if (_isChildExpanded(index) && index != 0 && !_isChildExpanded(index - 1)) + if (_isChildExpanded(index) && index != 0 && !_isChildExpanded(index - 1)) { items.add(MaterialGap(key: _SaltedKey(context, index * 2 - 1))); + } final ExpansionPanel child = widget.children[index]; final Widget headerWidget = child.headerBuilder( @@ -412,8 +416,9 @@ class _ExpansionPanelListState extends State { ), ); - if (_isChildExpanded(index) && index != widget.children.length - 1) + if (_isChildExpanded(index) && index != widget.children.length - 1) { items.add(MaterialGap(key: _SaltedKey(context, index * 2 + 1))); + } } return MergeableMaterial( diff --git a/packages/flutter/lib/src/material/expansion_tile.dart b/packages/flutter/lib/src/material/expansion_tile.dart index 9430aa28598a..ece7892e970f 100644 --- a/packages/flutter/lib/src/material/expansion_tile.dart +++ b/packages/flutter/lib/src/material/expansion_tile.dart @@ -296,8 +296,9 @@ class _ExpansionTileState extends State with SingleTickerProvider _backgroundColor = _controller.drive(_backgroundColorTween.chain(_easeOutTween)); _isExpanded = PageStorage.of(context)?.readState(context) as bool? ?? widget.initiallyExpanded; - if (_isExpanded) + if (_isExpanded) { _controller.value = 1.0; + } } @override @@ -313,8 +314,9 @@ class _ExpansionTileState extends State with SingleTickerProvider _controller.forward(); } else { _controller.reverse().then((void value) { - if (!mounted) + if (!mounted) { return; + } setState(() { // Rebuild without widget.children. }); @@ -344,14 +346,16 @@ class _ExpansionTileState extends State with SingleTickerProvider } Widget? _buildLeadingIcon(BuildContext context) { - if (_effectiveAffinity(widget.controlAffinity) != ListTileControlAffinity.leading) + if (_effectiveAffinity(widget.controlAffinity) != ListTileControlAffinity.leading) { return null; + } return _buildIcon(context); } Widget? _buildTrailingIcon(BuildContext context) { - if (_effectiveAffinity(widget.controlAffinity) != ListTileControlAffinity.trailing) + if (_effectiveAffinity(widget.controlAffinity) != ListTileControlAffinity.trailing) { return null; + } return _buildIcon(context); } diff --git a/packages/flutter/lib/src/material/expansion_tile_theme.dart b/packages/flutter/lib/src/material/expansion_tile_theme.dart index 9ecd0a206d06..e3b133a4794b 100644 --- a/packages/flutter/lib/src/material/expansion_tile_theme.dart +++ b/packages/flutter/lib/src/material/expansion_tile_theme.dart @@ -105,8 +105,9 @@ class ExpansionTileThemeData with Diagnosticable { /// Linearly interpolate between ExpansionTileThemeData objects. static ExpansionTileThemeData? lerp(ExpansionTileThemeData? a, ExpansionTileThemeData? b, double t) { assert (t != null); - if (a == null && b == null) + if (a == null && b == null) { return null; + } return ExpansionTileThemeData( backgroundColor: Color.lerp(a?.backgroundColor, b?.backgroundColor, t), collapsedBackgroundColor: Color.lerp(a?.collapsedBackgroundColor, b?.collapsedBackgroundColor, t), @@ -137,10 +138,12 @@ class ExpansionTileThemeData 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 ExpansionTileThemeData && other.backgroundColor == backgroundColor && other.collapsedBackgroundColor == collapsedBackgroundColor diff --git a/packages/flutter/lib/src/material/feedback.dart b/packages/flutter/lib/src/material/feedback.dart index bb00b3f939f6..e3313b537277 100644 --- a/packages/flutter/lib/src/material/feedback.dart +++ b/packages/flutter/lib/src/material/feedback.dart @@ -119,8 +119,9 @@ class Feedback { /// * [forTap] to just trigger the platform-specific feedback without wrapping /// a [GestureTapCallback]. static GestureTapCallback? wrapForTap(GestureTapCallback? callback, BuildContext context) { - if (callback == null) + if (callback == null) { return null; + } return () { Feedback.forTap(context); callback(); @@ -162,8 +163,9 @@ class Feedback { /// * [forLongPress] to just trigger the platform-specific feedback without /// wrapping a [GestureLongPressCallback]. static GestureLongPressCallback? wrapForLongPress(GestureLongPressCallback? callback, BuildContext context) { - if (callback == null) + if (callback == null) { return null; + } return () { Feedback.forLongPress(context); callback(); diff --git a/packages/flutter/lib/src/material/flexible_space_bar.dart b/packages/flutter/lib/src/material/flexible_space_bar.dart index b4187283f2c5..be29b785159a 100644 --- a/packages/flutter/lib/src/material/flexible_space_bar.dart +++ b/packages/flutter/lib/src/material/flexible_space_bar.dart @@ -176,8 +176,9 @@ class FlexibleSpaceBar extends StatefulWidget { class _FlexibleSpaceBarState extends State { bool _getEffectiveCenterTitle(ThemeData theme) { - if (widget.centerTitle != null) + if (widget.centerTitle != null) { return widget.centerTitle!; + } assert(theme.platform != null); switch (theme.platform) { case TargetPlatform.android: @@ -192,8 +193,9 @@ class _FlexibleSpaceBarState extends State { } Alignment _getTitleAlignment(bool effectiveCenterTitle) { - if (effectiveCenterTitle) + if (effectiveCenterTitle) { return Alignment.bottomCenter; + } final TextDirection textDirection = Directionality.of(context); assert(textDirection != null); switch (textDirection) { diff --git a/packages/flutter/lib/src/material/floating_action_button_location.dart b/packages/flutter/lib/src/material/floating_action_button_location.dart index acfb89f2439b..d19fd54b53a7 100644 --- a/packages/flutter/lib/src/material/floating_action_button_location.dart +++ b/packages/flutter/lib/src/material/floating_action_button_location.dart @@ -554,10 +554,12 @@ mixin FabFloatOffsetY on StandardFabLocation { ); double fabY = contentBottom - fabHeight - safeMargin; - if (snackBarHeight > 0.0) + if (snackBarHeight > 0.0) { fabY = math.min(fabY, contentBottom - snackBarHeight - fabHeight - kFloatingActionButtonMargin); - if (bottomSheetHeight > 0.0) + } + if (bottomSheetHeight > 0.0) { fabY = math.min(fabY, contentBottom - bottomSheetHeight - fabHeight / 2.0); + } return fabY + adjustment; } } @@ -595,11 +597,13 @@ mixin FabDockedOffsetY on StandardFabLocation { double fabY = contentBottom - fabHeight / 2.0 - safeMargin; // The FAB should sit with a margin between it and the snack bar. - if (snackBarHeight > 0.0) + if (snackBarHeight > 0.0) { fabY = math.min(fabY, contentBottom - snackBarHeight - fabHeight - kFloatingActionButtonMargin); + } // The FAB should sit with its center in front of the top of the bottom sheet. - if (bottomSheetHeight > 0.0) + if (bottomSheetHeight > 0.0) { fabY = math.min(fabY, contentBottom - bottomSheetHeight - fabHeight / 2.0); + } final double maxFabY = scaffoldGeometry.scaffoldSize.height - fabHeight - safeMargin; return math.min(maxFabY, fabY); } diff --git a/packages/flutter/lib/src/material/floating_action_button_theme.dart b/packages/flutter/lib/src/material/floating_action_button_theme.dart index 63fe43a52dea..fdc8b2abfa40 100644 --- a/packages/flutter/lib/src/material/floating_action_button_theme.dart +++ b/packages/flutter/lib/src/material/floating_action_button_theme.dart @@ -184,8 +184,9 @@ class FloatingActionButtonThemeData with Diagnosticable { /// {@macro dart.ui.shadow.lerp} static FloatingActionButtonThemeData? lerp(FloatingActionButtonThemeData? a, FloatingActionButtonThemeData? b, double t) { assert(t != null); - if (a == null && b == null) + if (a == null && b == null) { return null; + } return FloatingActionButtonThemeData( foregroundColor: Color.lerp(a?.foregroundColor, b?.foregroundColor, t), backgroundColor: Color.lerp(a?.backgroundColor, b?.backgroundColor, t), @@ -236,10 +237,12 @@ class FloatingActionButtonThemeData 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 FloatingActionButtonThemeData && other.foregroundColor == foregroundColor && other.backgroundColor == backgroundColor diff --git a/packages/flutter/lib/src/material/grid_tile.dart b/packages/flutter/lib/src/material/grid_tile.dart index e6bd778765da..e255e4c1a3ab 100644 --- a/packages/flutter/lib/src/material/grid_tile.dart +++ b/packages/flutter/lib/src/material/grid_tile.dart @@ -44,8 +44,9 @@ class GridTile extends StatelessWidget { @override Widget build(BuildContext context) { - if (header == null && footer == null) + if (header == null && footer == null) { return child; + } return Stack( children: [ diff --git a/packages/flutter/lib/src/material/grid_tile_bar.dart b/packages/flutter/lib/src/material/grid_tile_bar.dart index 70d158128e56..e8f923b785d5 100644 --- a/packages/flutter/lib/src/material/grid_tile_bar.dart +++ b/packages/flutter/lib/src/material/grid_tile_bar.dart @@ -59,8 +59,9 @@ class GridTileBar extends StatelessWidget { @override Widget build(BuildContext context) { BoxDecoration? decoration; - if (backgroundColor != null) + if (backgroundColor != null) { decoration = BoxDecoration(color: backgroundColor); + } final EdgeInsetsDirectional padding = EdgeInsetsDirectional.only( start: leading != null ? 8.0 : 16.0, diff --git a/packages/flutter/lib/src/material/icon_button.dart b/packages/flutter/lib/src/material/icon_button.dart index 267b9dcecd43..edec059e6901 100644 --- a/packages/flutter/lib/src/material/icon_button.dart +++ b/packages/flutter/lib/src/material/icon_button.dart @@ -306,10 +306,11 @@ class IconButton extends StatelessWidget { assert(debugCheckHasMaterial(context)); final ThemeData theme = Theme.of(context); Color? currentColor; - if (onPressed != null) + if (onPressed != null) { currentColor = color; - else + } else { currentColor = disabledColor ?? theme.disabledColor; + } final VisualDensity effectiveVisualDensity = visualDensity ?? theme.visualDensity; diff --git a/packages/flutter/lib/src/material/ink_decoration.dart b/packages/flutter/lib/src/material/ink_decoration.dart index 3a36bbc2c2a5..8529cfbc56e3 100644 --- a/packages/flutter/lib/src/material/ink_decoration.dart +++ b/packages/flutter/lib/src/material/ink_decoration.dart @@ -241,11 +241,13 @@ class Ink extends StatefulWidget { final double? height; EdgeInsetsGeometry get _paddingIncludingDecoration { - if (decoration == null || decoration!.padding == null) + if (decoration == null || decoration!.padding == null) { return padding ?? EdgeInsets.zero; + } final EdgeInsetsGeometry decorationPadding = decoration!.padding!; - if (padding == null) + if (padding == null) { return decorationPadding; + } return padding!.add(decorationPadding); } @@ -351,8 +353,9 @@ class InkDecoration extends InkFeature { Decoration? get decoration => _decoration; Decoration? _decoration; set decoration(Decoration? value) { - if (value == _decoration) + if (value == _decoration) { return; + } _decoration = value; _painter?.dispose(); _painter = _decoration?.createBoxPainter(_handleChanged); @@ -368,8 +371,9 @@ class InkDecoration extends InkFeature { ImageConfiguration _configuration; set configuration(ImageConfiguration value) { assert(value != null); - if (value == _configuration) + if (value == _configuration) { return; + } _configuration = value; controller.markNeedsPaint(); } @@ -386,8 +390,9 @@ class InkDecoration extends InkFeature { @override void paintFeature(Canvas canvas, Matrix4 transform) { - if (_painter == null) + if (_painter == null) { return; + } final Offset? originOffset = MatrixUtils.getAsTranslation(transform); final ImageConfiguration sizedConfiguration = configuration.copyWith( size: referenceBox.size, diff --git a/packages/flutter/lib/src/material/ink_highlight.dart b/packages/flutter/lib/src/material/ink_highlight.dart index b947a4b6aa92..892012fef2f6 100644 --- a/packages/flutter/lib/src/material/ink_highlight.dart +++ b/packages/flutter/lib/src/material/ink_highlight.dart @@ -98,8 +98,9 @@ class InkHighlight extends InteractiveInkFeature { } void _handleAlphaStatusChanged(AnimationStatus status) { - if (status == AnimationStatus.dismissed && !_active) + if (status == AnimationStatus.dismissed && !_active) { dispose(); + } } @override diff --git a/packages/flutter/lib/src/material/ink_ripple.dart b/packages/flutter/lib/src/material/ink_ripple.dart index 8157526d7853..c1dc3e015040 100644 --- a/packages/flutter/lib/src/material/ink_ripple.dart +++ b/packages/flutter/lib/src/material/ink_ripple.dart @@ -23,8 +23,9 @@ RectCallback? _getClipCallback(RenderBox referenceBox, bool containedInkWell, Re assert(containedInkWell); return rectCallback; } - if (containedInkWell) + if (containedInkWell) { return () => Offset.zero & referenceBox.size; + } return null; } @@ -208,13 +209,15 @@ class InkRipple extends InteractiveInkFeature { // dispose _fadeOutController. final double fadeOutValue = 1.0 - _fadeInController.value; _fadeOutController.value = fadeOutValue; - if (fadeOutValue < 1.0) + if (fadeOutValue < 1.0) { _fadeOutController.animateTo(1.0, duration: _kCancelDuration); + } } void _handleAlphaStatusChanged(AnimationStatus status) { - if (status == AnimationStatus.completed) + if (status == AnimationStatus.completed) { dispose(); + } } @override diff --git a/packages/flutter/lib/src/material/ink_splash.dart b/packages/flutter/lib/src/material/ink_splash.dart index 28516b4fa8fe..83149c03bd55 100644 --- a/packages/flutter/lib/src/material/ink_splash.dart +++ b/packages/flutter/lib/src/material/ink_splash.dart @@ -20,8 +20,9 @@ RectCallback? _getClipCallback(RenderBox referenceBox, bool containedInkWell, Re assert(containedInkWell); return rectCallback; } - if (containedInkWell) + if (containedInkWell) { return () => Offset.zero & referenceBox.size; + } return null; } @@ -185,8 +186,9 @@ class InkSplash extends InteractiveInkFeature { } void _handleAlphaStatusChanged(AnimationStatus status) { - if (status == AnimationStatus.completed) + if (status == AnimationStatus.completed) { dispose(); + } } @override @@ -201,8 +203,9 @@ class InkSplash extends InteractiveInkFeature { void paintFeature(Canvas canvas, Matrix4 transform) { final Paint paint = Paint()..color = color.withAlpha(_alpha.value); Offset? center = _position; - if (_repositionToReferenceBox) + if (_repositionToReferenceBox) { center = Offset.lerp(center, referenceBox.size.center(Offset.zero), _radiusController.value); + } paintInkCircle( canvas: canvas, transform: transform, diff --git a/packages/flutter/lib/src/material/ink_well.dart b/packages/flutter/lib/src/material/ink_well.dart index f8faa5dd1b44..87ff2f8e0fc3 100644 --- a/packages/flutter/lib/src/material/ink_well.dart +++ b/packages/flutter/lib/src/material/ink_well.dart @@ -59,8 +59,9 @@ abstract class InteractiveInkFeature extends InkFeature { Color get color => _color; Color _color; set color(Color value) { - if (value == _color) + if (value == _color) { return; + } _color = value; controller.markNeedsPaint(); } @@ -846,8 +847,9 @@ class _InkResponseState extends State<_InkResponseStateWidget> if (type == _HighlightType.pressed) { widget.parentState?.markChildInkResponsePressed(this, value); } - if (value == (highlight != null && highlight.active)) + if (value == (highlight != null && highlight.active)) { return; + } if (value) { if (highlight == null) { final RenderBox referenceBox = context.findRenderObject()! as RenderBox; @@ -878,8 +880,9 @@ class _InkResponseState extends State<_InkResponseStateWidget> widget.onHighlightChanged?.call(value); break; case _HighlightType.hover: - if (callOnHover) + if (callOnHover) { widget.onHover?.call(value); + } break; case _HighlightType.focus: break; @@ -901,8 +904,9 @@ class _InkResponseState extends State<_InkResponseStateWidget> if (_splashes != null) { assert(_splashes!.contains(splash)); _splashes!.remove(splash); - if (_currentSplash == splash) + if (_currentSplash == splash) { _currentSplash = null; + } updateKeepAlive(); } // else we're probably in deactivate() } @@ -964,8 +968,9 @@ class _InkResponseState extends State<_InkResponseStateWidget> } void _handleTapDown(TapDownDetails details) { - if (_anyChildInkResponsePressed) + if (_anyChildInkResponsePressed) { return; + } _startNewSplash(details: details); widget.onTapDown?.call(details); } @@ -999,8 +1004,9 @@ class _InkResponseState extends State<_InkResponseStateWidget> _currentSplash = null; updateHighlight(_HighlightType.pressed, value: false); if (widget.onTap != null) { - if (widget.enableFeedback) + if (widget.enableFeedback) { Feedback.forTap(context); + } widget.onTap?.call(); } } @@ -1023,8 +1029,9 @@ class _InkResponseState extends State<_InkResponseStateWidget> _currentSplash?.confirm(); _currentSplash = null; if (widget.onLongPress != null) { - if (widget.enableFeedback) + if (widget.enableFeedback) { Feedback.forLongPress(context); + } widget.onLongPress!(); } } @@ -1034,8 +1041,9 @@ class _InkResponseState extends State<_InkResponseStateWidget> if (_splashes != null) { final Set splashes = _splashes!; _splashes = null; - for (final InteractiveInkFeature splash in splashes) + for (final InteractiveInkFeature splash in splashes) { splash.dispose(); + } _currentSplash = null; } assert(_currentSplash == null); diff --git a/packages/flutter/lib/src/material/input_border.dart b/packages/flutter/lib/src/material/input_border.dart index 185d4ee4e561..5df3d8e31f64 100644 --- a/packages/flutter/lib/src/material/input_border.dart +++ b/packages/flutter/lib/src/material/input_border.dart @@ -229,17 +229,20 @@ class UnderlineInputBorder extends InputBorder { double gapPercentage = 0.0, TextDirection? textDirection, }) { - if (borderRadius.bottomLeft != Radius.zero || borderRadius.bottomRight != Radius.zero) + if (borderRadius.bottomLeft != Radius.zero || borderRadius.bottomRight != Radius.zero) { canvas.clipPath(getOuterPath(rect, textDirection: textDirection)); + } canvas.drawLine(rect.bottomLeft, rect.bottomRight, borderSide.toPaint()); } @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 InputBorder && other.borderSide == borderSide; } @@ -425,8 +428,9 @@ class OutlineInputBorder extends InputBorder { final Path path = Path() ..addArc(tlCorner, math.pi, tlCornerArcSweep); - if (start > scaledRRect.tlRadiusX) + if (start > scaledRRect.tlRadiusX) { path.lineTo(scaledRRect.left + start, scaledRRect.top); + } const double trCornerArcStart = (3 * math.pi) / 2.0; const double trCornerArcSweep = cornerArcSweep; @@ -495,10 +499,12 @@ class OutlineInputBorder extends InputBorder { @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 OutlineInputBorder && other.borderSide == borderSide && other.borderRadius == borderRadius diff --git a/packages/flutter/lib/src/material/input_decorator.dart b/packages/flutter/lib/src/material/input_decorator.dart index 2ff89d206686..dbbb4b2b5032 100644 --- a/packages/flutter/lib/src/material/input_decorator.dart +++ b/packages/flutter/lib/src/material/input_decorator.dart @@ -44,10 +44,12 @@ class _InputBorderGap extends ChangeNotifier { @override // ignore: avoid_equals_and_hash_code_on_mutable_classes, this class is not used in collection 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 _InputBorderGap && other.start == start && other.extent == extent; @@ -264,12 +266,13 @@ class _Shaker extends AnimatedWidget { double get translateX { const double shakeDelta = 4.0; final double t = animation.value; - if (t <= 0.25) + if (t <= 0.25) { return -t * shakeDelta; - else if (t < 0.75) + } else if (t < 0.75) { return (t - 0.5) * shakeDelta; - else + } else { return (1.0 - t) * 4.0 * shakeDelta; + } } @override @@ -432,11 +435,13 @@ class _HelperErrorState extends State<_HelperError> with SingleTickerProviderSta } } - if (_helper == null && widget.errorText != null) + if (_helper == null && widget.errorText != null) { return _buildError(); + } - if (_error == null && widget.helperText != null) + if (_error == null && widget.helperText != null) { return _buildHelper(); + } if (widget.errorText != null) { return Stack( @@ -514,19 +519,23 @@ class FloatingLabelAlignment { @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 FloatingLabelAlignment && _x == other._x; } static String _stringify(double x) { - if (x == -1.0) + if (x == -1.0) { return 'FloatingLabelAlignment.start'; - if (x == 0.0) + } + if (x == 0.0) { return 'FloatingLabelAlignment.center'; + } return 'FloatingLabelAlignment(x: ${x.toStringAsFixed(1)})'; } @@ -604,10 +613,12 @@ class _Decoration { @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 _Decoration && other.contentPadding == contentPadding && other.isCollapsed == isCollapsed @@ -745,8 +756,9 @@ class _RenderDecoration extends RenderBox with SlottedContainerRenderObjectMixin _Decoration _decoration; set decoration(_Decoration value) { assert(value != null); - if (_decoration == value) + if (_decoration == value) { return; + } _decoration = value; markNeedsLayout(); } @@ -755,8 +767,9 @@ class _RenderDecoration extends RenderBox with SlottedContainerRenderObjectMixin TextDirection _textDirection; set textDirection(TextDirection value) { assert(value != null); - if (_textDirection == value) + if (_textDirection == value) { return; + } _textDirection = value; markNeedsLayout(); } @@ -765,8 +778,9 @@ class _RenderDecoration extends RenderBox with SlottedContainerRenderObjectMixin TextBaseline _textBaseline; set textBaseline(TextBaseline value) { assert(value != null); - if (_textBaseline == value) + if (_textBaseline == value) { return; + } _textBaseline = value; markNeedsLayout(); } @@ -793,8 +807,9 @@ class _RenderDecoration extends RenderBox with SlottedContainerRenderObjectMixin bool _isFocused; set isFocused(bool value) { assert(value != null); - if (_isFocused == value) + if (_isFocused == value) { return; + } _isFocused = value; markNeedsSemanticsUpdate(); } @@ -803,8 +818,9 @@ class _RenderDecoration extends RenderBox with SlottedContainerRenderObjectMixin bool _expands = false; set expands(bool value) { assert(value != null); - if (_expands == value) + if (_expands == value) { return; + } _expands = value; markNeedsLayout(); } @@ -817,12 +833,15 @@ class _RenderDecoration extends RenderBox with SlottedContainerRenderObjectMixin @override void visitChildrenForSemantics(RenderObjectVisitor visitor) { - if (icon != null) + if (icon != null) { visitor(icon!); - if (prefix != null) + } + if (prefix != null) { visitor(prefix!); - if (prefixIcon != null) + } + if (prefixIcon != null) { visitor(prefixIcon!); + } if (label != null) { visitor(label!); @@ -835,18 +854,24 @@ class _RenderDecoration extends RenderBox with SlottedContainerRenderObjectMixin } } - if (input != null) + if (input != null) { visitor(input!); - if (suffixIcon != null) + } + if (suffixIcon != null) { visitor(suffixIcon!); - if (suffix != null) + } + if (suffix != null) { visitor(suffix!); - if (container != null) + } + if (container != null) { visitor(container!); - if (helperError != null) + } + if (helperError != null) { visitor(helperError!); - if (counter != null) + } + if (counter != null) { visitor(counter!); + } } @override @@ -885,8 +910,9 @@ class _RenderDecoration extends RenderBox with SlottedContainerRenderObjectMixin final double baseline = box.getDistanceToBaseline(TextBaseline.alphabetic)!; assert(() { - if (baseline >= 0) + if (baseline >= 0) { return true; + } throw FlutterError.fromParts([ ErrorSummary("One of InputDecorator's children reported a negative baseline offset."), ErrorDescription( @@ -1204,8 +1230,9 @@ class _RenderDecoration extends RenderBox with SlottedContainerRenderObjectMixin double _lineHeight(double width, List boxes) { double height = 0.0; for (final RenderBox? box in boxes) { - if (box == null) + if (box == null) { continue; + } height = math.max(_minHeight(box, width), height); } return height; @@ -1235,8 +1262,9 @@ class _RenderDecoration extends RenderBox with SlottedContainerRenderObjectMixin final double helperErrorAvailableWidth = math.max(width - counterWidth, 0.0); final double helperErrorHeight = _minHeight(helperError, helperErrorAvailableWidth); double subtextHeight = math.max(counterHeight, helperErrorHeight); - if (subtextHeight > 0.0) + if (subtextHeight > 0.0) { subtextHeight += subtextGap; + } final double prefixHeight = _minHeight(prefix, width); final double prefixWidth = _minWidth(prefix, prefixHeight); @@ -1355,18 +1383,22 @@ class _RenderDecoration extends RenderBox with SlottedContainerRenderObjectMixin centerLayout(label!, start - label!.size.width); } } - if (prefix != null) + if (prefix != null) { start -= baselineLayout(prefix!, start - prefix!.size.width); - if (input != null) + } + if (input != null) { baselineLayout(input!, start - input!.size.width); - if (hint != null) + } + if (hint != null) { baselineLayout(hint!, start - hint!.size.width); + } if (suffixIcon != null) { end -= contentPadding.left; end += centerLayout(suffixIcon!, end); } - if (suffix != null) + if (suffix != null) { end += baselineLayout(suffix!, end); + } break; } case TextDirection.ltr: { @@ -1383,18 +1415,22 @@ class _RenderDecoration extends RenderBox with SlottedContainerRenderObjectMixin centerLayout(label!, start); } } - if (prefix != null) + if (prefix != null) { start += baselineLayout(prefix!, start); - if (input != null) + } + if (input != null) { baselineLayout(input!, start); - if (hint != null) + } + if (hint != null) { baselineLayout(hint!, start); + } if (suffixIcon != null) { end += contentPadding.right; end -= centerLayout(suffixIcon!, end - suffixIcon!.size.width); } - if (suffix != null) + if (suffix != null) { end -= baselineLayout(suffix!, end - suffix!.size.width); + } break; } } @@ -1405,16 +1441,20 @@ class _RenderDecoration extends RenderBox with SlottedContainerRenderObjectMixin switch (textDirection) { case TextDirection.rtl: - if (helperError != null) + if (helperError != null) { baselineLayout(helperError!, right - helperError!.size.width - _boxSize(icon).width); - if (counter != null) + } + if (counter != null) { baselineLayout(counter!, left); + } break; case TextDirection.ltr: - if (helperError != null) + if (helperError != null) { baselineLayout(helperError!, left + _boxSize(icon).width); - if (counter != null) + } + if (counter != null) { baselineLayout(counter!, right - counter!.size.width); + } break; } } @@ -1460,8 +1500,9 @@ class _RenderDecoration extends RenderBox with SlottedContainerRenderObjectMixin @override void paint(PaintingContext context, Offset offset) { void doPaint(RenderBox? child) { - if (child != null) + if (child != null) { context.paintChild(child, _boxParentData(child).offset + offset); + } } doPaint(container); @@ -1537,8 +1578,9 @@ class _RenderDecoration extends RenderBox with SlottedContainerRenderObjectMixin return child.hitTest(result, position: transformed); }, ); - if (isHit) + if (isHit) { return true; + } } return false; } @@ -1882,17 +1924,19 @@ class _InputDecoratorState extends State with TickerProviderStat @override void didUpdateWidget(InputDecorator old) { super.didUpdateWidget(old); - if (widget.decoration != old.decoration) + if (widget.decoration != old.decoration) { _effectiveDecoration = null; + } final bool floatBehaviorChanged = widget.decoration.floatingLabelBehavior != old.decoration.floatingLabelBehavior; if (widget._labelShouldWithdraw != old._labelShouldWithdraw || floatBehaviorChanged) { if (_floatingLabelEnabled - && (widget._labelShouldWithdraw || widget.decoration.floatingLabelBehavior == FloatingLabelBehavior.always)) + && (widget._labelShouldWithdraw || widget.decoration.floatingLabelBehavior == FloatingLabelBehavior.always)) { _floatingLabelController.forward(); - else + } else { _floatingLabelController.reverse(); + } } final String? errorText = decoration!.errorText; @@ -1928,10 +1972,12 @@ class _InputDecoratorState extends State with TickerProviderStat } Color _getFillColor(ThemeData themeData) { - if (decoration!.filled != true) // filled == null same as filled == false + if (decoration!.filled != true) { // filled == null same as filled == false return Colors.transparent; - if (decoration!.fillColor != null) + } + if (decoration!.fillColor != null) { return MaterialStateProperty.resolveAs(decoration!.fillColor!, materialState); + } // dark theme: 10% white (enabled), 5% white (disabled) // light theme: 4% black (enabled), 2% black (disabled) @@ -1949,18 +1995,21 @@ class _InputDecoratorState extends State with TickerProviderStat } Color _getHoverColor(ThemeData themeData) { - if (decoration!.filled == null || !decoration!.filled! || isFocused || !decoration!.enabled) + if (decoration!.filled == null || !decoration!.filled! || isFocused || !decoration!.enabled) { return Colors.transparent; + } return decoration!.hoverColor ?? themeData.inputDecorationTheme.hoverColor ?? themeData.hoverColor; } Color _getIconColor(ThemeData themeData) { Color resolveIconColor(Set states) { - if (states.contains(MaterialState.disabled) && !states.contains(MaterialState.focused)) + if (states.contains(MaterialState.disabled) && !states.contains(MaterialState.focused)) { return themeData.disabledColor; + } - if (states.contains(MaterialState.focused)) + if (states.contains(MaterialState.focused)) { return themeData.colorScheme.primary; + } switch (themeData.brightness) { case Brightness.dark: @@ -2092,10 +2141,11 @@ class _InputDecoratorState extends State with TickerProviderStat } final double borderWeight; - if (decoration!.isCollapsed || decoration?.border == InputBorder.none || !decoration!.enabled) + if (decoration!.isCollapsed || decoration?.border == InputBorder.none || !decoration!.enabled) { borderWeight = 0.0; - else + } else { borderWeight = isFocused ? 2.0 : 1.0; + } return border.copyWith(borderSide: BorderSide(color: borderColor, width: borderWeight)); } @@ -2124,12 +2174,13 @@ class _InputDecoratorState extends State with TickerProviderStat final bool isError = decoration!.errorText != null; InputBorder? border; - if (!decoration!.enabled) + if (!decoration!.enabled) { border = isError ? decoration!.errorBorder : decoration!.disabledBorder; - else if (isFocused) + } else if (isFocused) { border = isError ? decoration!.focusedErrorBorder : decoration!.focusedBorder; - else + } else { border = isError ? decoration!.errorBorder : decoration!.enabledBorder; + } border ??= _getDefaultBorder(themeData); final Widget container = _BorderContainer( @@ -3498,10 +3549,12 @@ class InputDecoration { @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 InputDecoration && other.icon == icon && other.iconColor == iconColor @@ -4189,10 +4242,12 @@ class InputDecorationTheme 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 InputDecorationTheme && other.labelStyle == labelStyle && other.floatingLabelStyle == floatingLabelStyle diff --git a/packages/flutter/lib/src/material/list_tile.dart b/packages/flutter/lib/src/material/list_tile.dart index 3dd93577239f..972559f474cd 100644 --- a/packages/flutter/lib/src/material/list_tile.dart +++ b/packages/flutter/lib/src/material/list_tile.dart @@ -614,16 +614,18 @@ class ListTile extends StatelessWidget { } Color? _iconColor(ThemeData theme, ListTileThemeData tileTheme) { - if (!enabled) + if (!enabled) { return theme.disabledColor; + } if (selected) { return selectedColor ?? tileTheme.selectedColor ?? theme.listTileTheme.selectedColor ?? theme.colorScheme.primary; } final Color? color = iconColor ?? tileTheme.iconColor ?? theme.listTileTheme.iconColor; - if (color != null) + if (color != null) { return color; + } switch (theme.brightness) { case Brightness.light: @@ -636,8 +638,9 @@ class ListTile extends StatelessWidget { } Color? _textColor(ThemeData theme, ListTileThemeData tileTheme, Color? defaultColor) { - if (!enabled) + if (!enabled) { return theme.disabledColor; + } if (selected) { return selectedColor ?? tileTheme.selectedColor ?? theme.listTileTheme.selectedColor ?? theme.colorScheme.primary; @@ -977,8 +980,9 @@ class _RenderListTile extends RenderBox with SlottedContainerRenderObjectMixin<_ bool _isDense; set isDense(bool value) { assert(value != null); - if (_isDense == value) + if (_isDense == value) { return; + } _isDense = value; markNeedsLayout(); } @@ -987,8 +991,9 @@ class _RenderListTile extends RenderBox with SlottedContainerRenderObjectMixin<_ VisualDensity _visualDensity; set visualDensity(VisualDensity value) { assert(value != null); - if (_visualDensity == value) + if (_visualDensity == value) { return; + } _visualDensity = value; markNeedsLayout(); } @@ -997,8 +1002,9 @@ class _RenderListTile extends RenderBox with SlottedContainerRenderObjectMixin<_ bool _isThreeLine; set isThreeLine(bool value) { assert(value != null); - if (_isThreeLine == value) + if (_isThreeLine == value) { return; + } _isThreeLine = value; markNeedsLayout(); } @@ -1007,8 +1013,9 @@ class _RenderListTile extends RenderBox with SlottedContainerRenderObjectMixin<_ TextDirection _textDirection; set textDirection(TextDirection value) { assert(value != null); - if (_textDirection == value) + if (_textDirection == value) { return; + } _textDirection = value; markNeedsLayout(); } @@ -1017,8 +1024,9 @@ class _RenderListTile extends RenderBox with SlottedContainerRenderObjectMixin<_ TextBaseline _titleBaselineType; set titleBaselineType(TextBaseline value) { assert(value != null); - if (_titleBaselineType == value) + if (_titleBaselineType == value) { return; + } _titleBaselineType = value; markNeedsLayout(); } @@ -1026,8 +1034,9 @@ class _RenderListTile extends RenderBox with SlottedContainerRenderObjectMixin<_ TextBaseline? get subtitleBaselineType => _subtitleBaselineType; TextBaseline? _subtitleBaselineType; set subtitleBaselineType(TextBaseline? value) { - if (_subtitleBaselineType == value) + if (_subtitleBaselineType == value) { return; + } _subtitleBaselineType = value; markNeedsLayout(); } @@ -1038,8 +1047,9 @@ class _RenderListTile extends RenderBox with SlottedContainerRenderObjectMixin<_ set horizontalTitleGap(double value) { assert(value != null); - if (_horizontalTitleGap == value) + if (_horizontalTitleGap == value) { return; + } _horizontalTitleGap = value; markNeedsLayout(); } @@ -1049,8 +1059,9 @@ class _RenderListTile extends RenderBox with SlottedContainerRenderObjectMixin<_ set minVerticalPadding(double value) { assert(value != null); - if (_minVerticalPadding == value) + if (_minVerticalPadding == value) { return; + } _minVerticalPadding = value; markNeedsLayout(); } @@ -1060,8 +1071,9 @@ class _RenderListTile extends RenderBox with SlottedContainerRenderObjectMixin<_ set minLeadingWidth(double value) { assert(value != null); - if (_minLeadingWidth == value) + if (_minLeadingWidth == value) { return; + } _minLeadingWidth = value; markNeedsLayout(); } @@ -1103,10 +1115,12 @@ class _RenderListTile extends RenderBox with SlottedContainerRenderObjectMixin<_ final bool isOneLine = !isThreeLine && !hasSubtitle; final Offset baseDensity = visualDensity.baseSizeAdjustment; - if (isOneLine) + if (isOneLine) { return (isDense ? 48.0 : 56.0) + baseDensity.dy; - if (isTwoLine) + } + if (isTwoLine) { return (isDense ? 64.0 : 72.0) + baseDensity.dy; + } return (isDense ? 76.0 : 88.0) + baseDensity.dy; } @@ -1135,8 +1149,9 @@ class _RenderListTile extends RenderBox with SlottedContainerRenderObjectMixin<_ } static Size _layoutBox(RenderBox? box, BoxConstraints constraints) { - if (box == null) + if (box == null) { return Size.zero; + } box.layout(constraints, parentUsesSize: true); return box.size; } @@ -1272,23 +1287,29 @@ class _RenderListTile extends RenderBox with SlottedContainerRenderObjectMixin<_ switch (textDirection) { case TextDirection.rtl: { - if (hasLeading) + if (hasLeading) { _positionBox(leading!, Offset(tileWidth - leadingSize.width, leadingY)); + } _positionBox(title!, Offset(adjustedTrailingWidth, titleY)); - if (hasSubtitle) + if (hasSubtitle) { _positionBox(subtitle!, Offset(adjustedTrailingWidth, subtitleY!)); - if (hasTrailing) + } + if (hasTrailing) { _positionBox(trailing!, Offset(0.0, trailingY)); + } break; } case TextDirection.ltr: { - if (hasLeading) + if (hasLeading) { _positionBox(leading!, Offset(0.0, leadingY)); + } _positionBox(title!, Offset(titleStart, titleY)); - if (hasSubtitle) + if (hasSubtitle) { _positionBox(subtitle!, Offset(titleStart, subtitleY!)); - if (hasTrailing) + } + if (hasTrailing) { _positionBox(trailing!, Offset(tileWidth - trailingSize.width, trailingY)); + } break; } } @@ -1328,8 +1349,9 @@ class _RenderListTile extends RenderBox with SlottedContainerRenderObjectMixin<_ return child.hitTest(result, position: transformed); }, ); - if (isHit) + if (isHit) { return true; + } } return false; } diff --git a/packages/flutter/lib/src/material/list_tile_theme.dart b/packages/flutter/lib/src/material/list_tile_theme.dart index fcc5a8ebfcf9..7c15d6695d20 100644 --- a/packages/flutter/lib/src/material/list_tile_theme.dart +++ b/packages/flutter/lib/src/material/list_tile_theme.dart @@ -146,8 +146,9 @@ class ListTileThemeData with Diagnosticable { /// Linearly interpolate between ListTileThemeData objects. static ListTileThemeData? lerp(ListTileThemeData? a, ListTileThemeData? b, double t) { assert (t != null); - if (a == null && b == null) + if (a == null && b == null) { return null; + } return ListTileThemeData( dense: t < 0.5 ? a?.dense : b?.dense, shape: ShapeBorder.lerp(a?.shape, b?.shape, t), @@ -188,10 +189,12 @@ class ListTileThemeData 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 ListTileThemeData && other.dense == dense && other.shape == shape diff --git a/packages/flutter/lib/src/material/material.dart b/packages/flutter/lib/src/material/material.dart index 1542228e3053..6cc6724fa3bb 100644 --- a/packages/flutter/lib/src/material/material.dart +++ b/packages/flutter/lib/src/material/material.dart @@ -513,10 +513,12 @@ class _MaterialState extends State with TickerProviderStateMixin { // Otherwise, the shape is determined by the widget type as described in the // Material class documentation. ShapeBorder _getShape() { - if (widget.shape != null) + if (widget.shape != null) { return widget.shape!; - if (widget.borderRadius != null) + } + if (widget.borderRadius != null) { return RoundedRectangleBorder(borderRadius: widget.borderRadius!); + } switch (widget.type) { case MaterialType.canvas: case MaterialType.transparency: @@ -576,8 +578,9 @@ class _RenderInkFeatures extends RenderProxyBox implements MaterialInkController } void _didChangeLayout() { - if (_inkFeatures != null && _inkFeatures!.isNotEmpty) + if (_inkFeatures != null && _inkFeatures!.isNotEmpty) { markNeedsPaint(); + } } @override @@ -590,8 +593,9 @@ class _RenderInkFeatures extends RenderProxyBox implements MaterialInkController canvas.save(); canvas.translate(offset.dx, offset.dy); canvas.clipRect(Offset.zero & size); - for (final InkFeature inkFeature in _inkFeatures!) + for (final InkFeature inkFeature in _inkFeatures!) { inkFeature._paint(canvas); + } canvas.restore(); } super.paint(context, offset); @@ -697,8 +701,9 @@ abstract class InkFeature { // determine the transform that gets our coordinate system to be like theirs final Matrix4 transform = Matrix4.identity(); assert(descendants.length >= 2); - for (int index = descendants.length - 1; index > 0; index -= 1) + for (int index = descendants.length - 1; index > 0; index -= 1) { descendants[index].applyPaintTransform(descendants[index - 1], transform); + } paintFeature(canvas, transform); } diff --git a/packages/flutter/lib/src/material/material_localizations.dart b/packages/flutter/lib/src/material/material_localizations.dart index 9419f718fcd7..cd04b28d92c5 100644 --- a/packages/flutter/lib/src/material/material_localizations.dart +++ b/packages/flutter/lib/src/material/material_localizations.dart @@ -762,8 +762,9 @@ class DefaultMaterialLocalizations implements MaterialLocalizations { if (month == DateTime.february) { final bool isLeapYear = (year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0); - if (isLeapYear) + if (isLeapYear) { return 29; + } return 28; } const List daysInMonth = [31, -1, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; @@ -791,8 +792,9 @@ class DefaultMaterialLocalizations implements MaterialLocalizations { String _formatTwoDigitZeroPad(int number) { assert(0 <= number && number < 100); - if (number < 10) + if (number < 10) { return '0$number'; + } return '$number'; } @@ -968,16 +970,18 @@ class DefaultMaterialLocalizations implements MaterialLocalizations { @override String formatDecimal(int number) { - if (number > -1000 && number < 1000) + if (number > -1000 && number < 1000) { return number.toString(); + } final String digits = number.abs().toString(); final StringBuffer result = StringBuffer(number < 0 ? '-' : ''); final int maxDigitIndex = digits.length - 1; for (int i = 0; i <= maxDigitIndex; i += 1) { result.write(digits[i]); - if (i < maxDigitIndex && (maxDigitIndex - i) % 3 == 0) + if (i < maxDigitIndex && (maxDigitIndex - i) % 3 == 0) { result.write(','); + } } return result.toString(); } diff --git a/packages/flutter/lib/src/material/material_state_mixin.dart b/packages/flutter/lib/src/material/material_state_mixin.dart index 24b871edd6b3..2a8d9de2aff0 100644 --- a/packages/flutter/lib/src/material/material_state_mixin.dart +++ b/packages/flutter/lib/src/material/material_state_mixin.dart @@ -108,8 +108,9 @@ mixin MaterialStateMixin on State { @protected ValueChanged updateMaterialState(MaterialState key, {ValueChanged? onChanged}) { return (bool value) { - if (materialStates.contains(key) == value) + if (materialStates.contains(key) == value) { return; + } setMaterialState(key, value); onChanged?.call(value); }; @@ -124,15 +125,17 @@ mixin MaterialStateMixin on State { /// Mutator to mark a [MaterialState] value as active. @protected void addMaterialState(MaterialState state) { - if (materialStates.add(state)) + if (materialStates.add(state)) { setState((){}); + } } /// Mutator to mark a [MaterialState] value as inactive. @protected void removeMaterialState(MaterialState state) { - if (materialStates.remove(state)) + if (materialStates.remove(state)) { setState((){}); + } } /// Getter for whether this class considers [MaterialState.disabled] to be active. diff --git a/packages/flutter/lib/src/material/mergeable_material.dart b/packages/flutter/lib/src/material/mergeable_material.dart index e90c5daea368..1d16a684e2fa 100644 --- a/packages/flutter/lib/src/material/mergeable_material.dart +++ b/packages/flutter/lib/src/material/mergeable_material.dart @@ -211,8 +211,9 @@ class _MergeableMaterialState extends State with TickerProvid @override void dispose() { for (final MergeableMaterialItem child in _children) { - if (child is MaterialGap) + if (child is MaterialGap) { _animationTuples[child.key]!.controller.dispose(); + } } super.dispose(); } @@ -226,21 +227,24 @@ class _MergeableMaterialState extends State with TickerProvid bool _debugHasConsecutiveGaps(List children) { for (int i = 0; i < widget.children.length - 1; i += 1) { if (widget.children[i] is MaterialGap && - widget.children[i + 1] is MaterialGap) + widget.children[i + 1] is MaterialGap) { return true; + } } return false; } bool _debugGapsAreValid(List children) { // Check for consecutive gaps. - if (_debugHasConsecutiveGaps(children)) + if (_debugHasConsecutiveGaps(children)) { return false; + } // First and last children must not be gaps. if (children.isNotEmpty) { - if (children.first is MaterialGap || children.last is MaterialGap) + if (children.first is MaterialGap || children.last is MaterialGap) { return false; + } } return true; @@ -249,15 +253,17 @@ class _MergeableMaterialState extends State with TickerProvid void _insertChild(int index, MergeableMaterialItem child) { _children.insert(index, child); - if (child is MaterialGap) + if (child is MaterialGap) { _initGap(child); + } } void _removeChild(int index) { final MergeableMaterialItem child = _children.removeAt(index); - if (child is MaterialGap) + if (child is MaterialGap) { _animationTuples[child.key] = null; + } } bool _isClosingGap(int index) { @@ -312,12 +318,14 @@ class _MergeableMaterialState extends State with TickerProvid final int startOld = j; // Skip new keys. - while (newOnly.contains(newChildren[i].key)) + while (newOnly.contains(newChildren[i].key)) { i += 1; + } // Skip old keys. - while (oldOnly.contains(_children[j].key) || _isClosingGap(j)) + while (oldOnly.contains(_children[j].key) || _isClosingGap(j)) { j += 1; + } final int newLength = i - startNew; final int oldLength = j - startOld; @@ -348,10 +356,12 @@ class _MergeableMaterialState extends State with TickerProvid j += 1; } else { // No animation if replaced items are more than one. - for (int k = 0; k < oldLength; k += 1) + for (int k = 0; k < oldLength; k += 1) { _removeChild(startOld); - for (int k = 0; k < newLength; k += 1) + } + for (int k = 0; k < newLength; k += 1) { _insertChild(startOld + k, newChildren[startNew + k]); + } j += newLength - oldLength; } @@ -365,8 +375,9 @@ class _MergeableMaterialState extends State with TickerProvid _removeChild(startOld); - for (int k = 0; k < newLength; k += 1) + for (int k = 0; k < newLength; k += 1) { _insertChild(startOld + k, newChildren[startNew + k]); + } j += newLength - 1; double gapSizeSum = 0.0; @@ -457,8 +468,9 @@ class _MergeableMaterialState extends State with TickerProvid } // Handle remaining items. - while (j < _children.length) + while (j < _children.length) { _removeChild(j); + } while (i < newChildren.length) { _insertChild(j, newChildren[i]); @@ -515,10 +527,12 @@ class _MergeableMaterialState extends State with TickerProvid } bool _willNeedDivider(int index) { - if (index < 0) + if (index < 0) { return false; - if (index >= _children.length) + } + if (index >= _children.length) { return false; + } return _children[index] is MaterialSlice || _isClosingGap(index); } @@ -683,8 +697,9 @@ class _RenderMergeableMaterialListBody extends RenderListBody { double get elevation => _elevation; double _elevation; set elevation(double value) { - if (value == _elevation) + if (value == _elevation) { return; + } _elevation = value; markNeedsPaint(); } @@ -708,8 +723,9 @@ class _RenderMergeableMaterialListBody extends RenderListBody { while (child != null) { final ListBodyParentData childParentData = child.parentData! as ListBodyParentData; final Rect rect = (childParentData.offset + offset) & child.size; - if (index.isEven) + if (index.isEven) { _paintShadows(context.canvas, rect); + } child = childParentData.nextSibling; index += 1; } diff --git a/packages/flutter/lib/src/material/navigation_bar_theme.dart b/packages/flutter/lib/src/material/navigation_bar_theme.dart index cad96523ced4..25eb4537208d 100644 --- a/packages/flutter/lib/src/material/navigation_bar_theme.dart +++ b/packages/flutter/lib/src/material/navigation_bar_theme.dart @@ -117,8 +117,9 @@ class NavigationBarThemeData with Diagnosticable { /// {@macro dart.ui.shadow.lerp} static NavigationBarThemeData? lerp(NavigationBarThemeData? a, NavigationBarThemeData? b, double t) { assert(t != null); - if (a == null && b == null) + if (a == null && b == null) { return null; + } return NavigationBarThemeData( height: lerpDouble(a?.height, b?.height, t), backgroundColor: Color.lerp(a?.backgroundColor, b?.backgroundColor, t), @@ -147,10 +148,12 @@ class NavigationBarThemeData 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 NavigationBarThemeData && other.height == height && other.backgroundColor == backgroundColor @@ -184,8 +187,9 @@ class NavigationBarThemeData with Diagnosticable { T Function(T?, T?, double) lerpFunction, ) { // Avoid creating a _LerpProperties object for a common case. - if (a == null && b == null) + if (a == null && b == null) { return null; + } return _LerpProperties(a, b, t, lerpFunction); } } diff --git a/packages/flutter/lib/src/material/navigation_rail.dart b/packages/flutter/lib/src/material/navigation_rail.dart index 2b8656974b4f..02074fb1abc0 100644 --- a/packages/flutter/lib/src/material/navigation_rail.dart +++ b/packages/flutter/lib/src/material/navigation_rail.dart @@ -436,8 +436,9 @@ class _NavigationRailState extends State with TickerProviderStat useIndicator: useIndicator, indicatorColor: useIndicator ? indicatorColor : null, onTap: () { - if (widget.onDestinationSelected != null) + if (widget.onDestinationSelected != null) { widget.onDestinationSelected!(i); + } }, indexLabel: localizations.tabLabel( tabIndex: i + 1, diff --git a/packages/flutter/lib/src/material/navigation_rail_theme.dart b/packages/flutter/lib/src/material/navigation_rail_theme.dart index 4e1c872cd7f0..dd5de72ac508 100644 --- a/packages/flutter/lib/src/material/navigation_rail_theme.dart +++ b/packages/flutter/lib/src/material/navigation_rail_theme.dart @@ -135,8 +135,9 @@ class NavigationRailThemeData with Diagnosticable { /// {@macro dart.ui.shadow.lerp} static NavigationRailThemeData? lerp(NavigationRailThemeData? a, NavigationRailThemeData? b, double t) { assert(t != null); - if (a == null && b == null) + if (a == null && b == null) { return null; + } return NavigationRailThemeData( backgroundColor: Color.lerp(a?.backgroundColor, b?.backgroundColor, t), elevation: lerpDouble(a?.elevation, b?.elevation, t), @@ -172,10 +173,12 @@ class NavigationRailThemeData 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 NavigationRailThemeData && other.backgroundColor == backgroundColor && other.elevation == elevation diff --git a/packages/flutter/lib/src/material/outlined_button.dart b/packages/flutter/lib/src/material/outlined_button.dart index 78681b41c299..7e21de3a0b93 100644 --- a/packages/flutter/lib/src/material/outlined_button.dart +++ b/packages/flutter/lib/src/material/outlined_button.dart @@ -336,8 +336,9 @@ class _OutlinedButtonDefaultForeground extends MaterialStateProperty wi @override Color? resolve(Set states) { - if (states.contains(MaterialState.disabled)) + if (states.contains(MaterialState.disabled)) { return onSurface?.withOpacity(0.38); + } return primary; } } @@ -350,10 +351,12 @@ class _OutlinedButtonDefaultOverlay extends MaterialStateProperty with D @override Color? resolve(Set states) { - if (states.contains(MaterialState.hovered)) + if (states.contains(MaterialState.hovered)) { return primary.withOpacity(0.04); - if (states.contains(MaterialState.focused) || states.contains(MaterialState.pressed)) + } + if (states.contains(MaterialState.focused) || states.contains(MaterialState.pressed)) { return primary.withOpacity(0.12); + } return null; } } @@ -367,8 +370,9 @@ class _OutlinedButtonDefaultMouseCursor extends MaterialStateProperty states) { - if (states.contains(MaterialState.disabled)) + if (states.contains(MaterialState.disabled)) { return disabledCursor; + } return enabledCursor; } } @@ -442,20 +446,24 @@ class _TokenDefaultsM3 extends ButtonStyle { @override MaterialStateProperty? get foregroundColor => MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.disabled)) + if (states.contains(MaterialState.disabled)) { return _colors.onSurface.withOpacity(0.38); + } return _colors.primary; }); @override MaterialStateProperty? get overlayColor => MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.hovered)) + if (states.contains(MaterialState.hovered)) { return _colors.primary.withOpacity(0.08); - if (states.contains(MaterialState.focused)) + } + if (states.contains(MaterialState.focused)) { return _colors.primary.withOpacity(0.12); - if (states.contains(MaterialState.pressed)) + } + if (states.contains(MaterialState.pressed)) { return _colors.primary.withOpacity(0.12); + } return null; }); @@ -484,8 +492,9 @@ class _TokenDefaultsM3 extends ButtonStyle { @override MaterialStateProperty? get side => MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.disabled)) + if (states.contains(MaterialState.disabled)) { return BorderSide(color: _colors.onSurface.withOpacity(0.12)); + } return BorderSide(color: _colors.outline); }); @@ -496,8 +505,9 @@ class _TokenDefaultsM3 extends ButtonStyle { @override MaterialStateProperty? get mouseCursor => MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.disabled)) + if (states.contains(MaterialState.disabled)) { return SystemMouseCursors.basic; + } return SystemMouseCursors.click; }); diff --git a/packages/flutter/lib/src/material/outlined_button_theme.dart b/packages/flutter/lib/src/material/outlined_button_theme.dart index 9cc01c115d07..20eb53f6a62a 100644 --- a/packages/flutter/lib/src/material/outlined_button_theme.dart +++ b/packages/flutter/lib/src/material/outlined_button_theme.dart @@ -47,8 +47,9 @@ class OutlinedButtonThemeData with Diagnosticable { /// Linearly interpolate between two outlined button themes. static OutlinedButtonThemeData? lerp(OutlinedButtonThemeData? a, OutlinedButtonThemeData? b, double t) { assert (t != null); - if (a == null && b == null) + if (a == null && b == null) { return null; + } return OutlinedButtonThemeData( style: ButtonStyle.lerp(a?.style, b?.style, t), ); @@ -59,10 +60,12 @@ class OutlinedButtonThemeData 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 OutlinedButtonThemeData && other.style == style; } diff --git a/packages/flutter/lib/src/material/page_transitions_theme.dart b/packages/flutter/lib/src/material/page_transitions_theme.dart index be8e5bb07d30..ec3d2a9f7671 100644 --- a/packages/flutter/lib/src/material/page_transitions_theme.dart +++ b/packages/flutter/lib/src/material/page_transitions_theme.dart @@ -584,8 +584,9 @@ class PageTransitionsTheme with Diagnosticable { ) { TargetPlatform platform = Theme.of(context).platform; - if (CupertinoRouteTransitionMixin.isPopGestureInProgress(route)) + if (CupertinoRouteTransitionMixin.isPopGestureInProgress(route)) { platform = TargetPlatform.iOS; + } final PageTransitionsBuilder matchingBuilder = builders[platform] ?? const ZoomPageTransitionsBuilder(); @@ -600,12 +601,15 @@ class PageTransitionsTheme 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; - if (other is PageTransitionsTheme && identical(builders, other.builders)) + } + if (other is PageTransitionsTheme && identical(builders, other.builders)) { return true; + } return other is PageTransitionsTheme && listEquals(_all(other.builders), _all(builders)); } diff --git a/packages/flutter/lib/src/material/paginated_data_table.dart b/packages/flutter/lib/src/material/paginated_data_table.dart index 82070fe90046..567afe26e9a3 100644 --- a/packages/flutter/lib/src/material/paginated_data_table.dart +++ b/packages/flutter/lib/src/material/paginated_data_table.dart @@ -103,8 +103,9 @@ class PaginatedDataTable extends StatefulWidget { assert(rowsPerPage != null), assert(rowsPerPage > 0), assert(() { - if (onRowsPerPageChanged != null) + if (onRowsPerPageChanged != null) { assert(availableRowsPerPage != null && availableRowsPerPage.contains(rowsPerPage)); + } return true; }()), assert(source != null), @@ -304,8 +305,9 @@ class PaginatedDataTableState extends State { _firstRowIndex = (rowIndex ~/ rowsPerPage) * rowsPerPage; }); if ((widget.onPageChanged != null) && - (oldFirstRowIndex != _firstRowIndex)) + (oldFirstRowIndex != _firstRowIndex)) { widget.onPageChanged!(_firstRowIndex); + } } DataRow _getBlankRowFor(int index) { diff --git a/packages/flutter/lib/src/material/popup_menu.dart b/packages/flutter/lib/src/material/popup_menu.dart index 30111ba4e1ba..01a4644392b8 100644 --- a/packages/flutter/lib/src/material/popup_menu.dart +++ b/packages/flutter/lib/src/material/popup_menu.dart @@ -347,8 +347,9 @@ class PopupMenuItemState> extends State { final PopupMenuThemeData popupMenuTheme = PopupMenuTheme.of(context); TextStyle style = widget.textStyle ?? popupMenuTheme.textStyle ?? theme.textTheme.subtitle1!; - if (!widget.enabled) + if (!widget.enabled) { style = style.copyWith(color: theme.disabledColor); + } Widget item = AnimatedDefaultTextStyle( style: style, @@ -503,10 +504,11 @@ class _CheckedPopupMenuItemState extends PopupMenuItemState screen.right - _kMenuScreenPadding - padding.right) + } else if (x + childSize.width > screen.right - _kMenuScreenPadding - padding.right) { x = screen.right - childSize.width - _kMenuScreenPadding - padding.right; - if (y < screen.top + _kMenuScreenPadding + padding.top) + } + if (y < screen.top + _kMenuScreenPadding + padding.top) { y = _kMenuScreenPadding + padding.top; - else if (y + childSize.height > screen.bottom - _kMenuScreenPadding - padding.bottom) + } else if (y + childSize.height > screen.bottom - _kMenuScreenPadding - padding.bottom) { y = screen.bottom - childSize.height - _kMenuScreenPadding - padding.bottom; + } return Offset(x,y); } @@ -801,8 +806,9 @@ class _PopupMenuRoute extends PopupRoute { int? selectedItemIndex; if (initialValue != null) { for (int index = 0; selectedItemIndex == null && index < items.length; index += 1) { - if (items[index].represents(initialValue)) + if (items[index].represents(initialValue)) { selectedItemIndex = index; + } } } @@ -1188,8 +1194,9 @@ class PopupMenuButtonState extends State> { constraints: widget.constraints, ) .then((T? newValue) { - if (!mounted) + if (!mounted) { return null; + } if (newValue == null) { widget.onCanceled?.call(); return null; @@ -1218,7 +1225,7 @@ class PopupMenuButtonState extends State> { assert(debugCheckHasMaterialLocalizations(context)); - if (widget.child != null) + if (widget.child != null) { return Tooltip( message: widget.tooltip ?? MaterialLocalizations.of(context).showMenuTooltip, child: InkWell( @@ -1229,6 +1236,7 @@ class PopupMenuButtonState extends State> { child: widget.child, ), ); + } return IconButton( icon: widget.icon ?? Icon(Icons.adaptive.more), diff --git a/packages/flutter/lib/src/material/popup_menu_theme.dart b/packages/flutter/lib/src/material/popup_menu_theme.dart index 16282c406ee8..65142052b8b6 100644 --- a/packages/flutter/lib/src/material/popup_menu_theme.dart +++ b/packages/flutter/lib/src/material/popup_menu_theme.dart @@ -91,8 +91,9 @@ class PopupMenuThemeData with Diagnosticable { /// {@macro dart.ui.shadow.lerp} static PopupMenuThemeData? lerp(PopupMenuThemeData? a, PopupMenuThemeData? b, double t) { assert(t != null); - if (a == null && b == null) + if (a == null && b == null) { return null; + } return PopupMenuThemeData( color: Color.lerp(a?.color, b?.color, t), shape: ShapeBorder.lerp(a?.shape, b?.shape, t), @@ -115,10 +116,12 @@ class PopupMenuThemeData 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 PopupMenuThemeData && other.elevation == elevation && other.color == color diff --git a/packages/flutter/lib/src/material/progress_indicator.dart b/packages/flutter/lib/src/material/progress_indicator.dart index 43932ddd45c8..b533186399fa 100644 --- a/packages/flutter/lib/src/material/progress_indicator.dart +++ b/packages/flutter/lib/src/material/progress_indicator.dart @@ -186,8 +186,9 @@ class _LinearProgressIndicatorPainter extends CustomPainter { paint.color = valueColor; void drawBar(double x, double width) { - if (width <= 0.0) + if (width <= 0.0) { return; + } final double left; switch (textDirection) { @@ -308,17 +309,19 @@ class _LinearProgressIndicatorState extends State with duration: const Duration(milliseconds: _kIndeterminateLinearDuration), vsync: this, ); - if (widget.value == null) + if (widget.value == null) { _controller.repeat(); + } } @override void didUpdateWidget(LinearProgressIndicator oldWidget) { super.didUpdateWidget(oldWidget); - if (widget.value == null && !_controller.isAnimating) + if (widget.value == null && !_controller.isAnimating) { _controller.repeat(); - else if (widget.value != null && _controller.isAnimating) + } else if (widget.value != null && _controller.isAnimating) { _controller.stop(); + } } @override @@ -359,8 +362,9 @@ class _LinearProgressIndicatorState extends State with Widget build(BuildContext context) { final TextDirection textDirection = Directionality.of(context); - if (widget.value != null) + if (widget.value != null) { return _buildIndicator(context, _controller.value, textDirection); + } return AnimatedBuilder( animation: _controller.view, @@ -419,8 +423,9 @@ class _CircularProgressIndicatorPainter extends CustomPainter { canvas.drawArc(Offset.zero & size, 0, _sweep, false, backgroundPaint); } - if (value == null) // Indeterminate + if (value == null) { // Indeterminate paint.strokeCap = StrokeCap.square; + } canvas.drawArc(Offset.zero & size, arcStart, arcSweep, false, paint); } @@ -548,17 +553,19 @@ class _CircularProgressIndicatorState extends State w duration: const Duration(milliseconds: _kIndeterminateCircularDuration), vsync: this, ); - if (widget.value == null) + if (widget.value == null) { _controller.repeat(); + } } @override void didUpdateWidget(CircularProgressIndicator oldWidget) { super.didUpdateWidget(oldWidget); - if (widget.value == null && !_controller.isAnimating) + if (widget.value == null && !_controller.isAnimating) { _controller.repeat(); - else if (widget.value != null && _controller.isAnimating) + } else if (widget.value != null && _controller.isAnimating) { _controller.stop(); + } } @override @@ -617,8 +624,9 @@ class _CircularProgressIndicatorState extends State w Widget build(BuildContext context) { switch (widget._indicatorType) { case _ActivityIndicatorType.material: - if (widget.value != null) + if (widget.value != null) { return _buildMaterialIndicator(context, 0.0, 0.0, 0, 0.0); + } return _buildAnimation(); case _ActivityIndicatorType.adaptive: final ThemeData theme = Theme.of(context); @@ -631,8 +639,9 @@ class _CircularProgressIndicatorState extends State w case TargetPlatform.fuchsia: case TargetPlatform.linux: case TargetPlatform.windows: - if (widget.value != null) + if (widget.value != null) { return _buildMaterialIndicator(context, 0.0, 0.0, 0, 0.0); + } return _buildAnimation(); } } @@ -683,8 +692,9 @@ class _RefreshProgressIndicatorPainter extends _CircularProgressIndicatorPainter @override void paint(Canvas canvas, Size size) { super.paint(canvas, size); - if (arrowheadScale > 0.0) + if (arrowheadScale > 0.0) { paintArrowhead(canvas, size); + } } } diff --git a/packages/flutter/lib/src/material/progress_indicator_theme.dart b/packages/flutter/lib/src/material/progress_indicator_theme.dart index 188f8e6d19b3..946f519c48ef 100644 --- a/packages/flutter/lib/src/material/progress_indicator_theme.dart +++ b/packages/flutter/lib/src/material/progress_indicator_theme.dart @@ -81,8 +81,9 @@ class ProgressIndicatorThemeData with Diagnosticable { /// /// If both arguments are null, then null is returned. static ProgressIndicatorThemeData? lerp(ProgressIndicatorThemeData? a, ProgressIndicatorThemeData? b, double t) { - if (a == null && b == null) + if (a == null && b == null) { return null; + } assert(t != null); return ProgressIndicatorThemeData( color: Color.lerp(a?.color, b?.color, t), @@ -104,10 +105,12 @@ class ProgressIndicatorThemeData 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 ProgressIndicatorThemeData && other.color == color && other.linearTrackColor == linearTrackColor diff --git a/packages/flutter/lib/src/material/radio_theme.dart b/packages/flutter/lib/src/material/radio_theme.dart index 66e7b8a408db..485fb2ef3d9f 100644 --- a/packages/flutter/lib/src/material/radio_theme.dart +++ b/packages/flutter/lib/src/material/radio_theme.dart @@ -131,10 +131,12 @@ class RadioThemeData 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 RadioThemeData && other.mouseCursor == mouseCursor && other.fillColor == fillColor @@ -162,8 +164,9 @@ class RadioThemeData with Diagnosticable { T Function(T?, T?, double) lerpFunction, ) { // Avoid creating a _LerpProperties object for a common case. - if (a == null && b == null) + if (a == null && b == null) { return null; + } return _LerpProperties(a, b, t, lerpFunction); } } diff --git a/packages/flutter/lib/src/material/range_slider.dart b/packages/flutter/lib/src/material/range_slider.dart index 17039d23ddfe..5947a6aae050 100644 --- a/packages/flutter/lib/src/material/range_slider.dart +++ b/packages/flutter/lib/src/material/range_slider.dart @@ -432,8 +432,9 @@ class _RangeSliderState extends State with TickerProviderStateMixin @override void didUpdateWidget(RangeSlider oldWidget) { super.didUpdateWidget(oldWidget); - if (oldWidget.onChanged == widget.onChanged) + if (oldWidget.onChanged == widget.onChanged) { return; + } final bool wasEnabled = oldWidget.onChanged != null; final bool isEnabled = widget.onChanged != null; if (wasEnabled != isEnabled) { @@ -533,16 +534,20 @@ class _RangeSliderState extends State with TickerProviderStateMixin towardsEnd = dx < 0; break; } - if (towardsStart) + if (towardsStart) { return Thumb.start; - if (towardsEnd) + } + if (towardsEnd) { return Thumb.end; + } } else { // Snap position on the track if its in the inactive range. - if (tapValue < values.start || inStartTouchTarget) + if (tapValue < values.start || inStartTouchTarget) { return Thumb.start; - if (tapValue > values.end || inEndTouchTarget) + } + if (tapValue > values.end || inEndTouchTarget) { return Thumb.end; + } } return null; } @@ -870,8 +875,9 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix TargetPlatform _platform; TargetPlatform get platform => _platform; set platform(TargetPlatform value) { - if (_platform == value) + if (_platform == value) { return; + } _platform = value; markNeedsSemanticsUpdate(); } @@ -879,8 +885,9 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix SemanticFormatterCallback? _semanticFormatterCallback; SemanticFormatterCallback? get semanticFormatterCallback => _semanticFormatterCallback; set semanticFormatterCallback(SemanticFormatterCallback? value) { - if (_semanticFormatterCallback == value) + if (_semanticFormatterCallback == value) { return; + } _semanticFormatterCallback = value; markNeedsSemanticsUpdate(); } @@ -898,8 +905,9 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix RangeLabels? get labels => _labels; RangeLabels? _labels; set labels(RangeLabels? labels) { - if (labels == _labels) + if (labels == _labels) { return; + } _labels = labels; _updateLabelPainters(); } @@ -907,8 +915,9 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix SliderThemeData get sliderTheme => _sliderTheme; SliderThemeData _sliderTheme; set sliderTheme(SliderThemeData value) { - if (value == _sliderTheme) + if (value == _sliderTheme) { return; + } _sliderTheme = value; markNeedsPaint(); } @@ -916,8 +925,9 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix ThemeData? get theme => _theme; ThemeData? _theme; set theme(ThemeData? value) { - if (value == _theme) + if (value == _theme) { return; + } _theme = value; markNeedsPaint(); } @@ -925,8 +935,9 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix double get textScaleFactor => _textScaleFactor; double _textScaleFactor; set textScaleFactor(double value) { - if (value == _textScaleFactor) + if (value == _textScaleFactor) { return; + } _textScaleFactor = value; _updateLabelPainters(); } @@ -934,8 +945,9 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix Size get screenSize => _screenSize; Size _screenSize; set screenSize(Size value) { - if (value == screenSize) + if (value == screenSize) { return; + } _screenSize = value; markNeedsPaint(); } @@ -943,8 +955,9 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix ValueChanged? get onChanged => _onChanged; ValueChanged? _onChanged; set onChanged(ValueChanged? value) { - if (value == _onChanged) + if (value == _onChanged) { return; + } final bool wasEnabled = isEnabled; _onChanged = value; if (wasEnabled != isEnabled) { @@ -960,8 +973,9 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix TextDirection _textDirection; set textDirection(TextDirection value) { assert(value != null); - if (value == _textDirection) + if (value == _textDirection) { return; + } _textDirection = value; _updateLabelPainters(); } @@ -1002,8 +1016,9 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix } void _updateLabelPainter(Thumb thumb) { - if (labels == null) + if (labels == null) { return; + } final String text; final TextPainter labelPainter; diff --git a/packages/flutter/lib/src/material/refresh_indicator.dart b/packages/flutter/lib/src/material/refresh_indicator.dart index 34b19ebc56e1..0bb5ec7f311b 100644 --- a/packages/flutter/lib/src/material/refresh_indicator.dart +++ b/packages/flutter/lib/src/material/refresh_indicator.dart @@ -310,8 +310,9 @@ class RefreshIndicatorState extends State with TickerProviderS } bool _handleScrollNotification(ScrollNotification notification) { - if (!widget.notificationPredicate(notification)) + if (!widget.notificationPredicate(notification)) { return false; + } if (_shouldStart(notification)) { setState(() { _mode = _RefreshIndicatorMode.drag; @@ -330,8 +331,9 @@ class RefreshIndicatorState extends State with TickerProviderS break; } if (indicatorAtTopNow != _isIndicatorAtTop) { - if (_mode == _RefreshIndicatorMode.drag || _mode == _RefreshIndicatorMode.armed) + if (_mode == _RefreshIndicatorMode.drag || _mode == _RefreshIndicatorMode.armed) { _dismiss(_RefreshIndicatorMode.canceled); + } } else if (notification is ScrollUpdateNotification) { if (_mode == _RefreshIndicatorMode.drag || _mode == _RefreshIndicatorMode.armed) { if ((notification.metrics.axisDirection == AxisDirection.down && notification.metrics.extentBefore > 0.0) @@ -382,8 +384,9 @@ class RefreshIndicatorState extends State with TickerProviderS } bool _handleGlowNotification(OverscrollIndicatorNotification notification) { - if (notification.depth != 0 || !notification.leading) + if (notification.depth != 0 || !notification.leading) { return false; + } if (_mode == _RefreshIndicatorMode.drag) { notification.disallowGlow(); return true; @@ -415,11 +418,13 @@ class RefreshIndicatorState extends State with TickerProviderS void _checkDragOffset(double containerExtent) { assert(_mode == _RefreshIndicatorMode.drag || _mode == _RefreshIndicatorMode.armed); double newValue = _dragOffset! / (containerExtent * _kDragContainerExtentPercentage); - if (_mode == _RefreshIndicatorMode.armed) + if (_mode == _RefreshIndicatorMode.armed) { newValue = math.max(newValue, 1.0 / _kDragSizeFactorLimit); + } _positionController.value = clampDouble(newValue, 0.0, 1.0); // this triggers various rebuilds - if (_mode == _RefreshIndicatorMode.drag && _valueColor.value!.alpha == 0xFF) + if (_mode == _RefreshIndicatorMode.drag && _valueColor.value!.alpha == 0xFF) { _mode = _RefreshIndicatorMode.armed; + } } // Stop showing the refresh indicator. @@ -472,7 +477,7 @@ class RefreshIndicatorState extends State with TickerProviderS final Future refreshResult = widget.onRefresh(); assert(() { - if (refreshResult == null) + if (refreshResult == null) { FlutterError.reportError(FlutterErrorDetails( exception: FlutterError( 'The onRefresh callback returned null.\n' @@ -481,10 +486,12 @@ class RefreshIndicatorState extends State with TickerProviderS context: ErrorDescription('when calling onRefresh'), library: 'material library', )); + } return true; }()); - if (refreshResult == null) + if (refreshResult == null) { return; + } refreshResult.whenComplete(() { if (mounted && _mode == _RefreshIndicatorMode.refresh) { completer.complete(); @@ -514,8 +521,9 @@ class RefreshIndicatorState extends State with TickerProviderS Future show({ bool atTop = true }) { if (_mode != _RefreshIndicatorMode.refresh && _mode != _RefreshIndicatorMode.snap) { - if (_mode == null) + if (_mode == null) { _start(atTop ? AxisDirection.down : AxisDirection.up); + } _show(); } return _pendingRefreshFuture; diff --git a/packages/flutter/lib/src/material/reorderable_list.dart b/packages/flutter/lib/src/material/reorderable_list.dart index 91bb59f544b1..cb79aebf6bcf 100644 --- a/packages/flutter/lib/src/material/reorderable_list.dart +++ b/packages/flutter/lib/src/material/reorderable_list.dart @@ -275,8 +275,9 @@ class ReorderableListView extends StatefulWidget { class _ReorderableListViewState extends State { Widget _wrapWithSemantics(Widget child, int index) { void reorder(int startIndex, int endIndex) { - if (startIndex != endIndex) + if (startIndex != endIndex) { widget.onReorder(startIndex, endIndex); + } } // First, determine which semantics actions apply. @@ -525,8 +526,9 @@ class _ReorderableListViewChildGlobalKey extends GlobalObjectKey { @override bool operator ==(Object other) { - if (other.runtimeType != runtimeType) + if (other.runtimeType != runtimeType) { return false; + } return other is _ReorderableListViewChildGlobalKey && other.subKey == subKey && other.state == state; diff --git a/packages/flutter/lib/src/material/scaffold.dart b/packages/flutter/lib/src/material/scaffold.dart index b9f6538639c8..9d5c753bf9d6 100644 --- a/packages/flutter/lib/src/material/scaffold.dart +++ b/packages/flutter/lib/src/material/scaffold.dart @@ -329,11 +329,13 @@ class ScaffoldMessengerState extends State with TickerProvide /// any queued snack bars, they begin their entrance animation immediately. void removeCurrentSnackBar({ SnackBarClosedReason reason = SnackBarClosedReason.remove }) { assert(reason != null); - if (_snackBars.isEmpty) + if (_snackBars.isEmpty) { return; + } final Completer completer = _snackBars.first._completer; - if (!completer.isCompleted) + if (!completer.isCompleted) { completer.complete(reason); + } _snackBarTimer?.cancel(); _snackBarTimer = null; // This will trigger the animation's status callback. @@ -345,8 +347,9 @@ class ScaffoldMessengerState extends State with TickerProvide /// The closed completer is called after the animation is complete. void hideCurrentSnackBar({ SnackBarClosedReason reason = SnackBarClosedReason.hide }) { assert(reason != null); - if (_snackBars.isEmpty || _snackBarController!.status == AnimationStatus.dismissed) + if (_snackBars.isEmpty || _snackBarController!.status == AnimationStatus.dismissed) { return; + } final Completer completer = _snackBars.first._completer; if (_accessibleNavigation!) { _snackBarController!.value = 0.0; @@ -354,8 +357,9 @@ class ScaffoldMessengerState extends State with TickerProvide } else { _snackBarController!.reverse().then((void value) { assert(mounted); - if (!completer.isCompleted) + if (!completer.isCompleted) { completer.complete(reason); + } }); } _snackBarTimer?.cancel(); @@ -365,8 +369,9 @@ class ScaffoldMessengerState extends State with TickerProvide /// Removes all the snackBars currently in queue by clearing the queue /// and running normal exit animation on the current snackBar. void clearSnackBars() { - if (_snackBars.isEmpty || _snackBarController!.status == AnimationStatus.dismissed) + if (_snackBars.isEmpty || _snackBarController!.status == AnimationStatus.dismissed) { return; + } final ScaffoldFeatureController currentSnackbar = _snackBars.first; _snackBars.clear(); _snackBars.add(currentSnackbar); @@ -456,11 +461,13 @@ class ScaffoldMessengerState extends State with TickerProvide /// any queued material banners, they begin their entrance animation immediately. void removeCurrentMaterialBanner({ MaterialBannerClosedReason reason = MaterialBannerClosedReason.remove }) { assert(reason != null); - if (_materialBanners.isEmpty) + if (_materialBanners.isEmpty) { return; + } final Completer completer = _materialBanners.first._completer; - if (!completer.isCompleted) + if (!completer.isCompleted) { completer.complete(reason); + } // This will trigger the animation's status callback. _materialBannerController!.value = 0.0; @@ -471,8 +478,9 @@ class ScaffoldMessengerState extends State with TickerProvide /// The closed completer is called after the animation is complete. void hideCurrentMaterialBanner({ MaterialBannerClosedReason reason = MaterialBannerClosedReason.hide }) { assert(reason != null); - if (_materialBanners.isEmpty || _materialBannerController!.status == AnimationStatus.dismissed) + if (_materialBanners.isEmpty || _materialBannerController!.status == AnimationStatus.dismissed) { return; + } final Completer completer = _materialBanners.first._completer; if (_accessibleNavigation!) { _materialBannerController!.value = 0.0; @@ -480,8 +488,9 @@ class ScaffoldMessengerState extends State with TickerProvide } else { _materialBannerController!.reverse().then((void value) { assert(mounted); - if (!completer.isCompleted) + if (!completer.isCompleted) { completer.complete(reason); + } }); } } @@ -489,8 +498,9 @@ class ScaffoldMessengerState extends State with TickerProvide /// Removes all the [MaterialBanner]s currently in queue by clearing the queue /// and running normal exit animation on the current [MaterialBanner]. void clearMaterialBanners() { - if (_materialBanners.isEmpty || _materialBannerController!.status == AnimationStatus.dismissed) + if (_materialBanners.isEmpty || _materialBannerController!.status == AnimationStatus.dismissed) { return; + } final ScaffoldFeatureController currentMaterialBanner = _materialBanners.first; _materialBanners.clear(); _materialBanners.add(currentMaterialBanner); @@ -515,8 +525,9 @@ class ScaffoldMessengerState extends State with TickerProvide ); // Look up MediaQuery again in case the setting changed. final MediaQueryData mediaQuery = MediaQuery.of(context); - if (mediaQuery.accessibleNavigation && snackBar.action != null) + if (mediaQuery.accessibleNavigation && snackBar.action != null) { return; + } hideCurrentSnackBar(reason: SnackBarClosedReason.timeout); }); } @@ -728,8 +739,9 @@ class ScaffoldGeometry { final Rect? floatingActionButtonArea; ScaffoldGeometry _scaleFloatingActionButton(double scaleFactor) { - if (scaleFactor == 1.0) + if (scaleFactor == 1.0) { return this; + } if (scaleFactor == 0.0) { return ScaffoldGeometry( @@ -770,12 +782,13 @@ class _ScaffoldGeometryNotifier extends ChangeNotifier implements ValueListenabl ScaffoldGeometry get value { assert(() { final RenderObject? renderObject = context.findRenderObject(); - if (renderObject == null || !renderObject.owner!.debugDoingPaint) + if (renderObject == null || !renderObject.owner!.debugDoingPaint) { throw FlutterError( 'Scaffold.geometryOf() must only be accessed during the paint phase.\n' 'The ScaffoldGeometry is only available during the paint phase, because ' 'its value is computed during the animation and layout phases prior to painting.', ); + } return true; }()); return geometry._scaleFloatingActionButton(floatingActionButtonScale!); @@ -828,8 +841,9 @@ class _BodyBoxConstraints extends BoxConstraints { // min and max values have not, we still want performLayout to happen. @override bool operator ==(Object other) { - if (super != other) + if (super != other) { return false; + } return other is _BodyBoxConstraints && other.materialBannerHeight == materialBannerHeight && other.bottomWidgetsHeight == bottomWidgetsHeight @@ -861,8 +875,9 @@ class _BodyBuilder extends StatelessWidget { @override Widget build(BuildContext context) { - if (!extendBody && !extendBodyBehindAppBar) + if (!extendBody && !extendBodyBehindAppBar) { return body; + } return LayoutBuilder( builder: (BuildContext context, BoxConstraints constraints) { @@ -1213,8 +1228,9 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr super.didUpdateWidget(oldWidget); final bool oldChildIsNull = oldWidget.child == null; final bool newChildIsNull = widget.child == null; - if (oldChildIsNull == newChildIsNull && oldWidget.child?.key == widget.child?.key) + if (oldChildIsNull == newChildIsNull && oldWidget.child?.key == widget.child?.key) { return; + } if (oldWidget.fabMotionAnimator != widget.fabMotionAnimator || oldWidget.fabMoveAnimation != widget.fabMoveAnimation) { // Get the right scale and rotation animations to use for this widget. _updateAnimations(); @@ -1225,8 +1241,9 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr // The current child hasn't started its entrance animation yet. We can // just skip directly to the new child's entrance. _previousChild = null; - if (widget.child != null) + if (widget.child != null) { widget.currentController.forward(); + } } else { // Otherwise, we need to copy the state from the current controller to // the previous controller and run an exit animation for the previous @@ -1284,8 +1301,9 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr setState(() { if (status == AnimationStatus.dismissed) { assert(widget.currentController.status == AnimationStatus.dismissed); - if (widget.child != null) + if (widget.child != null) { widget.currentController.forward(); + } } }); } @@ -1787,8 +1805,9 @@ class Scaffold extends StatefulWidget { static ScaffoldState of(BuildContext context) { assert(context != null); final ScaffoldState? result = context.findAncestorStateOfType(); - if (result != null) + if (result != null) { return result; + } throw FlutterError.fromParts([ ErrorSummary( 'Scaffold.of() called with a context that does not contain a Scaffold.', @@ -1857,7 +1876,7 @@ class Scaffold extends StatefulWidget { /// listenable. static ValueListenable geometryOf(BuildContext context) { final _ScaffoldScope? scaffoldScope = context.dependOnInheritedWidgetOfExactType<_ScaffoldScope>(); - if (scaffoldScope == null) + if (scaffoldScope == null) { throw FlutterError.fromParts([ ErrorSummary( 'Scaffold.geometryOf() called with a context that does not contain a Scaffold.', @@ -1880,6 +1899,7 @@ class Scaffold extends StatefulWidget { ), context.describeElement('The context used was'), ]); + } return scaffoldScope.geometryNotifier; } @@ -1998,8 +2018,9 @@ class ScaffoldState extends State with TickerProviderStateMixin, Resto /// /// See [Scaffold.of] for information about how to obtain the [ScaffoldState]. void openDrawer() { - if (_endDrawerKey.currentState != null && _endDrawerOpened.value) + if (_endDrawerKey.currentState != null && _endDrawerOpened.value) { _endDrawerKey.currentState!.close(); + } _drawerKey.currentState?.open(); } @@ -2017,8 +2038,9 @@ class ScaffoldState extends State with TickerProviderStateMixin, Resto /// /// See [Scaffold.of] for information about how to obtain the [ScaffoldState]. void openEndDrawer() { - if (_drawerKey.currentState != null && _drawerOpened.value) + if (_drawerKey.currentState != null && _drawerOpened.value) { _drawerKey.currentState!.close(); + } _endDrawerKey.currentState?.open(); } @@ -2248,8 +2270,9 @@ class ScaffoldState extends State with TickerProviderStateMixin, Resto constraints: constraints, ); - if (!isPersistent) + if (!isPersistent) { ModalRoute.of(context)!.addLocalHistoryEntry(entry!); + } return PersistentBottomSheetController._( bottomSheet, @@ -2522,8 +2545,9 @@ class ScaffoldState extends State with TickerProviderStateMixin, Resto removeRight: removeRightPadding, removeBottom: removeBottomPadding, ); - if (removeBottomInset) + if (removeBottomInset) { data = data.removeViewInsets(removeBottom: true); + } if (maintainBottomViewPadding && data.viewInsets.bottom != 0.0) { data = data.copyWith( diff --git a/packages/flutter/lib/src/material/scrollbar.dart b/packages/flutter/lib/src/material/scrollbar.dart index 2d62f967a8cb..d0ee9db3bfaa 100644 --- a/packages/flutter/lib/src/material/scrollbar.dart +++ b/packages/flutter/lib/src/material/scrollbar.dart @@ -323,13 +323,15 @@ class _MaterialScrollbarState extends RawScrollbarState<_MaterialScrollbar> { } return MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.dragged)) + if (states.contains(MaterialState.dragged)) { return _scrollbarTheme.thumbColor?.resolve(states) ?? dragColor; + } // If the track is visible, the thumb color hover animation is ignored and // changes immediately. - if (_trackVisibility.resolve(states)) + if (_trackVisibility.resolve(states)) { return _scrollbarTheme.thumbColor?.resolve(states) ?? hoverColor; + } return Color.lerp( _scrollbarTheme.thumbColor?.resolve(states) ?? idleColor, @@ -369,10 +371,11 @@ class _MaterialScrollbarState extends RawScrollbarState<_MaterialScrollbar> { MaterialStateProperty get _thickness { return MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.hovered) && _trackVisibility.resolve(states)) + if (states.contains(MaterialState.hovered) && _trackVisibility.resolve(states)) { return widget.hoverThickness ?? _scrollbarTheme.thickness?.resolve(states) ?? _kScrollbarThicknessWithTrack; + } // The default scrollbar thickness is smaller on mobile. return widget.thickness ?? _scrollbarTheme.thickness?.resolve(states) diff --git a/packages/flutter/lib/src/material/scrollbar_theme.dart b/packages/flutter/lib/src/material/scrollbar_theme.dart index 4ad3da74a253..da29beeb80f7 100644 --- a/packages/flutter/lib/src/material/scrollbar_theme.dart +++ b/packages/flutter/lib/src/material/scrollbar_theme.dart @@ -233,10 +233,12 @@ class ScrollbarThemeData 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 ScrollbarThemeData && other.thumbVisibility == thumbVisibility && other.thickness == thickness @@ -278,8 +280,9 @@ class ScrollbarThemeData with Diagnosticable { T Function(T?, T?, double) lerpFunction, ) { // Avoid creating a _LerpProperties object for a common case. - if (a == null && b == null) + if (a == null && b == null) { return null; + } return _LerpProperties(a, b, t, lerpFunction); } } diff --git a/packages/flutter/lib/src/material/selectable_text.dart b/packages/flutter/lib/src/material/selectable_text.dart index ea42f494f70f..963431c37aa1 100644 --- a/packages/flutter/lib/src/material/selectable_text.dart +++ b/packages/flutter/lib/src/material/selectable_text.dart @@ -565,20 +565,25 @@ class _SelectableTextState extends State implements TextSelectio 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; + } - if (_controller.selection.isCollapsed) + if (_controller.selection.isCollapsed) { return false; + } - if (cause == SelectionChangedCause.keyboard) + if (cause == SelectionChangedCause.keyboard) { return false; + } - if (cause == SelectionChangedCause.longPress) + if (cause == SelectionChangedCause.longPress) { return true; + } - if (_controller.text.isNotEmpty) + if (_controller.text.isNotEmpty) { return true; + } return false; } @@ -658,10 +663,12 @@ class _SelectableTextState extends State implements TextSelectio final DefaultTextStyle defaultTextStyle = DefaultTextStyle.of(context); TextStyle? effectiveTextStyle = widget.style; - if (effectiveTextStyle == null || effectiveTextStyle.inherit) + if (effectiveTextStyle == null || effectiveTextStyle.inherit) { effectiveTextStyle = defaultTextStyle.style.merge(widget.style); - if (MediaQuery.boldTextOverride(context)) + } + if (MediaQuery.boldTextOverride(context)) { effectiveTextStyle = effectiveTextStyle.merge(const TextStyle(fontWeight: FontWeight.bold)); + } final Widget child = RepaintBoundary( child: EditableText( key: editableTextKey, diff --git a/packages/flutter/lib/src/material/slider.dart b/packages/flutter/lib/src/material/slider.dart index 78ac129bac75..1f56a88fe4fa 100644 --- a/packages/flutter/lib/src/material/slider.dart +++ b/packages/flutter/lib/src/material/slider.dart @@ -1051,8 +1051,9 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin { TargetPlatform _platform; TargetPlatform get platform => _platform; set platform(TargetPlatform value) { - if (_platform == value) + if (_platform == value) { return; + } _platform = value; markNeedsSemanticsUpdate(); } @@ -1060,8 +1061,9 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin { SemanticFormatterCallback? _semanticFormatterCallback; SemanticFormatterCallback? get semanticFormatterCallback => _semanticFormatterCallback; set semanticFormatterCallback(SemanticFormatterCallback? value) { - if (_semanticFormatterCallback == value) + if (_semanticFormatterCallback == value) { return; + } _semanticFormatterCallback = value; markNeedsSemanticsUpdate(); } @@ -1154,8 +1156,9 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin { bool _hasFocus; set hasFocus(bool value) { assert(value != null); - if (value == _hasFocus) + if (value == _hasFocus) { return; + } _hasFocus = value; _updateForFocusOrHover(_hasFocus); markNeedsSemanticsUpdate(); @@ -1166,8 +1169,9 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin { bool _hovering; set hovering(bool value) { assert(value != null); - if (value == _hovering) + if (value == _hovering) { return; + } _hovering = value; _updateForFocusOrHover(_hovering); } diff --git a/packages/flutter/lib/src/material/slider_theme.dart b/packages/flutter/lib/src/material/slider_theme.dart index 0b919c36b269..a6da38021866 100644 --- a/packages/flutter/lib/src/material/slider_theme.dart +++ b/packages/flutter/lib/src/material/slider_theme.dart @@ -1586,11 +1586,13 @@ class RectangularSliderTrackShape extends SliderTrackShape with BaseSliderTrackS ); final Rect leftTrackSegment = Rect.fromLTRB(trackRect.left, trackRect.top, thumbCenter.dx, trackRect.bottom); - if (!leftTrackSegment.isEmpty) + if (!leftTrackSegment.isEmpty) { context.canvas.drawRect(leftTrackSegment, leftTrackPaint); + } final Rect rightTrackSegment = Rect.fromLTRB(thumbCenter.dx, trackRect.top, trackRect.right, trackRect.bottom); - if (!rightTrackSegment.isEmpty) + if (!rightTrackSegment.isEmpty) { context.canvas.drawRect(rightTrackSegment, rightTrackPaint); + } } } @@ -1827,14 +1829,17 @@ class RectangularRangeSliderTrackShape extends RangeSliderTrackShape { isDiscrete: isDiscrete, ); final Rect leftTrackSegment = Rect.fromLTRB(trackRect.left, trackRect.top, leftThumbOffset.dx, trackRect.bottom); - if (!leftTrackSegment.isEmpty) + if (!leftTrackSegment.isEmpty) { context.canvas.drawRect(leftTrackSegment, inactivePaint); + } final Rect middleTrackSegment = Rect.fromLTRB(leftThumbOffset.dx, trackRect.top, rightThumbOffset.dx, trackRect.bottom); - if (!middleTrackSegment.isEmpty) + if (!middleTrackSegment.isEmpty) { context.canvas.drawRect(middleTrackSegment, activePaint); + } final Rect rightTrackSegment = Rect.fromLTRB(rightThumbOffset.dx, trackRect.top, trackRect.right, trackRect.bottom); - if (!rightTrackSegment.isEmpty) + if (!rightTrackSegment.isEmpty) { context.canvas.drawRect(rightTrackSegment, inactivePaint); + } } } @@ -3297,8 +3302,9 @@ class RangeValues { @override bool operator ==(Object other) { - if (other.runtimeType != runtimeType) + if (other.runtimeType != runtimeType) { return false; + } return other is RangeValues && other.start == start && other.end == end; @@ -3337,8 +3343,9 @@ class RangeLabels { @override bool operator ==(Object other) { - if (other.runtimeType != runtimeType) + if (other.runtimeType != runtimeType) { return false; + } return other is RangeLabels && other.start == start && other.end == end; diff --git a/packages/flutter/lib/src/material/snack_bar.dart b/packages/flutter/lib/src/material/snack_bar.dart index 32d52fd90eb8..90c0ad965c73 100644 --- a/packages/flutter/lib/src/material/snack_bar.dart +++ b/packages/flutter/lib/src/material/snack_bar.dart @@ -115,8 +115,9 @@ class _SnackBarActionState extends State { bool _haveTriggeredAction = false; void _handlePressed() { - if (_haveTriggeredAction) + if (_haveTriggeredAction) { return; + } setState(() { _haveTriggeredAction = true; }); @@ -128,8 +129,9 @@ class _SnackBarActionState extends State { Widget build(BuildContext context) { Color? resolveForegroundColor(Set states) { final SnackBarThemeData snackBarTheme = Theme.of(context).snackBarTheme; - if (states.contains(MaterialState.disabled)) + if (states.contains(MaterialState.disabled)) { return widget.disabledTextColor ?? snackBarTheme.disabledActionTextColor; + } return widget.textColor ?? snackBarTheme.actionTextColor; } diff --git a/packages/flutter/lib/src/material/snack_bar_theme.dart b/packages/flutter/lib/src/material/snack_bar_theme.dart index 19988351a8ec..33ab1faa57dc 100644 --- a/packages/flutter/lib/src/material/snack_bar_theme.dart +++ b/packages/flutter/lib/src/material/snack_bar_theme.dart @@ -157,10 +157,12 @@ class SnackBarThemeData 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 SnackBarThemeData && other.backgroundColor == backgroundColor && other.actionTextColor == actionTextColor diff --git a/packages/flutter/lib/src/material/stepper.dart b/packages/flutter/lib/src/material/stepper.dart index c9b62224ad78..d1901605fe1c 100644 --- a/packages/flutter/lib/src/material/stepper.dart +++ b/packages/flutter/lib/src/material/stepper.dart @@ -322,8 +322,9 @@ class _StepperState extends State with TickerProviderStateMixin { (int i) => GlobalKey(), ); - for (int i = 0; i < widget.steps.length; i += 1) + for (int i = 0; i < widget.steps.length; i += 1) { _oldStates[i] = widget.steps[i].state; + } } @override @@ -331,8 +332,9 @@ class _StepperState extends State with TickerProviderStateMixin { super.didUpdateWidget(oldWidget); assert(widget.steps.length == oldWidget.steps.length); - for (int i = 0; i < oldWidget.steps.length; i += 1) + for (int i = 0; i < oldWidget.steps.length; i += 1) { _oldStates[i] = oldWidget.steps[i].state; + } } bool _isFirst(int index) { @@ -450,15 +452,16 @@ class _StepperState extends State with TickerProviderStateMixin { duration: kThemeAnimationDuration, ); } else { - if (widget.steps[index].state != StepState.error) + if (widget.steps[index].state != StepState.error) { return _buildCircle(index, false); - else + } else { return _buildTriangle(index, false); + } } } Widget _buildVerticalControls(int stepIndex) { - if (widget.controlsBuilder != null) + if (widget.controlsBuilder != null) { return widget.controlsBuilder!( context, ControlsDetails( @@ -468,6 +471,7 @@ class _StepperState extends State with TickerProviderStateMixin { stepIndex: stepIndex, ), ); + } final Color cancelColor; switch (Theme.of(context).brightness) { @@ -773,13 +777,14 @@ class _StepperState extends State with TickerProviderStateMixin { assert(debugCheckHasMaterial(context)); assert(debugCheckHasMaterialLocalizations(context)); assert(() { - if (context.findAncestorWidgetOfExactType() != null) + if (context.findAncestorWidgetOfExactType() != null) { throw FlutterError( 'Steppers must not be nested.\n' 'The material specification advises that one should avoid embedding ' 'steppers within steppers. ' 'https://material.io/archive/guidelines/components/steppers.html#steppers-usage', ); + } return true; }()); assert(widget.type != null); diff --git a/packages/flutter/lib/src/material/switch.dart b/packages/flutter/lib/src/material/switch.dart index f0ca58c3adca..eacd53d044b7 100644 --- a/packages/flutter/lib/src/material/switch.dart +++ b/packages/flutter/lib/src/material/switch.dart @@ -637,8 +637,9 @@ class _MaterialSwitchState extends State<_MaterialSwitch> with TickerProviderSta double get _trackInnerLength => widget.size.width - _kSwitchMinSize; void _handleDragStart(DragStartDetails details) { - if (isInteractive) + if (isInteractive) { reactionController.forward(); + } } void _handleDragUpdate(DragUpdateDetails details) { @@ -791,8 +792,9 @@ class _SwitchPainter extends ToggleablePainter { ImageProvider? get activeThumbImage => _activeThumbImage; ImageProvider? _activeThumbImage; set activeThumbImage(ImageProvider? value) { - if (value == _activeThumbImage) + if (value == _activeThumbImage) { return; + } _activeThumbImage = value; notifyListeners(); } @@ -810,8 +812,9 @@ class _SwitchPainter extends ToggleablePainter { ImageProvider? get inactiveThumbImage => _inactiveThumbImage; ImageProvider? _inactiveThumbImage; set inactiveThumbImage(ImageProvider? value) { - if (value == _inactiveThumbImage) + if (value == _inactiveThumbImage) { return; + } _inactiveThumbImage = value; notifyListeners(); } @@ -830,8 +833,9 @@ class _SwitchPainter extends ToggleablePainter { Color? _activeTrackColor; set activeTrackColor(Color value) { assert(value != null); - if (value == _activeTrackColor) + if (value == _activeTrackColor) { return; + } _activeTrackColor = value; notifyListeners(); } @@ -840,8 +844,9 @@ class _SwitchPainter extends ToggleablePainter { Color? _inactiveTrackColor; set inactiveTrackColor(Color value) { assert(value != null); - if (value == _inactiveTrackColor) + if (value == _inactiveTrackColor) { return; + } _inactiveTrackColor = value; notifyListeners(); } @@ -850,8 +855,9 @@ class _SwitchPainter extends ToggleablePainter { ImageConfiguration? _configuration; set configuration(ImageConfiguration value) { assert(value != null); - if (value == _configuration) + if (value == _configuration) { return; + } _configuration = value; notifyListeners(); } @@ -860,8 +866,9 @@ class _SwitchPainter extends ToggleablePainter { TextDirection? _textDirection; set textDirection(TextDirection value) { assert(value != null); - if (_textDirection == value) + if (_textDirection == value) { return; + } _textDirection = value; notifyListeners(); } @@ -870,8 +877,9 @@ class _SwitchPainter extends ToggleablePainter { Color? _surfaceColor; set surfaceColor(Color value) { assert(value != null); - if (value == _surfaceColor) + if (value == _surfaceColor) { return; + } _surfaceColor = value; notifyListeners(); } @@ -917,8 +925,9 @@ class _SwitchPainter extends ToggleablePainter { // during paint. There's no reason to mark ourselves as needing paint if we // are already in the middle of painting. (In fact, doing so would trigger // an assert). - if (!_isPainting) + if (!_isPainting) { notifyListeners(); + } } @override diff --git a/packages/flutter/lib/src/material/switch_theme.dart b/packages/flutter/lib/src/material/switch_theme.dart index 1513905402ef..8d079eedaa68 100644 --- a/packages/flutter/lib/src/material/switch_theme.dart +++ b/packages/flutter/lib/src/material/switch_theme.dart @@ -119,10 +119,12 @@ class SwitchThemeData 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 SwitchThemeData && other.thumbColor == thumbColor && other.trackColor == trackColor @@ -150,8 +152,9 @@ class SwitchThemeData with Diagnosticable { T Function(T?, T?, double) lerpFunction, ) { // Avoid creating a _LerpProperties object for a common case. - if (a == null && b == null) + if (a == null && b == null) { return null; + } return _LerpProperties(a, b, t, lerpFunction); } } diff --git a/packages/flutter/lib/src/material/tab_bar_theme.dart b/packages/flutter/lib/src/material/tab_bar_theme.dart index 69fed86296b2..dcab9e9e2e4d 100644 --- a/packages/flutter/lib/src/material/tab_bar_theme.dart +++ b/packages/flutter/lib/src/material/tab_bar_theme.dart @@ -148,10 +148,12 @@ class TabBarTheme 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 TabBarTheme && other.indicator == indicator && other.indicatorSize == indicatorSize @@ -189,10 +191,12 @@ class _LerpColors implements MaterialStateProperty { @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 _LerpColors && other.a == a && other.b == b diff --git a/packages/flutter/lib/src/material/tab_controller.dart b/packages/flutter/lib/src/material/tab_controller.dart index ae8f1652ddcc..ff196c868e16 100644 --- a/packages/flutter/lib/src/material/tab_controller.dart +++ b/packages/flutter/lib/src/material/tab_controller.dart @@ -181,8 +181,9 @@ class TabController extends ChangeNotifier { assert(value >= 0 && (value < length || length == 0)); assert(duration != null || curve == null); assert(_indexIsChangingCount >= 0); - if (value == _index || length < 2) + if (value == _index || length < 2) { return; + } _previousIndex = index; _index = value; if (duration != null && duration > Duration.zero) { @@ -256,8 +257,9 @@ class TabController extends ChangeNotifier { assert(value != null); assert(value >= -1.0 && value <= 1.0); assert(!indexIsChanging); - if (value == offset) + if (value == offset) { return; + } _animationController!.value = value + _index.toDouble(); } diff --git a/packages/flutter/lib/src/material/tabs.dart b/packages/flutter/lib/src/material/tabs.dart index 49ddfea34948..91192977ff61 100644 --- a/packages/flutter/lib/src/material/tabs.dart +++ b/packages/flutter/lib/src/material/tabs.dart @@ -151,12 +151,13 @@ class Tab extends StatelessWidget implements PreferredSizeWidget { @override Size get preferredSize { - if (height != null) + if (height != null) { return Size.fromHeight(height!); - else if ((text != null || child != null) && icon != null) + } else if ((text != null || child != null) && icon != null) { return const Size.fromHeight(_kTextAndIconTabHeight); - else + } else { return const Size.fromHeight(_kTabHeight); + } } } @@ -310,8 +311,9 @@ double _indexChangeProgress(TabController controller) { // The controller's offset is changing because the user is dragging the // TabBarView's PageView to the left or right. - if (!controller.indexIsChanging) + if (!controller.indexIsChanging) { return clampDouble((currentIndex - controllerValue).abs(), 0.0, 1.0); + } // The TabController animation's value is changing from previousIndex to currentIndex. return (controllerValue - currentIndex).abs() / (currentIndex - previousIndex).abs(); @@ -328,8 +330,9 @@ class _IndicatorPainter extends CustomPainter { }) : assert(controller != null), assert(indicator != null), super(repaint: controller.animation) { - if (old != null) + if (old != null) { saveTabOffsets(old._currentTabOffsets, old._currentTextDirection); + } } final TabController controller; @@ -452,14 +455,16 @@ class _ChangeAnimation extends Animation with AnimationWithParentMixin with AnimationWithParentMixin { } Decoration get _indicator { - if (widget.indicator != null) + if (widget.indicator != null) { return widget.indicator!; + } final TabBarTheme tabBarTheme = TabBarTheme.of(context); - if (tabBarTheme.indicator != null) + if (tabBarTheme.indicator != null) { return tabBarTheme.indicator!; + } Color color = widget.indicatorColor ?? Theme.of(context).indicatorColor; // ThemeData tries to avoid this by having indicatorColor avoid being the @@ -937,8 +947,9 @@ class _TabBarState extends State { // TODO(xu-baolin): Remove automatic adjustment to white color indicator // with a better long-term solution. // https://github.com/flutter/flutter/pull/68171#pullrequestreview-517753917 - if (widget.automaticIndicatorColorAdjustment && color.value == Material.of(context)?.color?.value) + if (widget.automaticIndicatorColorAdjustment && color.value == Material.of(context)?.color?.value) { color = Colors.white; + } return UnderlineTabIndicator( borderSide: BorderSide( @@ -968,8 +979,9 @@ class _TabBarState extends State { return true; }()); - if (newController == _controller) + if (newController == _controller) { return; + } if (_controllerIsValid) { _controller!.animation!.removeListener(_handleTabControllerAnimationTick); @@ -1038,8 +1050,9 @@ class _TabBarState extends State { int get maxTabIndex => _indicatorPainter!.maxTabIndex; double _tabScrollOffset(int index, double viewportWidth, double minExtent, double maxExtent) { - if (!widget.isScrollable) + if (!widget.isScrollable) { return 0.0; + } double tabCenter = _indicatorPainter!.centerOf(index); switch (Directionality.of(context)) { case TextDirection.rtl: @@ -1073,16 +1086,17 @@ class _TabBarState extends State { final double index = _controller!.index.toDouble(); final double value = _controller!.animation!.value; final double offset; - if (value == index - 1.0) + if (value == index - 1.0) { offset = leadingPosition ?? middlePosition; - else if (value == index + 1.0) + } else if (value == index + 1.0) { offset = trailingPosition ?? middlePosition; - else if (value == index) + } else if (value == index) { offset = middlePosition; - else if (value < index) + } else if (value < index) { offset = leadingPosition == null ? middlePosition : lerpDouble(middlePosition, leadingPosition, index - value)!; - else + } else { offset = trailingPosition == null ? middlePosition : lerpDouble(middlePosition, trailingPosition, value - index)!; + } _scrollController!.jumpTo(offset); } @@ -1099,8 +1113,9 @@ class _TabBarState extends State { void _handleTabControllerTick() { if (_controller!.index != _currentIndex) { _currentIndex = _controller!.index; - if (widget.isScrollable) + if (widget.isScrollable) { _scrollToCurrentIndex(); + } } setState(() { // Rebuild the tabs after a (potentially animated) index change @@ -1244,8 +1259,9 @@ class _TabBarState extends State { ), ), ); - if (!widget.isScrollable) + if (!widget.isScrollable) { wrappedTabs[index] = Expanded(child: wrappedTabs[index]); + } } Widget tabBar = CustomPaint( @@ -1380,14 +1396,17 @@ class _TabBarViewState extends State { return true; }()); - if (newController == _controller) + if (newController == _controller) { return; + } - if (_controllerIsValid) + if (_controllerIsValid) { _controller!.animation!.removeListener(_handleTabControllerAnimationTick); + } _controller = newController; - if (_controller != null) + if (_controller != null) { _controller!.animation!.addListener(_handleTabControllerAnimationTick); + } } @override @@ -1417,14 +1436,16 @@ class _TabBarViewState extends State { _pageController.jumpToPage(_currentIndex!); _warpUnderwayCount -= 1; } - if (widget.children != oldWidget.children && _warpUnderwayCount == 0) + if (widget.children != oldWidget.children && _warpUnderwayCount == 0) { _updateChildren(); + } } @override void dispose() { - if (_controllerIsValid) + if (_controllerIsValid) { _controller!.animation!.removeListener(_handleTabControllerAnimationTick); + } _controller = null; // We don't own the _controller Animation, so it's not disposed here. super.dispose(); @@ -1436,8 +1457,9 @@ class _TabBarViewState extends State { } void _handleTabControllerAnimationTick() { - if (_warpUnderwayCount > 0 || !_controller!.indexIsChanging) - return; // This widget is driving the controller's animation. + if (_warpUnderwayCount > 0 || !_controller!.indexIsChanging) { + return; + } // This widget is driving the controller's animation. if (_controller!.index != _currentIndex) { _currentIndex = _controller!.index; @@ -1446,11 +1468,13 @@ class _TabBarViewState extends State { } Future _warpToCurrentIndex() async { - if (!mounted) + if (!mounted) { return Future.value(); + } - if (_pageController.page == _currentIndex!.toDouble()) + if (_pageController.page == _currentIndex!.toDouble()) { return Future.value(); + } final Duration duration = _controller!.animationDuration; @@ -1484,8 +1508,9 @@ class _TabBarViewState extends State { _pageController.jumpToPage(initialPage); await _pageController.animateToPage(_currentIndex!, duration: duration, curve: Curves.ease); - if (!mounted) + if (!mounted) { return Future.value(); + } setState(() { _warpUnderwayCount -= 1; if (widget.children != _children) { @@ -1498,11 +1523,13 @@ class _TabBarViewState extends State { // Called when the PageView scrolls bool _handleScrollNotification(ScrollNotification notification) { - if (_warpUnderwayCount > 0) + if (_warpUnderwayCount > 0) { return false; + } - if (notification.depth != 0) + if (notification.depth != 0) { return false; + } _warpUnderwayCount += 1; if (notification is ScrollUpdateNotification && !_controller!.indexIsChanging) { @@ -1514,8 +1541,9 @@ class _TabBarViewState extends State { } else if (notification is ScrollEndNotification) { _controller!.index = _pageController.page!.round(); _currentIndex = _controller!.index; - if (!_controller!.indexIsChanging) + if (!_controller!.indexIsChanging) { _controller!.offset = clampDouble(_pageController.page! - _controller!.index, -1.0, 1.0); + } } _warpUnderwayCount -= 1; @@ -1652,12 +1680,13 @@ class TabPageSelector extends StatelessWidget { if (tabController.indexIsChanging) { // The selection's animation is animating from previousValue to value. final double t = 1.0 - _indexChangeProgress(tabController); - if (tabController.index == tabIndex) + if (tabController.index == tabIndex) { background = selectedColorTween.lerp(t)!; - else if (tabController.previousIndex == tabIndex) + } else if (tabController.previousIndex == tabIndex) { background = previousColorTween.lerp(t)!; - else + } else { background = selectedColorTween.begin!; + } } else { // The selection's offset reflects how far the TabBarView has / been dragged // to the previous page (-1.0 to 0.0) or the next page (0.0 to 1.0). diff --git a/packages/flutter/lib/src/material/text_button.dart b/packages/flutter/lib/src/material/text_button.dart index 918cddd2a31e..e1936d501f30 100644 --- a/packages/flutter/lib/src/material/text_button.dart +++ b/packages/flutter/lib/src/material/text_button.dart @@ -349,8 +349,9 @@ class _TextButtonDefaultForeground extends MaterialStateProperty { @override Color? resolve(Set states) { - if (states.contains(MaterialState.disabled)) + if (states.contains(MaterialState.disabled)) { return onSurface?.withOpacity(0.38); + } return primary; } @@ -368,10 +369,12 @@ class _TextButtonDefaultOverlay extends MaterialStateProperty { @override Color? resolve(Set states) { - if (states.contains(MaterialState.hovered)) + if (states.contains(MaterialState.hovered)) { return primary.withOpacity(0.04); - if (states.contains(MaterialState.focused) || states.contains(MaterialState.pressed)) + } + if (states.contains(MaterialState.focused) || states.contains(MaterialState.pressed)) { return primary.withOpacity(0.12); + } return null; } @@ -390,8 +393,9 @@ class _TextButtonDefaultMouseCursor extends MaterialStateProperty w @override MouseCursor resolve(Set states) { - if (states.contains(MaterialState.disabled)) + if (states.contains(MaterialState.disabled)) { return disabledCursor; + } return enabledCursor; } } @@ -480,20 +484,24 @@ class _TokenDefaultsM3 extends ButtonStyle { @override MaterialStateProperty? get foregroundColor => MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.disabled)) + if (states.contains(MaterialState.disabled)) { return _colors.onSurface.withOpacity(0.38); + } return _colors.primary; }); @override MaterialStateProperty? get overlayColor => MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.hovered)) + if (states.contains(MaterialState.hovered)) { return _colors.primary.withOpacity(0.08); - if (states.contains(MaterialState.focused)) + } + if (states.contains(MaterialState.focused)) { return _colors.primary.withOpacity(0.12); - if (states.contains(MaterialState.pressed)) + } + if (states.contains(MaterialState.pressed)) { return _colors.primary.withOpacity(0.12); + } return null; }); @@ -528,8 +536,9 @@ class _TokenDefaultsM3 extends ButtonStyle { @override MaterialStateProperty? get mouseCursor => MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.disabled)) + if (states.contains(MaterialState.disabled)) { return SystemMouseCursors.basic; + } return SystemMouseCursors.click; }); diff --git a/packages/flutter/lib/src/material/text_button_theme.dart b/packages/flutter/lib/src/material/text_button_theme.dart index 3ad6a5006d1b..798f31000f3a 100644 --- a/packages/flutter/lib/src/material/text_button_theme.dart +++ b/packages/flutter/lib/src/material/text_button_theme.dart @@ -47,8 +47,9 @@ class TextButtonThemeData with Diagnosticable { /// Linearly interpolate between two text button themes. static TextButtonThemeData? lerp(TextButtonThemeData? a, TextButtonThemeData? b, double t) { assert (t != null); - if (a == null && b == null) + if (a == null && b == null) { return null; + } return TextButtonThemeData( style: ButtonStyle.lerp(a?.style, b?.style, t), ); @@ -59,10 +60,12 @@ class TextButtonThemeData 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 TextButtonThemeData && other.style == style; } diff --git a/packages/flutter/lib/src/material/text_field.dart b/packages/flutter/lib/src/material/text_field.dart index 679109f821df..451cf665a7e0 100644 --- a/packages/flutter/lib/src/material/text_field.dart +++ b/packages/flutter/lib/src/material/text_field.dart @@ -861,8 +861,9 @@ class _TextFieldState extends State with RestorationMixin implements ); // No need to build anything if counter or counterText were given directly. - if (effectiveDecoration.counter != null || effectiveDecoration.counterText != null) + if (effectiveDecoration.counter != null || effectiveDecoration.counterText != null) { return effectiveDecoration; + } // If buildCounter was provided, use it to generate a counter widget. Widget? counter; @@ -888,8 +889,9 @@ class _TextFieldState extends State with RestorationMixin implements return effectiveDecoration.copyWith(counter: counter); } - if (widget.maxLength == null) - return effectiveDecoration; // No counter widget + if (widget.maxLength == null) { + return effectiveDecoration; + } // No counter widget String counterText = '$currentLength'; String semanticCounterText = ''; @@ -1012,23 +1014,29 @@ class _TextFieldState extends State with RestorationMixin implements 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; + } - if (cause == SelectionChangedCause.keyboard) + if (cause == SelectionChangedCause.keyboard) { return false; + } - if (widget.readOnly && _effectiveController.selection.isCollapsed) + if (widget.readOnly && _effectiveController.selection.isCollapsed) { return false; + } - if (!_isEnabled) + if (!_isEnabled) { return false; + } - if (cause == SelectionChangedCause.longPress || cause == SelectionChangedCause.scribble) + if (cause == SelectionChangedCause.longPress || cause == SelectionChangedCause.scribble) { return true; + } - if (_effectiveController.text.isNotEmpty) + if (_effectiveController.text.isNotEmpty) { return true; + } return false; } @@ -1327,8 +1335,9 @@ class _TextFieldState extends State with RestorationMixin implements maxValueLength: semanticsMaxValueLength, currentValueLength: _currentLength, onTap: widget.readOnly ? null : () { - if (!_effectiveController.selection.isValid) + if (!_effectiveController.selection.isValid) { _effectiveController.selection = TextSelection.collapsed(offset: _effectiveController.text.length); + } _requestKeyboard(); }, onDidGainAccessibilityFocus: handleDidGainAccessibilityFocus, diff --git a/packages/flutter/lib/src/material/text_form_field.dart b/packages/flutter/lib/src/material/text_form_field.dart index adced9ca5480..00454893f915 100644 --- a/packages/flutter/lib/src/material/text_form_field.dart +++ b/packages/flutter/lib/src/material/text_form_field.dart @@ -325,8 +325,9 @@ class _TextFormFieldState extends FormFieldState { void didChange(String? value) { super.didChange(value); - if (_effectiveController.text != value) + if (_effectiveController.text != value) { _effectiveController.text = value ?? ''; + } } @override @@ -345,7 +346,8 @@ class _TextFormFieldState extends FormFieldState { // notifications for changes originating from within this class -- for // example, the reset() method. In such cases, the FormField value will // already have been set. - if (_effectiveController.text != value) + if (_effectiveController.text != value) { didChange(_effectiveController.text); + } } } diff --git a/packages/flutter/lib/src/material/text_selection_theme.dart b/packages/flutter/lib/src/material/text_selection_theme.dart index c5c03be4a525..dc65e1f032cd 100644 --- a/packages/flutter/lib/src/material/text_selection_theme.dart +++ b/packages/flutter/lib/src/material/text_selection_theme.dart @@ -70,8 +70,9 @@ class TextSelectionThemeData with Diagnosticable { /// /// {@macro dart.ui.shadow.lerp} static TextSelectionThemeData? lerp(TextSelectionThemeData? a, TextSelectionThemeData? b, double t) { - if (a == null && b == null) + if (a == null && b == null) { return null; + } assert(t != null); return TextSelectionThemeData( cursorColor: Color.lerp(a?.cursorColor, b?.cursorColor, t), @@ -89,10 +90,12 @@ class TextSelectionThemeData 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 TextSelectionThemeData && other.cursorColor == cursorColor && other.selectionColor == selectionColor diff --git a/packages/flutter/lib/src/material/text_selection_toolbar.dart b/packages/flutter/lib/src/material/text_selection_toolbar.dart index d7578fb8dfe0..d014bbc30e8b 100644 --- a/packages/flutter/lib/src/material/text_selection_toolbar.dart +++ b/packages/flutter/lib/src/material/text_selection_toolbar.dart @@ -612,8 +612,9 @@ class _RenderTextSelectionToolbarItemsLayout extends RenderBox with ContainerRen return child!.hitTest(result, position: transformed); }, ); - if (isHit) + if (isHit) { return true; + } child = childParentData.previousSibling; } return false; diff --git a/packages/flutter/lib/src/material/text_theme.dart b/packages/flutter/lib/src/material/text_theme.dart index 0633542921b4..8fe63363118a 100644 --- a/packages/flutter/lib/src/material/text_theme.dart +++ b/packages/flutter/lib/src/material/text_theme.dart @@ -426,8 +426,9 @@ class TextTheme with Diagnosticable { /// individual fields in the [TextTheme] instead of merging all of the /// fields of two [TextTheme]s. TextTheme merge(TextTheme? other) { - if (other == null) + if (other == null) { return this; + } return copyWith( displayLarge: displayLarge?.merge(other.displayLarge) ?? other.displayLarge, displayMedium: displayMedium?.merge(other.displayMedium) ?? other.displayMedium, @@ -632,10 +633,12 @@ class TextTheme 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 TextTheme && displayLarge == other.displayLarge && displayMedium == other.displayMedium diff --git a/packages/flutter/lib/src/material/theme_data.dart b/packages/flutter/lib/src/material/theme_data.dart index beb21d5d8a73..132c8f8044ff 100644 --- a/packages/flutter/lib/src/material/theme_data.dart +++ b/packages/flutter/lib/src/material/theme_data.dart @@ -1900,8 +1900,9 @@ class ThemeData with Diagnosticable { // Design spec shows for its color palette on // . const double kThreshold = 0.15; - if ((relativeLuminance + 0.05) * (relativeLuminance + 0.05) > kThreshold) + if ((relativeLuminance + 0.05) * (relativeLuminance + 0.05) > kThreshold) { return Brightness.light; + } return Brightness.dark; } @@ -2039,8 +2040,9 @@ class ThemeData with Diagnosticable { @override bool operator ==(Object other) { - if (other.runtimeType != runtimeType) + if (other.runtimeType != runtimeType) { return false; + } return other is ThemeData && // For the sanity of the reader, make sure these properties are in the same // order in every place that they are separated by section comments (e.g. @@ -2498,10 +2500,12 @@ class _FifoCache { assert(key != null); assert(loader != null); final V? result = _cache[key]; - if (result != null) + if (result != null) { return result; - if (_cache.length == _maximumSize) + } + if (_cache.length == _maximumSize) { _cache.remove(_cache.keys.first); + } return _cache[key] = loader(); } } diff --git a/packages/flutter/lib/src/material/time.dart b/packages/flutter/lib/src/material/time.dart index 246877f03a81..5b9e31945a66 100644 --- a/packages/flutter/lib/src/material/time.dart +++ b/packages/flutter/lib/src/material/time.dart @@ -125,8 +125,9 @@ class TimeOfDay { @override String toString() { String addLeadingZeroIfNeeded(int value) { - if (value < 10) + if (value < 10) { return '0$value'; + } return value.toString(); } diff --git a/packages/flutter/lib/src/material/time_picker.dart b/packages/flutter/lib/src/material/time_picker.dart index 450fdaa39dc2..d15d763f9fbf 100644 --- a/packages/flutter/lib/src/material/time_picker.dart +++ b/packages/flutter/lib/src/material/time_picker.dart @@ -125,8 +125,9 @@ class _TimePickerHeader extends StatelessWidget { final String? helpText; void _handleChangeMode(_TimePickerMode value) { - if (value != mode) + if (value != mode) { onModeChanged(value); + } } @override @@ -693,8 +694,9 @@ class _RenderInputPadding extends RenderShiftedBox { Size get minSize => _minSize; Size _minSize; set minSize(Size value) { - if (_minSize == value) + if (_minSize == value) { return; + } _minSize = value; markNeedsLayout(); } @@ -857,8 +859,9 @@ class _DialPainter extends CustomPainter { } void paintLabels(List<_TappableLabel>? labels) { - if (labels == null) + if (labels == null) { return; + } final double labelThetaIncrement = -_kTwoPi / labels.length; double labelTheta = math.pi / 2.0; @@ -963,8 +966,9 @@ class _DialState extends State<_Dial> with SingleTickerProviderStateMixin { void didUpdateWidget(_Dial oldWidget) { super.didUpdateWidget(oldWidget); if (widget.mode != oldWidget.mode || widget.selectedTime != oldWidget.selectedTime) { - if (!_dragging) + if (!_dragging) { _animateTo(_getThetaForTime(widget.selectedTime)); + } } } @@ -1026,10 +1030,12 @@ class _DialState extends State<_Dial> with SingleTickerProviderStateMixin { TimeOfDay _notifyOnChangedIfNeeded({ bool roundMinutes = false }) { final TimeOfDay current = _getTimeForTheta(_theta.value, roundMinutes: roundMinutes); - if (widget.onChanged == null) + if (widget.onChanged == null) { return current; - if (current != widget.selectedTime) + } + if (current != widget.selectedTime) { widget.onChanged!(current); + } return current; } @@ -2071,8 +2077,9 @@ class _TimePickerDialogState extends State with RestorationMix } void _announceInitialTimeOnce() { - if (_announcedInitialTime.value) + if (_announcedInitialTime.value) { return; + } final MediaQueryData media = MediaQuery.of(context); final MaterialLocalizations localizations = MaterialLocalizations.of(context); diff --git a/packages/flutter/lib/src/material/time_picker_theme.dart b/packages/flutter/lib/src/material/time_picker_theme.dart index e23579da3657..30afbdd747e2 100644 --- a/packages/flutter/lib/src/material/time_picker_theme.dart +++ b/packages/flutter/lib/src/material/time_picker_theme.dart @@ -301,10 +301,12 @@ class TimePickerThemeData 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 TimePickerThemeData && other.backgroundColor == backgroundColor && other.hourMinuteTextColor == hourMinuteTextColor diff --git a/packages/flutter/lib/src/material/toggle_buttons.dart b/packages/flutter/lib/src/material/toggle_buttons.dart index be57bd20697e..0bed52cd35e6 100644 --- a/packages/flutter/lib/src/material/toggle_buttons.dart +++ b/packages/flutter/lib/src/material/toggle_buttons.dart @@ -535,8 +535,9 @@ class ToggleButtons extends StatelessWidget { ThemeData theme, ToggleButtonsThemeData toggleButtonsTheme, ) { - if (!renderBorder) + if (!renderBorder) { return BorderSide.none; + } final double resultingBorderWidth = borderWidth ?? toggleButtonsTheme.borderWidth @@ -570,8 +571,9 @@ class ToggleButtons extends StatelessWidget { ThemeData theme, ToggleButtonsThemeData toggleButtonsTheme, ) { - if (!renderBorder) + if (!renderBorder) { return BorderSide.none; + } final double resultingBorderWidth = borderWidth ?? toggleButtonsTheme.borderWidth @@ -605,11 +607,13 @@ class ToggleButtons extends StatelessWidget { ThemeData theme, ToggleButtonsThemeData toggleButtonsTheme, ) { - if (!renderBorder) + if (!renderBorder) { return BorderSide.none; + } - if (index != children.length - 1) + if (index != children.length - 1) { return BorderSide.none; + } final double resultingBorderWidth = borderWidth ?? toggleButtonsTheme.borderWidth @@ -654,8 +658,9 @@ class ToggleButtons extends StatelessWidget { ); assert( () { - if (focusNodes != null) + if (focusNodes != null) { return focusNodes!.length == children.length; + } return true; }(), 'focusNodes.length must match children.length.\n' @@ -1023,8 +1028,9 @@ class _SelectToggleButtonRenderObject extends RenderShiftedBox { Axis get direction => _direction; Axis _direction; set direction(Axis value) { - if (_direction == value) + if (_direction == value) { return; + } _direction = value; markNeedsLayout(); } @@ -1032,8 +1038,9 @@ class _SelectToggleButtonRenderObject extends RenderShiftedBox { VerticalDirection get verticalDirection => _verticalDirection; VerticalDirection _verticalDirection; set verticalDirection(VerticalDirection value) { - if (_verticalDirection == value) + if (_verticalDirection == value) { return; + } _verticalDirection = value; markNeedsLayout(); } @@ -1042,8 +1049,9 @@ class _SelectToggleButtonRenderObject extends RenderShiftedBox { BorderSide get leadingBorderSide => _leadingBorderSide; BorderSide _leadingBorderSide; set leadingBorderSide(BorderSide value) { - if (_leadingBorderSide == value) + if (_leadingBorderSide == value) { return; + } _leadingBorderSide = value; markNeedsLayout(); } @@ -1052,8 +1060,9 @@ class _SelectToggleButtonRenderObject extends RenderShiftedBox { BorderSide get borderSide => _borderSide; BorderSide _borderSide; set borderSide(BorderSide value) { - if (_borderSide == value) + if (_borderSide == value) { return; + } _borderSide = value; markNeedsLayout(); } @@ -1062,8 +1071,9 @@ class _SelectToggleButtonRenderObject extends RenderShiftedBox { BorderSide get trailingBorderSide => _trailingBorderSide; BorderSide _trailingBorderSide; set trailingBorderSide(BorderSide value) { - if (_trailingBorderSide == value) + if (_trailingBorderSide == value) { return; + } _trailingBorderSide = value; markNeedsLayout(); } @@ -1072,8 +1082,9 @@ class _SelectToggleButtonRenderObject extends RenderShiftedBox { BorderRadius get borderRadius => _borderRadius; BorderRadius _borderRadius; set borderRadius(BorderRadius value) { - if (_borderRadius == value) + if (_borderRadius == value) { return; + } _borderRadius = value; markNeedsLayout(); } @@ -1082,8 +1093,9 @@ class _SelectToggleButtonRenderObject extends RenderShiftedBox { bool get isFirstButton => _isFirstButton; bool _isFirstButton; set isFirstButton(bool value) { - if (_isFirstButton == value) + if (_isFirstButton == value) { return; + } _isFirstButton = value; markNeedsLayout(); } @@ -1092,8 +1104,9 @@ class _SelectToggleButtonRenderObject extends RenderShiftedBox { bool get isLastButton => _isLastButton; bool _isLastButton; set isLastButton(bool value) { - if (_isLastButton == value) + if (_isLastButton == value) { return; + } _isLastButton = value; markNeedsLayout(); } @@ -1102,8 +1115,9 @@ class _SelectToggleButtonRenderObject extends RenderShiftedBox { TextDirection get textDirection => _textDirection; TextDirection _textDirection; set textDirection(TextDirection value) { - if (_textDirection == value) + if (_textDirection == value) { return; + } _textDirection = value; markNeedsLayout(); } @@ -1514,8 +1528,9 @@ class _RenderInputPadding extends RenderShiftedBox { Size get minSize => _minSize; Size _minSize; set minSize(Size value) { - if (_minSize == value) + if (_minSize == value) { return; + } _minSize = value; markNeedsLayout(); } @@ -1523,37 +1538,42 @@ class _RenderInputPadding extends RenderShiftedBox { Axis get direction => _direction; Axis _direction; set direction(Axis value) { - if (_direction == value) + if (_direction == value) { return; + } _direction = value; markNeedsLayout(); } @override double computeMinIntrinsicWidth(double height) { - if (child != null) + if (child != null) { return math.max(child!.getMinIntrinsicWidth(height), minSize.width); + } return 0.0; } @override double computeMinIntrinsicHeight(double width) { - if (child != null) + if (child != null) { return math.max(child!.getMinIntrinsicHeight(width), minSize.height); + } return 0.0; } @override double computeMaxIntrinsicWidth(double height) { - if (child != null) + if (child != null) { return math.max(child!.getMaxIntrinsicWidth(height), minSize.width); + } return 0.0; } @override double computeMaxIntrinsicHeight(double width) { - if (child != null) + if (child != null) { return math.max(child!.getMaxIntrinsicHeight(width), minSize.height); + } return 0.0; } diff --git a/packages/flutter/lib/src/material/toggle_buttons_theme.dart b/packages/flutter/lib/src/material/toggle_buttons_theme.dart index 2da7f9739f5e..8c57dc586e0a 100644 --- a/packages/flutter/lib/src/material/toggle_buttons_theme.dart +++ b/packages/flutter/lib/src/material/toggle_buttons_theme.dart @@ -148,8 +148,9 @@ class ToggleButtonsThemeData with Diagnosticable { /// Linearly interpolate between two toggle buttons themes. static ToggleButtonsThemeData? lerp(ToggleButtonsThemeData? a, ToggleButtonsThemeData? b, double t) { assert (t != null); - if (a == null && b == null) + if (a == null && b == null) { return null; + } return ToggleButtonsThemeData( textStyle: TextStyle.lerp(a?.textStyle, b?.textStyle, t), constraints: BoxConstraints.lerp(a?.constraints, b?.constraints, t), @@ -190,10 +191,12 @@ class ToggleButtonsThemeData 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 ToggleButtonsThemeData && other.textStyle == textStyle && other.constraints == constraints diff --git a/packages/flutter/lib/src/material/toggleable.dart b/packages/flutter/lib/src/material/toggleable.dart index 2bd89cad5080..13c1861675c9 100644 --- a/packages/flutter/lib/src/material/toggleable.dart +++ b/packages/flutter/lib/src/material/toggleable.dart @@ -183,17 +183,20 @@ mixin ToggleableStateMixin on TickerProviderStateMixin /// visual representation of the Toggleable matches the current [value]. void animateToValue() { if (tristate) { - if (value == null) + if (value == null) { _positionController.value = 0.0; - if (value ?? true) + } + if (value ?? true) { _positionController.forward(); - else + } else { _positionController.reverse(); + } } else { - if (value ?? false) + if (value ?? false) { _positionController.forward(); - else + } else { _positionController.reverse(); + } } } @@ -223,8 +226,9 @@ mixin ToggleableStateMixin on TickerProviderStateMixin } void _handleTap([Intent? _]) { - if (!isInteractive) + if (!isInteractive) { return; + } switch (value) { case false: onChanged!(true); diff --git a/packages/flutter/lib/src/material/tooltip.dart b/packages/flutter/lib/src/material/tooltip.dart index 048d1887e957..5cf4eb11c834 100644 --- a/packages/flutter/lib/src/material/tooltip.dart +++ b/packages/flutter/lib/src/material/tooltip.dart @@ -529,8 +529,9 @@ class TooltipState extends State with SingleTickerProviderStateMixin { /// Returns `false` when the tooltip shouldn't be shown or when the tooltip /// was already visible. bool ensureTooltipVisible() { - if (!_visible) + if (!_visible) { return false; + } _showTimer?.cancel(); _showTimer = null; _forceRemoval = false; @@ -668,10 +669,11 @@ class TooltipState extends State with SingleTickerProviderStateMixin { _pressActivated = true; final bool tooltipCreated = ensureTooltipVisible(); if (tooltipCreated && _enableFeedback) { - if (_triggerMode == TooltipTriggerMode.longPress) + if (_triggerMode == TooltipTriggerMode.longPress) { Feedback.forLongPress(context); - else + } else { Feedback.forTap(context); + } } widget.onTriggered?.call(); } diff --git a/packages/flutter/lib/src/material/tooltip_theme.dart b/packages/flutter/lib/src/material/tooltip_theme.dart index df8fba31e79e..36efc3c6bb3d 100644 --- a/packages/flutter/lib/src/material/tooltip_theme.dart +++ b/packages/flutter/lib/src/material/tooltip_theme.dart @@ -146,8 +146,9 @@ class TooltipThemeData with Diagnosticable { /// /// {@macro dart.ui.shadow.lerp} static TooltipThemeData? lerp(TooltipThemeData? a, TooltipThemeData? b, double t) { - if (a == null && b == null) + if (a == null && b == null) { return null; + } assert(t != null); return TooltipThemeData( height: lerpDouble(a?.height, b?.height, t), @@ -181,10 +182,12 @@ class TooltipThemeData 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 TooltipThemeData && other.height == height && other.padding == padding diff --git a/packages/flutter/lib/src/material/typography.dart b/packages/flutter/lib/src/material/typography.dart index b122253efbf7..9479b2610492 100644 --- a/packages/flutter/lib/src/material/typography.dart +++ b/packages/flutter/lib/src/material/typography.dart @@ -322,10 +322,12 @@ class Typography 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 Typography && other.black == black && other.white == white diff --git a/packages/flutter/test/material/app_bar_test.dart b/packages/flutter/test/material/app_bar_test.dart index 2767cc15c7ba..b1ea29cc771c 100644 --- a/packages/flutter/test/material/app_bar_test.dart +++ b/packages/flutter/test/material/app_bar_test.dart @@ -2574,8 +2574,9 @@ void main() { .delegate; // Ensure we have a non-null vsync when it's needed. - if (!floating || (delegate.snapConfiguration == null && delegate.showOnScreenConfiguration == null)) + if (!floating || (delegate.snapConfiguration == null && delegate.showOnScreenConfiguration == null)) { expect(delegate.vsync, isNotNull); + } expect(delegate.showOnScreenConfiguration != null, snap && floating); } diff --git a/packages/flutter/test/material/app_test.dart b/packages/flutter/test/material/app_test.dart index f0cb28651d95..c734de3c64fa 100644 --- a/packages/flutter/test/material/app_test.dart +++ b/packages/flutter/test/material/app_test.dart @@ -30,8 +30,9 @@ class StateMarkerState extends State { @override Widget build(BuildContext context) { - if (widget.child != null) + if (widget.child != null) { return widget.child!; + } return Container(); } } diff --git a/packages/flutter/test/material/banner_test.dart b/packages/flutter/test/material/banner_test.dart index 71b159171ad8..4a6b520599dc 100644 --- a/packages/flutter/test/material/banner_test.dart +++ b/packages/flutter/test/material/banner_test.dart @@ -789,7 +789,7 @@ void main() { ScaffoldMessenger.of(context).showMaterialBanner(MaterialBanner( content: const SizedBox(width: 100, height: 100), actions: List.generate(actionCount, (int index) { - if (index == 0) + if (index == 0) { return SizedBox( width: 64, height: 48, @@ -799,6 +799,7 @@ void main() { onTap: () => ScaffoldMessenger.of(context).hideCurrentMaterialBanner(), ), ); + } return SizedBox( width: 64, @@ -911,7 +912,7 @@ void main() { ScaffoldMessenger.of(context).showMaterialBanner(MaterialBanner( content: const SizedBox(width: 100, height: 100), actions: List.generate(actionCount, (int index) { - if (index == 0) + if (index == 0) { return SizedBox( width: 200, height: 10, @@ -921,6 +922,7 @@ void main() { onTap: () => ScaffoldMessenger.of(context).hideCurrentMaterialBanner(), ), ); + } return SizedBox( width: 200, @@ -1016,7 +1018,7 @@ void main() { overflowAlignment: overflowAlignment, content: const SizedBox(width: 100, height: 100), actions: List.generate(actionCount, (int index) { - if (index == 0) + if (index == 0) { return SizedBox( width: 200, height: 10, @@ -1026,6 +1028,7 @@ void main() { onTap: () => ScaffoldMessenger.of(context).hideCurrentMaterialBanner(), ), ); + } return SizedBox( width: 200, diff --git a/packages/flutter/test/material/bottom_app_bar_test.dart b/packages/flutter/test/material/bottom_app_bar_test.dart index cb6901a2f6b9..9885765bd137 100644 --- a/packages/flutter/test/material/bottom_app_bar_test.dart +++ b/packages/flutter/test/material/bottom_app_bar_test.dart @@ -571,8 +571,9 @@ class RectangularNotch extends NotchedShape { @override Path getOuterPath(Rect host, Rect? guest) { - if (guest == null) + if (guest == null) { return Path()..addRect(host); + } return Path() ..moveTo(host.left, host.top) ..lineTo(guest.left, host.top) diff --git a/packages/flutter/test/material/bottom_navigation_bar_test.dart b/packages/flutter/test/material/bottom_navigation_bar_test.dart index 7d2a25754136..29e7f5b47bfe 100644 --- a/packages/flutter/test/material/bottom_navigation_bar_test.dart +++ b/packages/flutter/test/material/bottom_navigation_bar_test.dart @@ -1560,8 +1560,9 @@ void main() { final Finder backgroundMaterial = find.descendant( of: find.byType(BottomNavigationBar), matching: find.byWidgetPredicate((Widget w) { - if (w is Material) + if (w is Material) { return w.type == MaterialType.canvas; + } return false; }), ); diff --git a/packages/flutter/test/material/chip_test.dart b/packages/flutter/test/material/chip_test.dart index c9236cef5473..15c8416fe255 100644 --- a/packages/flutter/test/material/chip_test.dart +++ b/packages/flutter/test/material/chip_test.dart @@ -177,8 +177,9 @@ bool radiiAreClose(double a, double b) => (a - b).abs() < 1.0; PaintPattern ripplePattern(Offset expectedCenter, double expectedRadius) { return paints ..something((Symbol method, List arguments) { - if (method != #drawCircle) + if (method != #drawCircle) { return false; + } final Offset center = arguments[0] as Offset; final double radius = arguments[1] as double; return offsetsAreClose(center, expectedCenter) && radiiAreClose(radius, expectedRadius); @@ -192,12 +193,14 @@ PaintPattern ripplePattern(Offset expectedCenter, double expectedRadius) { PaintPattern uniqueRipplePattern(Offset expectedCenter, double expectedRadius) { return paints ..everything((Symbol method, List arguments) { - if (method != #drawCircle) + if (method != #drawCircle) { return true; + } final Offset center = arguments[0] as Offset; final double radius = arguments[1] as double; - if (offsetsAreClose(center, expectedCenter) && radiiAreClose(radius, expectedRadius)) + if (offsetsAreClose(center, expectedCenter) && radiiAreClose(radius, expectedRadius)) { return true; + } throw ''' Expected: center == $expectedCenter, radius == $expectedRadius Found: center == $center radius == $radius'''; @@ -2553,20 +2556,25 @@ void main() { const Color disabledColor = Color(0x00000006); Color getTextColor(Set states) { - if (states.contains(MaterialState.disabled)) + if (states.contains(MaterialState.disabled)) { return disabledColor; + } - if (states.contains(MaterialState.pressed)) + if (states.contains(MaterialState.pressed)) { return pressedColor; + } - if (states.contains(MaterialState.hovered)) + if (states.contains(MaterialState.hovered)) { return hoverColor; + } - if (states.contains(MaterialState.focused)) + if (states.contains(MaterialState.focused)) { return focusedColor; + } - if (states.contains(MaterialState.selected)) + if (states.contains(MaterialState.selected)) { return selectedColor; + } return defaultColor; } @@ -2638,20 +2646,17 @@ void main() { BorderSide getBorderSide(Set states) { Color sideColor = defaultColor; - if (states.contains(MaterialState.disabled)) + if (states.contains(MaterialState.disabled)) { sideColor = disabledColor; - - else if (states.contains(MaterialState.pressed)) + } else if (states.contains(MaterialState.pressed)) { sideColor = pressedColor; - - else if (states.contains(MaterialState.hovered)) + } else if (states.contains(MaterialState.hovered)) { sideColor = hoverColor; - - else if (states.contains(MaterialState.focused)) + } else if (states.contains(MaterialState.focused)) { sideColor = focusedColor; - - else if (states.contains(MaterialState.selected)) + } else if (states.contains(MaterialState.selected)) { sideColor = selectedColor; + } return BorderSide(color: sideColor); } @@ -2720,20 +2725,17 @@ void main() { BorderSide getBorderSide(Set states) { Color sideColor = defaultColor; - if (states.contains(MaterialState.disabled)) + if (states.contains(MaterialState.disabled)) { sideColor = disabledColor; - - else if (states.contains(MaterialState.pressed)) + } else if (states.contains(MaterialState.pressed)) { sideColor = pressedColor; - - else if (states.contains(MaterialState.hovered)) + } else if (states.contains(MaterialState.hovered)) { sideColor = hoverColor; - - else if (states.contains(MaterialState.focused)) + } else if (states.contains(MaterialState.focused)) { sideColor = focusedColor; - - else if (states.contains(MaterialState.selected)) + } else if (states.contains(MaterialState.selected)) { sideColor = selectedColor; + } return BorderSide(color: sideColor); } @@ -2805,20 +2807,17 @@ void main() { BorderSide? getBorderSide(Set states) { Color sideColor = defaultColor; - if (states.contains(MaterialState.disabled)) + if (states.contains(MaterialState.disabled)) { sideColor = disabledColor; - - else if (states.contains(MaterialState.pressed)) + } else if (states.contains(MaterialState.pressed)) { sideColor = pressedColor; - - else if (states.contains(MaterialState.hovered)) + } else if (states.contains(MaterialState.hovered)) { sideColor = hoverColor; - - else if (states.contains(MaterialState.focused)) + } else if (states.contains(MaterialState.focused)) { sideColor = focusedColor; - - else if (states.contains(MaterialState.selected)) + } else if (states.contains(MaterialState.selected)) { return null; + } return BorderSide(color: sideColor); } @@ -2885,20 +2884,17 @@ void main() { final FocusNode focusNode = FocusNode(); OutlinedBorder? getShape(Set states) { - if (states.contains(MaterialState.disabled)) + if (states.contains(MaterialState.disabled)) { return const BeveledRectangleBorder(); - - else if (states.contains(MaterialState.pressed)) + } else if (states.contains(MaterialState.pressed)) { return const CircleBorder(); - - else if (states.contains(MaterialState.hovered)) + } else if (states.contains(MaterialState.hovered)) { return const ContinuousRectangleBorder(); - - else if (states.contains(MaterialState.focused)) + } else if (states.contains(MaterialState.focused)) { return const RoundedRectangleBorder(); - - else if (states.contains(MaterialState.selected)) + } else if (states.contains(MaterialState.selected)) { return const BeveledRectangleBorder(); + } return null; } @@ -2961,14 +2957,16 @@ void main() { const BorderSide selectedBorderSide = BorderSide(color: Color(0x00000002)); OutlinedBorder? getShape(Set states) { - if (states.contains(MaterialState.selected)) + if (states.contains(MaterialState.selected)) { return selectedShape; + } return null; } BorderSide? getBorderSide(Set states) { - if (states.contains(MaterialState.selected)) + if (states.contains(MaterialState.selected)) { return selectedBorderSide; + } return null; } diff --git a/packages/flutter/test/material/chip_theme_test.dart b/packages/flutter/test/material/chip_theme_test.dart index 0df7a0960b48..2722c8bc7223 100644 --- a/packages/flutter/test/material/chip_theme_test.dart +++ b/packages/flutter/test/material/chip_theme_test.dart @@ -504,20 +504,25 @@ void main() { const Color disabledColor = Color(0x00000006); Color getTextColor(Set states) { - if (states.contains(MaterialState.disabled)) + if (states.contains(MaterialState.disabled)) { return disabledColor; + } - if (states.contains(MaterialState.pressed)) + if (states.contains(MaterialState.pressed)) { return pressedColor; + } - if (states.contains(MaterialState.hovered)) + if (states.contains(MaterialState.hovered)) { return hoverColor; + } - if (states.contains(MaterialState.focused)) + if (states.contains(MaterialState.focused)) { return focusedColor; + } - if (states.contains(MaterialState.selected)) + if (states.contains(MaterialState.selected)) { return selectedColor; + } return defaultColor; } @@ -591,8 +596,9 @@ void main() { BorderSide getBorderSide(Set states) { Color color = defaultColor; - if (states.contains(MaterialState.selected)) + if (states.contains(MaterialState.selected)) { color = selectedColor; + } return BorderSide(color: color); } @@ -629,8 +635,9 @@ void main() { BorderSide getBorderSide(Set states) { Color color = defaultColor; - if (states.contains(MaterialState.selected)) + if (states.contains(MaterialState.selected)) { color = selectedColor; + } return BorderSide(color: color); } @@ -666,8 +673,9 @@ void main() { testWidgets('Chip uses stateful shape from chip theme', (WidgetTester tester) async { OutlinedBorder? getShape(Set states) { - if (states.contains(MaterialState.selected)) + if (states.contains(MaterialState.selected)) { return const RoundedRectangleBorder(); + } return null; } diff --git a/packages/flutter/test/material/colors_test.dart b/packages/flutter/test/material/colors_test.dart index 7882f67a435a..52f3db31167f 100644 --- a/packages/flutter/test/material/colors_test.dart +++ b/packages/flutter/test/material/colors_test.dart @@ -52,13 +52,15 @@ void main() { }); test('Colors swatches do not contain duplicates', () { - for (final MaterialColor color in Colors.primaries) + for (final MaterialColor color in Colors.primaries) { expect(primaryKeys.map((int key) => color[key]!).toSet().length, primaryKeys.length); + } expect(primaryKeys.map((int key) => Colors.grey[key]!).toSet().length, primaryKeys.length); - for (final MaterialAccentColor color in Colors.accents) + for (final MaterialAccentColor color in Colors.accents) { expect(accentKeys.map((int key) => color[key]!).toSet().length, accentKeys.length); + } }); test('All color swatch colors are opaque and equal their primary color', () { diff --git a/packages/flutter/test/material/data_table_test.dart b/packages/flutter/test/material/data_table_test.dart index bc4f0b2bd431..89758049f9d1 100644 --- a/packages/flutter/test/material/data_table_test.dart +++ b/packages/flutter/test/material/data_table_test.dart @@ -1468,8 +1468,9 @@ void main() { selected: selected, color: MaterialStateProperty.resolveWith( (Set states) { - if (states.contains(MaterialState.selected)) + if (states.contains(MaterialState.selected)) { return selectedColor; + } return defaultColor; }, ), @@ -1521,8 +1522,9 @@ void main() { DataRow( color: MaterialStateProperty.resolveWith( (Set states) { - if (states.contains(MaterialState.disabled)) + if (states.contains(MaterialState.disabled)) { return disabledColor; + } return defaultColor; }, ), @@ -1566,8 +1568,9 @@ void main() { DataRow( color: MaterialStateProperty.resolveWith( (Set states) { - if (states.contains(MaterialState.pressed)) + if (states.contains(MaterialState.pressed)) { return pressedColor; + } return Colors.transparent; }, ), diff --git a/packages/flutter/test/material/feedback_tester.dart b/packages/flutter/test/material/feedback_tester.dart index c65d9949b9ab..831738e340e8 100644 --- a/packages/flutter/test/material/feedback_tester.dart +++ b/packages/flutter/test/material/feedback_tester.dart @@ -23,11 +23,13 @@ class FeedbackTester { int _clickSoundCount = 0; Future _handler(MethodCall methodCall) async { - if (methodCall.method == 'HapticFeedback.vibrate') + if (methodCall.method == 'HapticFeedback.vibrate') { _hapticCount++; + } if (methodCall.method == 'SystemSound.play' && - methodCall.arguments == SystemSoundType.click.toString()) + methodCall.arguments == SystemSoundType.click.toString()) { _clickSoundCount++; + } } /// Stops tracking. diff --git a/packages/flutter/test/material/floating_action_button_location_test.dart b/packages/flutter/test/material/floating_action_button_location_test.dart index b1ffb854af4d..21819d8ae803 100644 --- a/packages/flutter/test/material/floating_action_button_location_test.dart +++ b/packages/flutter/test/material/floating_action_button_location_test.dart @@ -1536,11 +1536,13 @@ class _GeometryListenerState extends State<_GeometryListener> { void didChangeDependencies() { super.didChangeDependencies(); final ValueListenable newListenable = Scaffold.geometryOf(context); - if (geometryListenable == newListenable) + if (geometryListenable == newListenable) { return; + } - if (geometryListenable != null) + if (geometryListenable != null) { geometryListenable!.removeListener(onGeometryChanged); + } geometryListenable = newListenable; geometryListenable!.addListener(onGeometryChanged); diff --git a/packages/flutter/test/material/ink_paint_test.dart b/packages/flutter/test/material/ink_paint_test.dart index f260c29abc74..083a72b2c040 100644 --- a/packages/flutter/test/material/ink_paint_test.dart +++ b/packages/flutter/test/material/ink_paint_test.dart @@ -127,13 +127,15 @@ void main() { ..translate(x: 0.0, y: 0.0) ..translate(x: tapDownOffset.dx, y: tapDownOffset.dy) ..something((Symbol method, List arguments) { - if (method != #drawCircle) + if (method != #drawCircle) { return false; + } final Offset center = arguments[0] as Offset; final double radius = arguments[1] as double; final Paint paint = arguments[2] as Paint; - if (offsetsAreClose(center, expectedCenter) && radiiAreClose(radius, expectedRadius) && paint.color.alpha == expectedAlpha) + if (offsetsAreClose(center, expectedCenter) && radiiAreClose(radius, expectedRadius) && paint.color.alpha == expectedAlpha) { return true; + } throw ''' Expected: center == $expectedCenter, radius == $expectedRadius, alpha == $expectedAlpha Found: center == $center radius == $radius alpha == ${paint.color.alpha}'''; @@ -423,11 +425,13 @@ void main() { final RenderBox box = Material.of(tester.element(find.byType(InkWell)))! as RenderBox; expect(box, paints..everything((Symbol method, List arguments) { - if (method != #drawCircle) + if (method != #drawCircle) { return true; + } final Paint paint = arguments[2] as Paint; - if (paint.color.alpha == 0) + if (paint.color.alpha == 0) { return true; + } throw 'Expected: paint.color.alpha == 0, found: ${paint.color.alpha}'; })); }); diff --git a/packages/flutter/test/material/ink_well_test.dart b/packages/flutter/test/material/ink_well_test.dart index 5121235f5a22..13d76d2ea052 100644 --- a/packages/flutter/test/material/ink_well_test.dart +++ b/packages/flutter/test/material/ink_well_test.dart @@ -188,12 +188,15 @@ void main() { height: 100, child: InkWell( overlayColor: MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.hovered)) + if (states.contains(MaterialState.hovered)) { return const Color(0xff00ff00); - if (states.contains(MaterialState.focused)) + } + if (states.contains(MaterialState.focused)) { return const Color(0xff0000ff); - if (states.contains(MaterialState.pressed)) + } + if (states.contains(MaterialState.pressed)) { return const Color(0xf00fffff); + } return const Color(0xffbadbad); // Shouldn't happen. }), onTap: () { }, @@ -265,12 +268,15 @@ void main() { child: InkWell( focusNode: focusNode, overlayColor: MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.hovered)) + if (states.contains(MaterialState.hovered)) { return const Color(0xff00ff00); - if (states.contains(MaterialState.focused)) + } + if (states.contains(MaterialState.focused)) { return const Color(0xff0000ff); - if (states.contains(MaterialState.pressed)) + } + if (states.contains(MaterialState.pressed)) { return const Color(0xf00fffff); + } return const Color(0xffbadbad); // Shouldn't happen. }), highlightColor: const Color(0xf00fffff), @@ -381,12 +387,15 @@ void main() { height: 100, child: InkWell( overlayColor: MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.hovered)) + if (states.contains(MaterialState.hovered)) { return const Color(0xff00ff00); - if (states.contains(MaterialState.focused)) + } + if (states.contains(MaterialState.focused)) { return const Color(0xff0000ff); - if (states.contains(MaterialState.pressed)) + } + if (states.contains(MaterialState.pressed)) { return splashColor; + } return const Color(0xffbadbad); // Shouldn't happen. }), onTap: () { }, diff --git a/packages/flutter/test/material/input_decorator_test.dart b/packages/flutter/test/material/input_decorator_test.dart index f81d30f4b9e2..a7b63da15ff4 100644 --- a/packages/flutter/test/material/input_decorator_test.dart +++ b/packages/flutter/test/material/input_decorator_test.dart @@ -97,8 +97,9 @@ TextStyle getLabelStyle(WidgetTester tester) { } InputBorder? getBorder(WidgetTester tester) { - if (!tester.any(findBorderPainter())) + if (!tester.any(findBorderPainter())) { return null; + } final CustomPaint customPaint = tester.widget(findBorderPainter()); final dynamic/*_InputBorderPainter*/ inputBorderPainter = customPaint.foregroundPainter; // ignore: avoid_dynamic_calls diff --git a/packages/flutter/test/material/list_tile_test.dart b/packages/flutter/test/material/list_tile_test.dart index d9028fa0a4e7..c5a91e02201a 100644 --- a/packages/flutter/test/material/list_tile_test.dart +++ b/packages/flutter/test/material/list_tile_test.dart @@ -88,8 +88,9 @@ void main() { void testChildren() { expect(find.byKey(leadingKey), findsOneWidget); expect(find.text('title'), findsOneWidget); - if (hasSubtitle) + if (hasSubtitle) { expect(find.text('subtitle'), findsOneWidget); + } expect(find.byKey(trailingKey), findsOneWidget); } @@ -109,8 +110,9 @@ void main() { void testHorizontalGeometry() { expect(leftKey(leadingKey), math.max(16.0, leftPadding)); expect(left('title'), 56.0 + math.max(16.0, leftPadding)); - if (hasSubtitle) + if (hasSubtitle) { expect(left('subtitle'), 56.0 + math.max(16.0, leftPadding)); + } expect(left('title'), rightKey(leadingKey) + 32.0); expect(rightKey(trailingKey), 800.0 - math.max(16.0, rightPadding)); expect(widthKey(trailingKey), 24.0); diff --git a/packages/flutter/test/material/navigation_rail_test.dart b/packages/flutter/test/material/navigation_rail_test.dart index 717be41ae95b..aad594bd4ea0 100644 --- a/packages/flutter/test/material/navigation_rail_test.dart +++ b/packages/flutter/test/material/navigation_rail_test.dart @@ -4573,8 +4573,9 @@ double? _labelOpacity(WidgetTester tester, String text) { of: find.text(text), matching: find.byType(Opacity), )); - if (opacityWidgets.isNotEmpty) + if (opacityWidgets.isNotEmpty) { return opacityWidgets.single.opacity; + } final FadeTransition fadeTransitionWidget = tester.widget( find.ancestor( diff --git a/packages/flutter/test/material/outlined_button_test.dart b/packages/flutter/test/material/outlined_button_test.dart index 82bfec795e6e..4f1b2a34db34 100644 --- a/packages/flutter/test/material/outlined_button_test.dart +++ b/packages/flutter/test/material/outlined_button_test.dart @@ -829,10 +829,12 @@ void main() { minimumSize: const Size(64, 36), ).copyWith( side: MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.disabled)) + if (states.contains(MaterialState.disabled)) { return disabledBorderSide; - if (states.contains(MaterialState.pressed)) + } + if (states.contains(MaterialState.pressed)) { return pressedBorderSide; + } return enabledBorderSide; }), ), diff --git a/packages/flutter/test/material/page_selector_test.dart b/packages/flutter/test/material/page_selector_test.dart index 040f5f84ae7a..538f718c19c4 100644 --- a/packages/flutter/test/material/page_selector_test.dart +++ b/packages/flutter/test/material/page_selector_test.dart @@ -220,8 +220,9 @@ void main() { ).evaluate(); // Indicators get an 8 pixel margin, 16 + 8 = 24. - for (final Element indicatorElement in indicatorElements) + for (final Element indicatorElement in indicatorElements) { expect(indicatorElement.size, const Size(24.0, 24.0)); + } expect(tester.getSize(find.byType(TabPageSelector)).height, 24.0); }); @@ -243,8 +244,9 @@ void main() { matching: find.byType(TabPageSelectorIndicator), ), ); - for (final TabPageSelectorIndicator indicator in indicators) + for (final TabPageSelectorIndicator indicator in indicators) { expect(indicator.borderStyle, BorderStyle.solid); + } // No border await tester.pumpWidget(buildFrame(tabController, borderStyle: BorderStyle.none)); @@ -254,8 +256,9 @@ void main() { matching: find.byType(TabPageSelectorIndicator), ), ); - for (final TabPageSelectorIndicator indicator in indicators) + for (final TabPageSelectorIndicator indicator in indicators) { expect(indicator.borderStyle, BorderStyle.none); + } // Solid border await tester.pumpWidget(buildFrame(tabController, borderStyle: BorderStyle.solid)); @@ -265,7 +268,8 @@ void main() { matching: find.byType(TabPageSelectorIndicator), ), ); - for (final TabPageSelectorIndicator indicator in indicators) + for (final TabPageSelectorIndicator indicator in indicators) { expect(indicator.borderStyle, BorderStyle.solid); + } }); } diff --git a/packages/flutter/test/material/paginated_data_table_test.dart b/packages/flutter/test/material/paginated_data_table_test.dart index 2c148d8edf34..38bf14ab0305 100644 --- a/packages/flutter/test/material/paginated_data_table_test.dart +++ b/packages/flutter/test/material/paginated_data_table_test.dart @@ -25,8 +25,9 @@ class TestDataSource extends DataTableSource { int get generation => _generation; int _generation = 0; set generation(int value) { - if (_generation == value) + if (_generation == value) { return; + } _generation = value; notifyListeners(); } diff --git a/packages/flutter/test/material/range_slider_test.dart b/packages/flutter/test/material/range_slider_test.dart index 8e1f3f8107cd..e713958af7f9 100644 --- a/packages/flutter/test/material/range_slider_test.dart +++ b/packages/flutter/test/material/range_slider_test.dart @@ -1938,8 +1938,9 @@ void main() { late Rect activeTrackRect; expect(renderObject, paints..something((Symbol method, List arguments) { - if (method != #drawRect) + if (method != #drawRect) { return false; + } activeTrackRect = arguments[0] as Rect; return true; })); diff --git a/packages/flutter/test/material/scaffold_test.dart b/packages/flutter/test/material/scaffold_test.dart index d1c092e63734..d4f21bdb16e9 100644 --- a/packages/flutter/test/material/scaffold_test.dart +++ b/packages/flutter/test/material/scaffold_test.dart @@ -2444,11 +2444,13 @@ class _GeometryListenerState extends State<_GeometryListener> { void didChangeDependencies() { super.didChangeDependencies(); final ValueListenable newListenable = Scaffold.geometryOf(context); - if (geometryListenable == newListenable) + if (geometryListenable == newListenable) { return; + } - if (geometryListenable != null) + if (geometryListenable != null) { geometryListenable!.removeListener(onGeometryChanged); + } geometryListenable = newListenable; geometryListenable!.addListener(onGeometryChanged); diff --git a/packages/flutter/test/material/scrollbar_test.dart b/packages/flutter/test/material/scrollbar_test.dart index 0a74f9d4e7a0..37a3f32401bd 100644 --- a/packages/flutter/test/material/scrollbar_test.dart +++ b/packages/flutter/test/material/scrollbar_test.dart @@ -1065,8 +1065,9 @@ void main() { return states.contains(MaterialState.hovered); }), thickness: MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.hovered)) + if (states.contains(MaterialState.hovered)) { return 40.0; + } // Default thickness return 8.0; }), @@ -1130,8 +1131,9 @@ void main() { theme: ThemeData(scrollbarTheme: ScrollbarThemeData( isAlwaysShown: true, trackVisibility: MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.hovered)) + if (states.contains(MaterialState.hovered)) { return true; + } return false; }), )), diff --git a/packages/flutter/test/material/scrollbar_theme_test.dart b/packages/flutter/test/material/scrollbar_theme_test.dart index addd648bf7e5..93461e8c729b 100644 --- a/packages/flutter/test/material/scrollbar_theme_test.dart +++ b/packages/flutter/test/material/scrollbar_theme_test.dart @@ -706,29 +706,34 @@ ScrollbarThemeData _scrollbarTheme({ } double? _getThickness(Set states) { - if (states.contains(MaterialState.hovered)) + if (states.contains(MaterialState.hovered)) { return 20.0; + } return 10.0; } bool? _getThumbVisibility(Set states) => true; Color? _getThumbColor(Set states) { - if (states.contains(MaterialState.dragged)) + if (states.contains(MaterialState.dragged)) { return Colors.red; - if (states.contains(MaterialState.hovered)) + } + if (states.contains(MaterialState.hovered)) { return Colors.blue; + } return Colors.green; } Color? _getTrackColor(Set states) { - if (states.contains(MaterialState.hovered)) + if (states.contains(MaterialState.hovered)) { return Colors.black; + } return null; } Color? _getTrackBorderColor(Set states) { - if (states.contains(MaterialState.hovered)) + if (states.contains(MaterialState.hovered)) { return Colors.yellow; + } return null; } diff --git a/packages/flutter/test/material/slider_test.dart b/packages/flutter/test/material/slider_test.dart index b466096dcb94..baee8fb34654 100644 --- a/packages/flutter/test/material/slider_test.dart +++ b/packages/flutter/test/material/slider_test.dart @@ -2884,8 +2884,9 @@ void main() { late RRect activeTrackRRect; expect(renderObject, paints..something((Symbol method, List arguments) { - if (method != #drawRRect) + if (method != #drawRRect) { return false; + } activeTrackRRect = arguments[0] as RRect; return true; })); diff --git a/packages/flutter/test/material/stepper_test.dart b/packages/flutter/test/material/stepper_test.dart index e11f26a5713f..c883cae6483b 100644 --- a/packages/flutter/test/material/stepper_test.dart +++ b/packages/flutter/test/material/stepper_test.dart @@ -462,8 +462,9 @@ testWidgets('Stepper custom indexed controls test', (WidgetTester tester) async Widget builder(BuildContext context, ControlsDetails details) { // For the purposes of testing, only render something for the active // step. - if (!details.isActive) + if (!details.isActive) { return Container(); + } return Container( margin: const EdgeInsets.only(top: 16.0), diff --git a/packages/flutter/test/material/tabs_test.dart b/packages/flutter/test/material/tabs_test.dart index 4f29a87c7ad7..21637e24d5c5 100644 --- a/packages/flutter/test/material/tabs_test.dart +++ b/packages/flutter/test/material/tabs_test.dart @@ -43,8 +43,9 @@ class StateMarkerState extends State { @override Widget build(BuildContext context) { - if (widget.child != null) + if (widget.child != null) { return widget.child!; + } return Container(); } } @@ -204,8 +205,9 @@ class TabIndicatorRecordingCanvas extends TestRecordingCanvas { void drawLine(Offset p1, Offset p2, Paint paint) { // Assuming that the indicatorWeight is 2.0, the default. const double indicatorWeight = 2.0; - if (paint.color == indicatorColor) + if (paint.color == indicatorColor) { indicatorRect = Rect.fromPoints(p1, p2).inflate(indicatorWeight / 2.0); + } } } @@ -812,8 +814,9 @@ void main() { )); tabController.animation!.addListener(() { - if (tabController.animation!.status == AnimationStatus.forward) + if (tabController.animation!.status == AnimationStatus.forward) { tabController.index = 2; + } expect(tabController.indexIsChanging, true); }); @@ -3207,10 +3210,12 @@ void main() { ], overlayColor: MaterialStateProperty.resolveWith( (Set states) { - if (states.contains(MaterialState.hovered)) - return const Color(0xff00ff00); - if (states.contains(MaterialState.pressed)) + if (states.contains(MaterialState.hovered)) { + return const Color(0xff00ff00); + } + if (states.contains(MaterialState.pressed)) { return const Color(0xf00fffff); + } return const Color(0xffbadbad); // Shouldn't happen. }, ), @@ -3240,10 +3245,12 @@ void main() { ], overlayColor: MaterialStateProperty.resolveWith( (Set states) { - if (states.contains(MaterialState.hovered)) + if (states.contains(MaterialState.hovered)) { return const Color(0xff00ff00); - if (states.contains(MaterialState.pressed)) + } + if (states.contains(MaterialState.pressed)) { return splashColor; + } return const Color(0xffbadbad); // Shouldn't happen. }, ), diff --git a/packages/flutter/test/material/text_field_test.dart b/packages/flutter/test/material/text_field_test.dart index 2cf0cb56a1c4..6f241bf985ad 100644 --- a/packages/flutter/test/material/text_field_test.dart +++ b/packages/flutter/test/material/text_field_test.dart @@ -5151,11 +5151,12 @@ void main() { String clipboardContent = ''; tester.binding.defaultBinaryMessenger .setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async { - if (methodCall.method == 'Clipboard.setData') + if (methodCall.method == 'Clipboard.setData') { // ignore: avoid_dynamic_calls clipboardContent = methodCall.arguments['text'] as String; - else if (methodCall.method == 'Clipboard.getData') + } else if (methodCall.method == 'Clipboard.getData') { return {'text': clipboardContent}; + } return null; }); @@ -5227,8 +5228,9 @@ void main() { const String clipboardContent = 'I love Flutter!'; tester.binding.defaultBinaryMessenger .setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async { - if (methodCall.method == 'Clipboard.getData') + if (methodCall.method == 'Clipboard.getData') { return {'text': clipboardContent}; + } return null; }); @@ -5276,11 +5278,12 @@ void main() { String clipboardContent = ''; tester.binding.defaultBinaryMessenger .setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async { - if (methodCall.method == 'Clipboard.setData') + if (methodCall.method == 'Clipboard.setData') { // ignore: avoid_dynamic_calls clipboardContent = methodCall.arguments['text'] as String; - else if (methodCall.method == 'Clipboard.getData') + } else if (methodCall.method == 'Clipboard.getData') { return {'text': clipboardContent}; + } return null; }); diff --git a/packages/flutter/test/material/theme_test.dart b/packages/flutter/test/material/theme_test.dart index 364359ffb4e8..1a66e7a6ef09 100644 --- a/packages/flutter/test/material/theme_test.dart +++ b/packages/flutter/test/material/theme_test.dart @@ -201,8 +201,9 @@ void main() { await tester.tap(find.byKey(dropdownMenuButtonKey)); await tester.pump(const Duration(seconds: 1)); - for (final Element item in tester.elementList(find.text('menuItem'))) + for (final Element item in tester.elementList(find.text('menuItem'))) { expect(Theme.of(item).brightness, equals(Brightness.light)); + } }); testWidgets('ModalBottomSheet inherits shadowed app theme', (WidgetTester tester) async { diff --git a/packages/flutter/test/material/tooltip_test.dart b/packages/flutter/test/material/tooltip_test.dart index 0114e669af5f..01fcd2547f1f 100644 --- a/packages/flutter/test/material/tooltip_test.dart +++ b/packages/flutter/test/material/tooltip_test.dart @@ -1001,8 +1001,9 @@ void main() { const Duration waitDuration = Duration.zero; TestGesture? gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); addTearDown(() async { - if (gesture != null) + if (gesture != null) { return gesture.removePointer(); + } }); await gesture.addPointer(); await gesture.moveTo(const Offset(1.0, 1.0)); @@ -1056,8 +1057,9 @@ void main() { const Duration waitDuration = Duration.zero; TestGesture? gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); addTearDown(() async { - if (gesture != null) + if (gesture != null) { return gesture.removePointer(); + } }); await gesture.addPointer(); await gesture.moveTo(const Offset(1.0, 1.0)); @@ -1226,8 +1228,9 @@ void main() { const Duration waitDuration = Duration.zero; TestGesture? gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); addTearDown(() async { - if (gesture != null) + if (gesture != null) { return gesture.removePointer(); + } }); await gesture.addPointer(); await gesture.moveTo(const Offset(1.0, 1.0)); @@ -1270,8 +1273,9 @@ void main() { const Duration waitDuration = Duration.zero; TestGesture? gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); addTearDown(() async { - if (gesture != null) + if (gesture != null) { return gesture.removePointer(); + } }); await gesture.addPointer(); await gesture.moveTo(const Offset(1.0, 1.0)); @@ -1337,8 +1341,9 @@ void main() { const Duration waitDuration = Duration(seconds: 1); final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); addTearDown(() async { - if (gesture != null) + if (gesture != null) { return gesture.removePointer(); + } }); await gesture.addPointer(); await gesture.moveTo(const Offset(1.0, 1.0)); @@ -1939,7 +1944,8 @@ Future testGestureTap(WidgetTester tester, Finder tooltip) async { } SemanticsNode findDebugSemantics(RenderObject object) { - if (object.debugSemantics != null) + if (object.debugSemantics != null) { return object.debugSemantics!; + } return findDebugSemantics(object.parent! as RenderObject); } diff --git a/packages/flutter/test/material/tooltip_theme_test.dart b/packages/flutter/test/material/tooltip_theme_test.dart index 4d1eb407a075..c8ef44f18127 100644 --- a/packages/flutter/test/material/tooltip_theme_test.dart +++ b/packages/flutter/test/material/tooltip_theme_test.dart @@ -1355,7 +1355,8 @@ void main() { } SemanticsNode findDebugSemantics(RenderObject object) { - if (object.debugSemantics != null) + if (object.debugSemantics != null) { return object.debugSemantics!; + } return findDebugSemantics(object.parent! as RenderObject); } diff --git a/packages/flutter/test/material/tooltip_visibility_test.dart b/packages/flutter/test/material/tooltip_visibility_test.dart index fda54b90d200..6c44a50fcdeb 100644 --- a/packages/flutter/test/material/tooltip_visibility_test.dart +++ b/packages/flutter/test/material/tooltip_visibility_test.dart @@ -14,8 +14,9 @@ void main() { testWidgets('Tooltip does not build MouseRegion when mouse is detected and in TooltipVisibility with visibility = false', (WidgetTester tester) async { final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); addTearDown(() async { - if (gesture != null) + if (gesture != null) { return gesture.removePointer(); + } }); await gesture.addPointer(); await gesture.moveTo(const Offset(1.0, 1.0)); @@ -44,8 +45,9 @@ void main() { const Duration waitDuration = Duration.zero; final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); addTearDown(() async { - if (gesture != null) + if (gesture != null) { return gesture.removePointer(); + } }); await gesture.addPointer(); await gesture.moveTo(const Offset(1.0, 1.0)); @@ -84,8 +86,9 @@ void main() { const Duration waitDuration = Duration.zero; TestGesture? gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); addTearDown(() async { - if (gesture != null) + if (gesture != null) { return gesture.removePointer(); + } }); await gesture.addPointer(); await gesture.moveTo(const Offset(1.0, 1.0));