diff --git a/examples/layers/rendering/src/sector_layout.dart b/examples/layers/rendering/src/sector_layout.dart index ae94fd17c5..f37f48afc9 100644 --- a/examples/layers/rendering/src/sector_layout.dart +++ b/examples/layers/rendering/src/sector_layout.dart @@ -287,9 +287,11 @@ class RenderSectorRing extends RenderSectorWithChildren { remainingDeltaTheta -= paddingTheta; } } - return SectorDimensions.withConstraints(constraints, - deltaRadius: outerDeltaRadius, - deltaTheta: innerTheta); + return SectorDimensions.withConstraints( + constraints, + deltaRadius: outerDeltaRadius, + deltaTheta: innerTheta, + ); } @override @@ -399,9 +401,11 @@ class RenderSectorSlice extends RenderSectorWithChildren { childRadius += padding; remainingDeltaRadius -= padding; } - return SectorDimensions.withConstraints(constraints, - deltaRadius: childRadius - parentData!.radius, - deltaTheta: outerDeltaTheta); + return SectorDimensions.withConstraints( + constraints, + deltaRadius: childRadius - parentData!.radius, + deltaTheta: outerDeltaTheta, + ); } @override diff --git a/packages/flutter/lib/src/animation/curves.dart b/packages/flutter/lib/src/animation/curves.dart index 801db30749..8f4afd4eab 100644 --- a/packages/flutter/lib/src/animation/curves.dart +++ b/packages/flutter/lib/src/animation/curves.dart @@ -931,17 +931,21 @@ class CatmullRomCurve extends Curve { i < controlPoints.length - 2 && (controlPoints[i].dx <= 0.0 || controlPoints[i].dx >= 1.0)) { assert(() { - reasons?.add('Control points must have X values between 0.0 and 1.0, exclusive. ' - 'Point $i has an x value (${controlPoints![i].dx}) which is outside the range.'); + reasons?.add( + 'Control points must have X values between 0.0 and 1.0, exclusive. ' + 'Point $i has an x value (${controlPoints![i].dx}) which is outside the range.', + ); return true; }()); return false; } if (controlPoints[i].dx <= lastX) { assert(() { - reasons?.add('Each X coordinate must be greater than the preceding X coordinate ' - '(i.e. must be monotonically increasing in X). Point $i has an x value of ' - '${controlPoints![i].dx}, which is not greater than $lastX'); + reasons?.add( + 'Each X coordinate must be greater than the preceding X coordinate ' + '(i.e. must be monotonically increasing in X). Point $i has an x value of ' + '${controlPoints![i].dx}, which is not greater than $lastX', + ); return true; }()); return false; @@ -964,9 +968,11 @@ class CatmullRomCurve extends Curve { bool bail = true; success = false; assert(() { - reasons?.add('The curve has more than one Y value at X = ${samplePoints.first.value.dx}. ' - 'Try moving some control points further away from this value of X, or increasing ' - 'the tension.'); + reasons?.add( + 'The curve has more than one Y value at X = ${samplePoints.first.value.dx}. ' + 'Try moving some control points further away from this value of X, or increasing ' + 'the tension.', + ); // No need to keep going if we're not giving reasons. bail = reasons == null; return true; @@ -985,8 +991,10 @@ class CatmullRomCurve extends Curve { bool bail = true; success = false; assert(() { - reasons?.add('The resulting curve has an X value ($x) which is outside ' - 'the range [0.0, 1.0], inclusive.'); + reasons?.add( + 'The resulting curve has an X value ($x) which is outside ' + 'the range [0.0, 1.0], inclusive.', + ); // No need to keep going if we're not giving reasons. bail = reasons == null; return true; @@ -1001,8 +1009,10 @@ class CatmullRomCurve extends Curve { bool bail = true; success = false; assert(() { - reasons?.add('The curve has more than one Y value at x = $x. Try moving ' - 'some control points further apart in X, or increasing the tension.'); + reasons?.add( + 'The curve has more than one Y value at x = $x. Try moving ' + 'some control points further apart in X, or increasing the tension.', + ); // No need to keep going if we're not giving reasons. bail = reasons == null; return true; diff --git a/packages/flutter/lib/src/cupertino/action_sheet.dart b/packages/flutter/lib/src/cupertino/action_sheet.dart index 7c1d7be950..205ff6cc24 100644 --- a/packages/flutter/lib/src/cupertino/action_sheet.dart +++ b/packages/flutter/lib/src/cupertino/action_sheet.dart @@ -169,9 +169,11 @@ class CupertinoActionSheet extends StatelessWidget { this.messageScrollController, this.actionScrollController, this.cancelButton, - }) : assert(actions != null || title != null || message != null || cancelButton != null, - 'An action sheet must have a non-null value for at least one of the following arguments: ' - 'actions, title, message, or cancelButton'), + }) : assert( + actions != null || title != null || message != null || cancelButton != null, + 'An action sheet must have a non-null value for at least one of the following arguments: ' + 'actions, title, message, or cancelButton', + ), super(key: key); /// An optional title of the action sheet. When the [message] is non-null, @@ -491,10 +493,8 @@ class _CupertinoAlertRenderElement extends RenderObjectElement { @override void mount(Element? parent, Object? newSlot) { super.mount(parent, newSlot); - _contentElement = updateChild(_contentElement, - widget.contentSection, _AlertSections.contentSection); - _actionsElement = updateChild(_actionsElement, - widget.actionsSection, _AlertSections.actionsSection); + _contentElement = updateChild(_contentElement, widget.contentSection, _AlertSections.contentSection); + _actionsElement = updateChild(_actionsElement, widget.actionsSection, _AlertSections.actionsSection); } @override @@ -510,10 +510,8 @@ class _CupertinoAlertRenderElement extends RenderObjectElement { @override void update(RenderObjectWidget newWidget) { super.update(newWidget); - _contentElement = updateChild(_contentElement, - widget.contentSection, _AlertSections.contentSection); - _actionsElement = updateChild(_actionsElement, - widget.actionsSection, _AlertSections.actionsSection); + _contentElement = updateChild(_contentElement, widget.contentSection, _AlertSections.contentSection); + _actionsElement = updateChild(_actionsElement, widget.actionsSection, _AlertSections.actionsSection); } @override diff --git a/packages/flutter/lib/src/cupertino/segmented_control.dart b/packages/flutter/lib/src/cupertino/segmented_control.dart index e765fae508..3bdb858cd6 100644 --- a/packages/flutter/lib/src/cupertino/segmented_control.dart +++ b/packages/flutter/lib/src/cupertino/segmented_control.dart @@ -612,11 +612,17 @@ class _RenderSegmentedControl extends RenderBox final Rect childRect = Rect.fromLTWH(start, 0.0, child.size.width, child.size.height); final RRect rChildRect; if (child == leftChild) { - rChildRect = RRect.fromRectAndCorners(childRect, topLeft: const Radius.circular(3.0), - bottomLeft: const Radius.circular(3.0)); + rChildRect = RRect.fromRectAndCorners( + childRect, + topLeft: const Radius.circular(3.0), + bottomLeft: const Radius.circular(3.0), + ); } else if (child == rightChild) { - rChildRect = RRect.fromRectAndCorners(childRect, topRight: const Radius.circular(3.0), - bottomRight: const Radius.circular(3.0)); + rChildRect = RRect.fromRectAndCorners( + childRect, + topRight: const Radius.circular(3.0), + bottomRight: const Radius.circular(3.0), + ); } else { rChildRect = RRect.fromRectAndCorners(childRect); } diff --git a/packages/flutter/lib/src/cupertino/text_field.dart b/packages/flutter/lib/src/cupertino/text_field.dart index b0f79c0142..63817c3148 100644 --- a/packages/flutter/lib/src/cupertino/text_field.dart +++ b/packages/flutter/lib/src/cupertino/text_field.dart @@ -328,10 +328,12 @@ class CupertinoTextField extends StatefulWidget { assert(prefixMode != null), assert(suffixMode != null), // Assert the following instead of setting it directly to avoid surprising the user by silently changing the value they set. - assert(!identical(textInputAction, TextInputAction.newline) || + assert( + !identical(textInputAction, TextInputAction.newline) || maxLines == 1 || !identical(keyboardType, TextInputType.text), - 'Use keyboardType TextInputType.multiline when using TextInputAction.newline on a multiline TextField.'), + 'Use keyboardType TextInputType.multiline when using TextInputAction.newline on a multiline TextField.', + ), keyboardType = keyboardType ?? (maxLines == 1 ? TextInputType.text : TextInputType.multiline), toolbarOptions = toolbarOptions ?? (obscureText ? const ToolbarOptions( @@ -479,10 +481,12 @@ class CupertinoTextField extends StatefulWidget { assert(prefixMode != null), assert(suffixMode != null), // Assert the following instead of setting it directly to avoid surprising the user by silently changing the value they set. - assert(!identical(textInputAction, TextInputAction.newline) || + assert( + !identical(textInputAction, TextInputAction.newline) || maxLines == 1 || !identical(keyboardType, TextInputType.text), - 'Use keyboardType TextInputType.multiline when using TextInputAction.newline on a multiline TextField.'), + 'Use keyboardType TextInputType.multiline when using TextInputAction.newline on a multiline TextField.', + ), keyboardType = keyboardType ?? (maxLines == 1 ? TextInputType.text : TextInputType.multiline), toolbarOptions = toolbarOptions ?? (obscureText ? const ToolbarOptions( diff --git a/packages/flutter/lib/src/cupertino/text_form_field_row.dart b/packages/flutter/lib/src/cupertino/text_form_field_row.dart index 32d0014c98..39d5e9dca5 100644 --- a/packages/flutter/lib/src/cupertino/text_form_field_row.dart +++ b/packages/flutter/lib/src/cupertino/text_form_field_row.dart @@ -203,8 +203,7 @@ class CupertinoTextFormFieldRow extends FormField { !expands || (maxLines == null && minLines == null), 'minLines and maxLines must be null when expands is true.', ), - assert(!obscureText || maxLines == 1, - 'Obscured fields cannot be multiline.'), + assert(!obscureText || maxLines == 1, 'Obscured fields cannot be multiline.'), assert(maxLength == null || maxLength > 0), assert(enableInteractiveSelection != null), super( diff --git a/packages/flutter/lib/src/gestures/drag_details.dart b/packages/flutter/lib/src/gestures/drag_details.dart index fd3554a69e..d41374ca25 100644 --- a/packages/flutter/lib/src/gestures/drag_details.dart +++ b/packages/flutter/lib/src/gestures/drag_details.dart @@ -140,9 +140,11 @@ class DragUpdateDetails { required this.globalPosition, Offset? localPosition, }) : assert(delta != null), - assert(primaryDelta == null + assert( + primaryDelta == null || (primaryDelta == delta.dx && delta.dy == 0.0) - || (primaryDelta == delta.dy && delta.dx == 0.0)), + || (primaryDelta == delta.dy && delta.dx == 0.0), + ), localPosition = localPosition ?? globalPosition; /// Recorded timestamp of the source pointer event that triggered the drag @@ -217,9 +219,11 @@ class DragEndDetails { this.velocity = Velocity.zero, this.primaryVelocity, }) : assert(velocity != null), - assert(primaryVelocity == null + assert( + primaryVelocity == null || primaryVelocity == velocity.pixelsPerSecond.dx - || primaryVelocity == velocity.pixelsPerSecond.dy); + || primaryVelocity == velocity.pixelsPerSecond.dy, + ); /// The velocity the pointer was moving when it stopped contacting the screen. /// diff --git a/packages/flutter/lib/src/gestures/long_press.dart b/packages/flutter/lib/src/gestures/long_press.dart index f408c0fda0..4e460c45a1 100644 --- a/packages/flutter/lib/src/gestures/long_press.dart +++ b/packages/flutter/lib/src/gestures/long_press.dart @@ -462,20 +462,17 @@ class LongPressGestureRecognizer extends PrimaryPointerGestureRecognizer { switch (_initialButtons) { case kPrimaryButton: if (onLongPressMoveUpdate != null) { - invokeCallback('onLongPressMoveUpdate', - () => onLongPressMoveUpdate!(details)); + invokeCallback('onLongPressMoveUpdate', () => onLongPressMoveUpdate!(details)); } break; case kSecondaryButton: if (onSecondaryLongPressMoveUpdate != null) { - invokeCallback('onSecondaryLongPressMoveUpdate', - () => onSecondaryLongPressMoveUpdate!(details)); + invokeCallback('onSecondaryLongPressMoveUpdate', () => onSecondaryLongPressMoveUpdate!(details)); } break; case kTertiaryButton: if (onTertiaryLongPressMoveUpdate != null) { - invokeCallback('onTertiaryLongPressMoveUpdate', - () => onTertiaryLongPressMoveUpdate!(details)); + invokeCallback('onTertiaryLongPressMoveUpdate', () => onTertiaryLongPressMoveUpdate!(details)); } break; default: diff --git a/packages/flutter/lib/src/material/calendar_date_picker.dart b/packages/flutter/lib/src/material/calendar_date_picker.dart index 75240f1335..5dcddd4483 100644 --- a/packages/flutter/lib/src/material/calendar_date_picker.dart +++ b/packages/flutter/lib/src/material/calendar_date_picker.dart @@ -1064,8 +1064,10 @@ class _DayPickerGridDelegate extends SliverGridDelegate { SliverGridLayout getLayout(SliverConstraints constraints) { const int columnCount = DateTime.daysPerWeek; final double tileWidth = constraints.crossAxisExtent / columnCount; - final double tileHeight = math.min(_dayPickerRowHeight, - constraints.viewportMainAxisExtent / (_maxDayPickerRowCount + 1)); + final double tileHeight = math.min( + _dayPickerRowHeight, + constraints.viewportMainAxisExtent / (_maxDayPickerRowCount + 1), + ); return SliverGridRegularTileLayout( childCrossAxisExtent: tileWidth, childMainAxisExtent: tileHeight, diff --git a/packages/flutter/lib/src/material/chip_theme.dart b/packages/flutter/lib/src/material/chip_theme.dart index 0887771f88..de4796fadf 100644 --- a/packages/flutter/lib/src/material/chip_theme.dart +++ b/packages/flutter/lib/src/material/chip_theme.dart @@ -229,10 +229,8 @@ class ChipThemeData with Diagnosticable { required Color secondaryColor, required TextStyle labelStyle, }) { - assert(primaryColor != null || brightness != null, - 'One of primaryColor or brightness must be specified'); - assert(primaryColor == null || brightness == null, - 'Only one of primaryColor or brightness may be specified'); + assert(primaryColor != null || brightness != null, 'One of primaryColor or brightness must be specified'); + assert(primaryColor == null || brightness == null, 'Only one of primaryColor or brightness may be specified'); assert(secondaryColor != null); assert(labelStyle != null); diff --git a/packages/flutter/lib/src/material/input_decorator.dart b/packages/flutter/lib/src/material/input_decorator.dart index 36fcaff43e..2c957d8006 100644 --- a/packages/flutter/lib/src/material/input_decorator.dart +++ b/packages/flutter/lib/src/material/input_decorator.dart @@ -977,26 +977,32 @@ class _RenderDecoration extends RenderBox { boxToBaseline[prefixIcon] = _layoutLineBox(prefixIcon, boxConstraints); boxToBaseline[suffixIcon] = _layoutLineBox(suffixIcon, boxConstraints); - final double inputWidth = math.max(0.0, constraints.maxWidth - ( - _boxSize(icon).width - + contentPadding.left - + _boxSize(prefixIcon).width - + _boxSize(prefix).width - + _boxSize(suffix).width - + _boxSize(suffixIcon).width - + contentPadding.right)); + final double inputWidth = math.max( + 0.0, + constraints.maxWidth - ( + _boxSize(icon).width + + contentPadding.left + + _boxSize(prefixIcon).width + + _boxSize(prefix).width + + _boxSize(suffix).width + + _boxSize(suffixIcon).width + + contentPadding.right), + ); // Increase the available width for the label when it is scaled down. final double invertedLabelScale = lerpDouble(1.00, 1 / _kFinalLabelScale, decoration.floatingLabelProgress)!; double suffixIconWidth = _boxSize(suffixIcon).width; if (decoration.border!.isOutline) { suffixIconWidth = lerpDouble(suffixIconWidth, 0.0, decoration.floatingLabelProgress)!; } - final double labelWidth = math.max(0.0, constraints.maxWidth - ( - _boxSize(icon).width - + contentPadding.left - + _boxSize(prefixIcon).width - + suffixIconWidth - + contentPadding.right)); + final double labelWidth = math.max( + 0.0, + constraints.maxWidth - ( + _boxSize(icon).width + + contentPadding.left + + _boxSize(prefixIcon).width + + suffixIconWidth + + contentPadding.right), + ); boxToBaseline[label] = _layoutLineBox( label, boxConstraints.copyWith(maxWidth: labelWidth * invertedLabelScale), @@ -1496,8 +1502,13 @@ class _RenderDecoration extends RenderBox { _labelTransform = Matrix4.identity() ..translate(dx, labelOffset.dy + dy) ..scale(scale); - _transformLayer = context.pushTransform(needsCompositing, offset, _labelTransform!, _paintLabel, - oldLayer: _transformLayer); + _transformLayer = context.pushTransform( + needsCompositing, + offset, + _labelTransform!, + _paintLabel, + oldLayer: _transformLayer, + ); } else { _transformLayer = null; } @@ -2578,8 +2589,10 @@ class InputDecoration { this.border = InputBorder.none, this.enabled = true, }) : assert(enabled != null), - assert(!(!hasFloatingPlaceholder && identical(floatingLabelBehavior, FloatingLabelBehavior.always)), - 'hasFloatingPlaceholder=false conflicts with FloatingLabelBehavior.always'), + assert( + !(!hasFloatingPlaceholder && identical(floatingLabelBehavior, FloatingLabelBehavior.always)), + 'hasFloatingPlaceholder=false conflicts with FloatingLabelBehavior.always', + ), icon = null, labelText = null, labelStyle = null, @@ -3642,8 +3655,10 @@ class InputDecorationTheme with Diagnosticable { assert(isCollapsed != null), assert(filled != null), assert(alignLabelWithHint != null), - assert(!(!hasFloatingPlaceholder && identical(floatingLabelBehavior, FloatingLabelBehavior.always)), - 'hasFloatingPlaceholder=false conflicts with FloatingLabelBehavior.always'); + assert( + !(!hasFloatingPlaceholder && identical(floatingLabelBehavior, FloatingLabelBehavior.always)), + 'hasFloatingPlaceholder=false conflicts with FloatingLabelBehavior.always', + ); /// The style to use for [InputDecoration.labelText] when the label is /// above (i.e., vertically adjacent to) the input field. diff --git a/packages/flutter/lib/src/material/popup_menu.dart b/packages/flutter/lib/src/material/popup_menu.dart index 493592f5a1..cf7feb6ba9 100644 --- a/packages/flutter/lib/src/material/popup_menu.dart +++ b/packages/flutter/lib/src/material/popup_menu.dart @@ -988,8 +988,10 @@ class PopupMenuButton extends StatefulWidget { }) : assert(itemBuilder != null), assert(offset != null), assert(enabled != null), - assert(!(child != null && icon != null), - 'You can only pass [child] or [icon], not both.'), + assert( + !(child != null && icon != null), + 'You can only pass [child] or [icon], not both.', + ), super(key: key); /// Called when the button is pressed to create the items to show in the menu. diff --git a/packages/flutter/lib/src/material/scaffold.dart b/packages/flutter/lib/src/material/scaffold.dart index 9b14cadde2..e229694e08 100644 --- a/packages/flutter/lib/src/material/scaffold.dart +++ b/packages/flutter/lib/src/material/scaffold.dart @@ -457,8 +457,10 @@ class ScaffoldMessengerState extends State with TickerProvide if (_snackBarController!.isCompleted && _snackBarTimer == null) { final SnackBar snackBar = _snackBars.first._widget; _snackBarTimer = Timer(snackBar.duration, () { - assert(_snackBarController!.status == AnimationStatus.forward || - _snackBarController!.status == AnimationStatus.completed); + assert( + _snackBarController!.status == AnimationStatus.forward || + _snackBarController!.status == AnimationStatus.completed, + ); // Look up MediaQuery again in case the setting changed. final MediaQueryData mediaQuery = MediaQuery.of(context); if (mediaQuery.accessibleNavigation && snackBar.action != null) @@ -2984,8 +2986,10 @@ class ScaffoldState extends State with TickerProviderStateMixin, Resto if (_snackBarController!.isCompleted && _snackBarTimer == null) { final SnackBar snackBar = _snackBars.first._widget; _snackBarTimer = Timer(snackBar.duration, () { - assert(_snackBarController!.status == AnimationStatus.forward || - _snackBarController!.status == AnimationStatus.completed); + assert( + _snackBarController!.status == AnimationStatus.forward || + _snackBarController!.status == AnimationStatus.completed, + ); // Look up MediaQuery again in case the setting changed. final MediaQueryData mediaQuery = MediaQuery.of(context); if (mediaQuery.accessibleNavigation && snackBar.action != null) @@ -3374,8 +3378,10 @@ class _StandardBottomSheetState extends State<_StandardBottomSheet> { void initState() { super.initState(); assert(widget.animationController != null); - assert(widget.animationController.status == AnimationStatus.forward - || widget.animationController.status == AnimationStatus.completed); + assert( + widget.animationController.status == AnimationStatus.forward + || widget.animationController.status == AnimationStatus.completed, + ); widget.animationController.addStatusListener(_handleStatusChange); } diff --git a/packages/flutter/lib/src/material/text_field.dart b/packages/flutter/lib/src/material/text_field.dart index fe263299da..cffef721dd 100644 --- a/packages/flutter/lib/src/material/text_field.dart +++ b/packages/flutter/lib/src/material/text_field.dart @@ -423,10 +423,12 @@ class TextField extends StatefulWidget { assert(!obscureText || maxLines == 1, 'Obscured fields cannot be multiline.'), assert(maxLength == null || maxLength == TextField.noMaxLength || maxLength > 0), // Assert the following instead of setting it directly to avoid surprising the user by silently changing the value they set. - assert(!identical(textInputAction, TextInputAction.newline) || + assert( + !identical(textInputAction, TextInputAction.newline) || maxLines == 1 || !identical(keyboardType, TextInputType.text), - 'Use keyboardType TextInputType.multiline when using TextInputAction.newline on a multiline TextField.'), + 'Use keyboardType TextInputType.multiline when using TextInputAction.newline on a multiline TextField.', + ), keyboardType = keyboardType ?? (maxLines == 1 ? TextInputType.text : TextInputType.multiline), toolbarOptions = toolbarOptions ?? (obscureText ? const ToolbarOptions( diff --git a/packages/flutter/lib/src/painting/box_decoration.dart b/packages/flutter/lib/src/painting/box_decoration.dart index 60d6f70a00..246d34d797 100644 --- a/packages/flutter/lib/src/painting/box_decoration.dart +++ b/packages/flutter/lib/src/painting/box_decoration.dart @@ -128,8 +128,7 @@ class BoxDecoration extends Decoration { @override bool debugAssertIsValid() { - assert(shape != BoxShape.circle || - borderRadius == null); // Can't have a border radius if you're a circle. + assert(shape != BoxShape.circle || borderRadius == null); // Can't have a border radius if you're a circle. return super.debugAssertIsValid(); } diff --git a/packages/flutter/lib/src/painting/box_fit.dart b/packages/flutter/lib/src/painting/box_fit.dart index 1482e218ab..b2abccdcd3 100644 --- a/packages/flutter/lib/src/painting/box_fit.dart +++ b/packages/flutter/lib/src/painting/box_fit.dart @@ -173,8 +173,7 @@ FittedSizes applyBoxFit(BoxFit fit, Size inputSize, Size outputSize) { destinationSize = Size(sourceSize.width * outputSize.height / sourceSize.height, outputSize.height); break; case BoxFit.none: - sourceSize = Size(math.min(inputSize.width, outputSize.width), - math.min(inputSize.height, outputSize.height)); + sourceSize = Size(math.min(inputSize.width, outputSize.width), math.min(inputSize.height, outputSize.height)); destinationSize = sourceSize; break; case BoxFit.scaleDown: diff --git a/packages/flutter/lib/src/painting/flutter_logo.dart b/packages/flutter/lib/src/painting/flutter_logo.dart index 0daf6a49e2..ba53958908 100644 --- a/packages/flutter/lib/src/painting/flutter_logo.dart +++ b/packages/flutter/lib/src/painting/flutter_logo.dart @@ -79,14 +79,16 @@ class FlutterLogoDecoration extends Decoration { @override bool debugAssertIsValid() { - assert(textColor != null + assert( + textColor != null && style != null && margin != null && _position != null && _position.isFinite && _opacity != null && _opacity >= 0.0 - && _opacity <= 1.0); + && _opacity <= 1.0, + ); return true; } diff --git a/packages/flutter/lib/src/painting/image_resolution.dart b/packages/flutter/lib/src/painting/image_resolution.dart index bb81c103ae..1a9b225ded 100644 --- a/packages/flutter/lib/src/painting/image_resolution.dart +++ b/packages/flutter/lib/src/painting/image_resolution.dart @@ -261,9 +261,9 @@ class AssetImage extends AssetBundleImageProvider { // TODO(ianh): JSON decoding really shouldn't be on the main thread. final Map parsedJson = json.decode(jsonData) as Map; final Iterable keys = parsedJson.keys; - final Map> parsedManifest = - Map>.fromIterables(keys, - keys.map>((String key) => List.from(parsedJson[key] as List))); + final Map> parsedManifest = > { + for (final String key in keys) key: List.from(parsedJson[key] as List), + }; // TODO(ianh): convert that data structure to the right types. return SynchronousFuture>?>(parsedManifest); } diff --git a/packages/flutter/lib/src/physics/spring_simulation.dart b/packages/flutter/lib/src/physics/spring_simulation.dart index 7d26609ef7..5639ba5f65 100644 --- a/packages/flutter/lib/src/physics/spring_simulation.dart +++ b/packages/flutter/lib/src/physics/spring_simulation.dart @@ -250,8 +250,8 @@ class _UnderdampedSolution implements _SpringSolution { double distance, double velocity, ) { - final double w = math.sqrt(4.0 * spring.mass * spring.stiffness - - spring.damping * spring.damping) / (2.0 * spring.mass); + final double w = math.sqrt(4.0 * spring.mass * spring.stiffness - spring.damping * spring.damping) / + (2.0 * spring.mass); final double r = -(spring.damping / 2.0 * spring.mass); final double c1 = distance; final double c2 = (velocity - r * distance) / w; diff --git a/packages/flutter/lib/src/rendering/animated_size.dart b/packages/flutter/lib/src/rendering/animated_size.dart index acb538e195..acd6852a01 100644 --- a/packages/flutter/lib/src/rendering/animated_size.dart +++ b/packages/flutter/lib/src/rendering/animated_size.dart @@ -327,8 +327,14 @@ class RenderAnimatedSize extends RenderAligningShiftedBox { void paint(PaintingContext context, Offset offset) { if (child != null && _hasVisualOverflow && clipBehavior != Clip.none) { final Rect rect = Offset.zero & size; - _clipRectLayer = context.pushClipRect(needsCompositing, offset, rect, super.paint, - clipBehavior: clipBehavior, oldLayer: _clipRectLayer); + _clipRectLayer = context.pushClipRect( + needsCompositing, + offset, + rect, + super.paint, + clipBehavior: clipBehavior, + oldLayer: _clipRectLayer, + ); } else { _clipRectLayer = null; super.paint(context, offset); diff --git a/packages/flutter/lib/src/rendering/binding.dart b/packages/flutter/lib/src/rendering/binding.dart index a686e2514a..690ca66948 100644 --- a/packages/flutter/lib/src/rendering/binding.dart +++ b/packages/flutter/lib/src/rendering/binding.dart @@ -282,8 +282,7 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture event is PointerAddedEvent || event is PointerRemovedEvent) { assert(event.position != null); - _mouseTracker!.updateWithEvent(event, - () => hitTestResult ?? renderView.hitTestMouseTrackers(event.position)); + _mouseTracker!.updateWithEvent(event, () => hitTestResult ?? renderView.hitTestMouseTrackers(event.position)); } super.dispatchEvent(event, hitTestResult); } diff --git a/packages/flutter/lib/src/rendering/box.dart b/packages/flutter/lib/src/rendering/box.dart index 4ec511c01a..b5c06de0cd 100644 --- a/packages/flutter/lib/src/rendering/box.dart +++ b/packages/flutter/lib/src/rendering/box.dart @@ -865,10 +865,12 @@ class BoxHitTestResult extends HitTestResult { required BoxHitTestWithOutOfBandPosition hitTest, }) { assert(hitTest != null); - assert((paintOffset == null && paintTransform == null && rawTransform != null) || - (paintOffset == null && paintTransform != null && rawTransform == null) || - (paintOffset != null && paintTransform == null && rawTransform == null), - 'Exactly one transform or offset argument must be provided.'); + assert( + (paintOffset == null && paintTransform == null && rawTransform != null) || + (paintOffset == null && paintTransform != null && rawTransform == null) || + (paintOffset != null && paintTransform == null && rawTransform == null), + 'Exactly one transform or offset argument must be provided.', + ); if (paintOffset != null) { pushOffset(-paintOffset); } else if (rawTransform != null) { diff --git a/packages/flutter/lib/src/rendering/debug_overflow_indicator.dart b/packages/flutter/lib/src/rendering/debug_overflow_indicator.dart index ce232380f8..1ba09530d1 100644 --- a/packages/flutter/lib/src/rendering/debug_overflow_indicator.dart +++ b/packages/flutter/lib/src/rendering/debug_overflow_indicator.dart @@ -224,8 +224,7 @@ mixin DebugOverflowIndicatorMixin on RenderObject { if (overflow.right > 0.0) '${_formatPixels(overflow.right)} pixels on the right', ]; String overflowText = ''; - assert(overflows.isNotEmpty, - "Somehow $runtimeType didn't actually overflow like it thought it did."); + assert(overflows.isNotEmpty, "Somehow $runtimeType didn't actually overflow like it thought it did."); switch (overflows.length) { case 1: overflowText = overflows.first; diff --git a/packages/flutter/lib/src/rendering/editable.dart b/packages/flutter/lib/src/rendering/editable.dart index 8d4f26de5d..0b4abc8742 100644 --- a/packages/flutter/lib/src/rendering/editable.dart +++ b/packages/flutter/lib/src/rendering/editable.dart @@ -1399,9 +1399,11 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin { return _extendSelectionToStart(cause); } - assert(_textLayoutLastMaxWidth == constraints.maxWidth && - _textLayoutLastMinWidth == constraints.minWidth, - 'Last width ($_textLayoutLastMinWidth, $_textLayoutLastMaxWidth) not the same as max width constraint (${constraints.minWidth}, ${constraints.maxWidth}).'); + assert( + _textLayoutLastMaxWidth == constraints.maxWidth && + _textLayoutLastMinWidth == constraints.minWidth, + 'Last width ($_textLayoutLastMinWidth, $_textLayoutLastMaxWidth) not the same as max width constraint (${constraints.minWidth}, ${constraints.maxWidth}).', + ); final TextSelection nextSelection = _extendGivenSelectionLeftByWord( _textPainter, selection!, @@ -1437,9 +1439,11 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin { return _extendSelectionToEnd(cause); } - assert(_textLayoutLastMaxWidth == constraints.maxWidth && - _textLayoutLastMinWidth == constraints.minWidth, - 'Last width ($_textLayoutLastMinWidth, $_textLayoutLastMaxWidth) not the same as max width constraint (${constraints.minWidth}, ${constraints.maxWidth}).'); + assert( + _textLayoutLastMaxWidth == constraints.maxWidth && + _textLayoutLastMinWidth == constraints.minWidth, + 'Last width ($_textLayoutLastMinWidth, $_textLayoutLastMaxWidth) not the same as max width constraint (${constraints.minWidth}, ${constraints.maxWidth}).', + ); final TextSelection nextSelection = _extendGivenSelectionRightByWord( _textPainter, selection!, @@ -1597,9 +1601,11 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin { return moveSelectionToStart(cause); } - assert(_textLayoutLastMaxWidth == constraints.maxWidth && - _textLayoutLastMinWidth == constraints.minWidth, - 'Last width ($_textLayoutLastMinWidth, $_textLayoutLastMaxWidth) not the same as max width constraint (${constraints.minWidth}, ${constraints.maxWidth}).'); + assert( + _textLayoutLastMaxWidth == constraints.maxWidth && + _textLayoutLastMinWidth == constraints.minWidth, + 'Last width ($_textLayoutLastMinWidth, $_textLayoutLastMaxWidth) not the same as max width constraint (${constraints.minWidth}, ${constraints.maxWidth}).', + ); final TextSelection nextSelection = _moveGivenSelectionLeftByWord( _textPainter, selection!, @@ -1683,9 +1689,11 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin { return moveSelectionToEnd(cause); } - assert(_textLayoutLastMaxWidth == constraints.maxWidth && - _textLayoutLastMinWidth == constraints.minWidth, - 'Last width ($_textLayoutLastMinWidth, $_textLayoutLastMaxWidth) not the same as max width constraint (${constraints.minWidth}, ${constraints.maxWidth}).'); + assert( + _textLayoutLastMaxWidth == constraints.maxWidth && + _textLayoutLastMinWidth == constraints.minWidth, + 'Last width ($_textLayoutLastMinWidth, $_textLayoutLastMaxWidth) not the same as max width constraint (${constraints.minWidth}, ${constraints.maxWidth}).', + ); final TextSelection nextSelection = _moveGivenSelectionRightByWord( _textPainter, selection!, @@ -3032,9 +3040,11 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin { } TextSelection _getWordAtOffset(TextPosition position) { - assert(_textLayoutLastMaxWidth == constraints.maxWidth && - _textLayoutLastMinWidth == constraints.minWidth, - 'Last width ($_textLayoutLastMinWidth, $_textLayoutLastMaxWidth) not the same as max width constraint (${constraints.minWidth}, ${constraints.maxWidth}).'); + assert( + _textLayoutLastMaxWidth == constraints.maxWidth && + _textLayoutLastMinWidth == constraints.minWidth, + 'Last width ($_textLayoutLastMinWidth, $_textLayoutLastMaxWidth) not the same as max width constraint (${constraints.minWidth}, ${constraints.maxWidth}).', + ); final TextRange word = _textPainter.getWordBoundary(position); // When long-pressing past the end of the text, we want a collapsed cursor. if (position.offset >= word.end) @@ -3095,9 +3105,11 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin { } TextSelection _getLineAtOffset(TextPosition position) { - assert(_textLayoutLastMaxWidth == constraints.maxWidth && - _textLayoutLastMinWidth == constraints.minWidth, - 'Last width ($_textLayoutLastMinWidth, $_textLayoutLastMaxWidth) not the same as max width constraint (${constraints.minWidth}, ${constraints.maxWidth}).'); + assert( + _textLayoutLastMaxWidth == constraints.maxWidth && + _textLayoutLastMinWidth == constraints.minWidth, + 'Last width ($_textLayoutLastMinWidth, $_textLayoutLastMaxWidth) not the same as max width constraint (${constraints.minWidth}, ${constraints.maxWidth}).', + ); final TextRange line = _textPainter.getLineBoundary(position); if (position.offset >= line.end) return TextSelection.fromPosition(position); @@ -3294,9 +3306,11 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin { } void _paintContents(PaintingContext context, Offset offset) { - assert(_textLayoutLastMaxWidth == constraints.maxWidth && - _textLayoutLastMinWidth == constraints.minWidth, - 'Last width ($_textLayoutLastMinWidth, $_textLayoutLastMaxWidth) not the same as max width constraint (${constraints.minWidth}, ${constraints.maxWidth}).'); + assert( + _textLayoutLastMaxWidth == constraints.maxWidth && + _textLayoutLastMinWidth == constraints.minWidth, + 'Last width ($_textLayoutLastMinWidth, $_textLayoutLastMaxWidth) not the same as max width constraint (${constraints.minWidth}, ${constraints.maxWidth}).', + ); final Offset effectiveOffset = offset + _paintOffset; if (selection != null && !_floatingCursorOn) { @@ -3346,8 +3360,14 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin { void paint(PaintingContext context, Offset offset) { _layoutText(minWidth: constraints.minWidth, maxWidth: constraints.maxWidth); if (_hasVisualOverflow && clipBehavior != Clip.none) { - _clipRectLayer = context.pushClipRect(needsCompositing, offset, Offset.zero & size, _paintContents, - clipBehavior: clipBehavior, oldLayer: _clipRectLayer); + _clipRectLayer = context.pushClipRect( + needsCompositing, + offset, + Offset.zero & size, + _paintContents, + clipBehavior: clipBehavior, + oldLayer: _clipRectLayer, + ); } else { _clipRectLayer = null; _paintContents(context, offset); diff --git a/packages/flutter/lib/src/rendering/flex.dart b/packages/flutter/lib/src/rendering/flex.dart index 1b3c0f9ce1..3bed45da9a 100644 --- a/packages/flutter/lib/src/rendering/flex.dart +++ b/packages/flutter/lib/src/rendering/flex.dart @@ -583,8 +583,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin _processConflictingPhysicalLayers(PhysicalModelLayer predecessor, PhysicalModelLayer child) { FlutterError.reportError(FlutterErrorDetails( - exception: FlutterError('Painting order is out of order with respect to elevation.\n' - 'See https://api.flutter.dev/flutter/rendering/debugCheckElevationsEnabled.html ' - 'for more details.'), + exception: FlutterError( + 'Painting order is out of order with respect to elevation.\n' + 'See https://api.flutter.dev/flutter/rendering/debugCheckElevationsEnabled.html ' + 'for more details.', + ), library: 'rendering library', context: ErrorDescription('during compositing'), informationCollector: () { diff --git a/packages/flutter/lib/src/rendering/list_wheel_viewport.dart b/packages/flutter/lib/src/rendering/list_wheel_viewport.dart index 32a8ae13e1..22e164df5c 100644 --- a/packages/flutter/lib/src/rendering/list_wheel_viewport.dart +++ b/packages/flutter/lib/src/rendering/list_wheel_viewport.dart @@ -989,11 +989,15 @@ class RenderListWheelViewport Matrix4 _centerOriginTransform(Matrix4 originalMatrix) { final Matrix4 result = Matrix4.identity(); final Offset centerOriginTranslation = Alignment.center.alongSize(size); - result.translate(centerOriginTranslation.dx * (-_offAxisFraction * 2 + 1), - centerOriginTranslation.dy); + result.translate( + centerOriginTranslation.dx * (-_offAxisFraction * 2 + 1), + centerOriginTranslation.dy, + ); result.multiply(originalMatrix); - result.translate(-centerOriginTranslation.dx * (-_offAxisFraction * 2 + 1), - -centerOriginTranslation.dy); + result.translate( + -centerOriginTranslation.dx * (-_offAxisFraction * 2 + 1), + -centerOriginTranslation.dy, + ); return result; } diff --git a/packages/flutter/lib/src/rendering/paragraph.dart b/packages/flutter/lib/src/rendering/paragraph.dart index c678568e1c..afc2c22420 100644 --- a/packages/flutter/lib/src/rendering/paragraph.dart +++ b/packages/flutter/lib/src/rendering/paragraph.dart @@ -373,9 +373,11 @@ class RenderParagraph extends RenderBox case ui.PlaceholderAlignment.baseline: case ui.PlaceholderAlignment.aboveBaseline: case ui.PlaceholderAlignment.belowBaseline: { - assert(RenderObject.debugCheckingIntrinsics, + assert( + RenderObject.debugCheckingIntrinsics, 'Intrinsics are not available for PlaceholderAlignment.baseline, ' - 'PlaceholderAlignment.aboveBaseline, or PlaceholderAlignment.belowBaseline.'); + 'PlaceholderAlignment.aboveBaseline, or PlaceholderAlignment.belowBaseline.', + ); return false; } case ui.PlaceholderAlignment.top: diff --git a/packages/flutter/lib/src/rendering/platform_view.dart b/packages/flutter/lib/src/rendering/platform_view.dart index 62013c9195..a0b0ab3bb6 100644 --- a/packages/flutter/lib/src/rendering/platform_view.dart +++ b/packages/flutter/lib/src/rendering/platform_view.dart @@ -209,8 +209,14 @@ class RenderAndroidView extends RenderBox with _PlatformViewGestureMixin { // Clip the texture if it's going to paint out of the bounds of the renter box // (see comment in _paintTexture for an explanation of when this happens). if ((size.width < _currentAndroidViewSize.width || size.height < _currentAndroidViewSize.height) && clipBehavior != Clip.none) { - _clipRectLayer = context.pushClipRect(true, offset, offset & size, _paintTexture, clipBehavior: clipBehavior, - oldLayer: _clipRectLayer); + _clipRectLayer = context.pushClipRect( + true, + offset, + offset & size, + _paintTexture, + clipBehavior: clipBehavior, + oldLayer: _clipRectLayer, + ); return; } _clipRectLayer = null; diff --git a/packages/flutter/lib/src/rendering/proxy_box.dart b/packages/flutter/lib/src/rendering/proxy_box.dart index 5b96e48bc9..a9519a74cf 100644 --- a/packages/flutter/lib/src/rendering/proxy_box.dart +++ b/packages/flutter/lib/src/rendering/proxy_box.dart @@ -1600,8 +1600,10 @@ class RenderClipOval extends _RenderCustomClip { assert(_clip != null); final Offset center = _clip!.center; // convert the position to an offset from the center of the unit circle - final Offset offset = Offset((position.dx - center.dx) / _clip!.width, - (position.dy - center.dy) / _clip!.height); + final Offset offset = Offset( + (position.dx - center.dx) / _clip!.width, + (position.dy - center.dy) / _clip!.height, + ); // check if the point is outside the unit circle if (offset.distanceSquared > 0.25) // x^2 + y^2 > r^2 return false; @@ -2582,8 +2584,13 @@ class RenderFittedBox extends RenderProxyBox { TransformLayer? _paintChildWithTransform(PaintingContext context, Offset offset) { final Offset? childOffset = MatrixUtils.getAsTranslation(_transform!); if (childOffset == null) - return context.pushTransform(needsCompositing, offset, _transform!, super.paint, - oldLayer: layer is TransformLayer ? layer! as TransformLayer : null); + return context.pushTransform( + needsCompositing, + offset, + _transform!, + super.paint, + oldLayer: layer is TransformLayer ? layer! as TransformLayer : null, + ); else super.paint(context, offset + childOffset); return null; @@ -2596,8 +2603,14 @@ class RenderFittedBox extends RenderProxyBox { _updatePaintData(); if (child != null) { if (_hasVisualOverflow! && clipBehavior != Clip.none) - layer = context.pushClipRect(needsCompositing, offset, Offset.zero & size, _paintChildWithTransform, - oldLayer: layer is ClipRectLayer ? layer! as ClipRectLayer : null, clipBehavior: clipBehavior); + layer = context.pushClipRect( + needsCompositing, + offset, + Offset.zero & size, + _paintChildWithTransform, + oldLayer: layer is ClipRectLayer ? layer! as ClipRectLayer : null, + clipBehavior: clipBehavior, + ); else layer = _paintChildWithTransform(context, offset); } @@ -4655,10 +4668,14 @@ class RenderSemanticsAnnotations extends RenderProxyBox { super.describeSemanticsConfiguration(config); config.isSemanticBoundary = container; config.explicitChildNodes = explicitChildNodes; - assert((scopesRoute == true && explicitChildNodes == true) || scopesRoute != true, - 'explicitChildNodes must be set to true if scopes route is true'); - assert(!(toggled == true && checked == true), - 'A semantics node cannot be toggled and checked at the same time'); + assert( + (scopesRoute == true && explicitChildNodes == true) || scopesRoute != true, + 'explicitChildNodes must be set to true if scopes route is true', + ); + assert( + !(toggled == true && checked == true), + 'A semantics node cannot be toggled and checked at the same time', + ); if (enabled != null) config.isEnabled = enabled; diff --git a/packages/flutter/lib/src/rendering/rotated_box.dart b/packages/flutter/lib/src/rendering/rotated_box.dart index 1a344ef0a7..ca53ae3efc 100644 --- a/packages/flutter/lib/src/rendering/rotated_box.dart +++ b/packages/flutter/lib/src/rendering/rotated_box.dart @@ -117,8 +117,13 @@ class RenderRotatedBox extends RenderBox with RenderObjectWithChildMixin setLayoutDirection(TextDirection layoutDirection) async { - assert(_state != _AndroidViewState.disposed, - 'trying to set a layout direction for a disposed UIView. View id: $viewId'); + assert( + _state != _AndroidViewState.disposed, + 'trying to set a layout direction for a disposed UIView. View id: $viewId', + ); if (layoutDirection == _layoutDirection) return; @@ -994,8 +996,7 @@ class TextureAndroidViewController extends AndroidViewController { @override Future setSize(Size size) async { - assert(_state != _AndroidViewState.disposed, - 'trying to size a disposed Android View. View id: $viewId'); + assert(_state != _AndroidViewState.disposed, 'trying to size a disposed Android View. View id: $viewId'); assert(size != null); assert(!size.isEmpty); diff --git a/packages/flutter/lib/src/services/raw_keyboard.dart b/packages/flutter/lib/src/services/raw_keyboard.dart index 62ace289db..fad652b70e 100644 --- a/packages/flutter/lib/src/services/raw_keyboard.dart +++ b/packages/flutter/lib/src/services/raw_keyboard.dart @@ -172,10 +172,12 @@ abstract class RawKeyEventData { } assert((){ if (side == null) { - debugPrint('Raw key data is returning inconsistent information for ' - 'pressed modifiers. isModifierPressed returns true for $key ' - 'being pressed, but when getModifierSide is called, it says ' - 'that no modifiers are pressed.'); + debugPrint( + 'Raw key data is returning inconsistent information for ' + 'pressed modifiers. isModifierPressed returns true for $key ' + 'being pressed, but when getModifierSide is called, it says ' + 'that no modifiers are pressed.', + ); if (this is RawKeyEventDataAndroid) { debugPrint('Android raw key metaState: ${(this as RawKeyEventDataAndroid).metaState}'); } @@ -660,11 +662,13 @@ class RawKeyboard { // Make sure that the modifiers reflect reality, in case a modifier key was // pressed/released while the app didn't have focus. _synchronizeModifiers(event); - assert(event is! RawKeyDownEvent || _keysPressed.isNotEmpty, - 'Attempted to send a key down event when no keys are in keysPressed. ' - "This state can occur if the key event being sent doesn't properly " - 'set its modifier flags. This was the event: $event and its data: ' - '${event.data}'); + assert( + event is! RawKeyDownEvent || _keysPressed.isNotEmpty, + 'Attempted to send a key down event when no keys are in keysPressed. ' + "This state can occur if the key event being sent doesn't properly " + 'set its modifier flags. This was the event: $event and its data: ' + '${event.data}', + ); // Send the event to passive listeners. for (final ValueChanged listener in List>.from(_listeners)) { if (_listeners.contains(listener)) { @@ -742,9 +746,11 @@ class RawKeyboard { final Set? mappedKeys = _modifierKeyMap[_ModifierSidePair(key, modifiersPressed[key])]; assert((){ if (mappedKeys == null) { - debugPrint('Platform key support for ${Platform.operatingSystem} is ' - 'producing unsupported modifier combinations for ' - 'modifier $key on side ${modifiersPressed[key]}.'); + debugPrint( + 'Platform key support for ${Platform.operatingSystem} is ' + 'producing unsupported modifier combinations for ' + 'modifier $key on side ${modifiersPressed[key]}.', + ); if (event.data is RawKeyEventDataAndroid) { debugPrint('Android raw key metaState: ${(event.data as RawKeyEventDataAndroid).metaState}'); } diff --git a/packages/flutter/lib/src/widgets/actions.dart b/packages/flutter/lib/src/widgets/actions.dart index e087bafa48..d9d01b8782 100644 --- a/packages/flutter/lib/src/widgets/actions.dart +++ b/packages/flutter/lib/src/widgets/actions.dart @@ -814,14 +814,16 @@ class Actions extends StatefulWidget { assert(() { if (action == null) { final Type type = intent?.runtimeType ?? T; - throw FlutterError('Unable to find an action for a $type in an $Actions widget ' - 'in the given context.\n' - "$Actions.find() was called on a context that doesn't contain an " - '$Actions widget with a mapping for the given intent type.\n' - 'The context used was:\n' - ' $context\n' - 'The intent type requested was:\n' - ' $type'); + throw FlutterError( + 'Unable to find an action for a $type in an $Actions widget ' + 'in the given context.\n' + "$Actions.find() was called on a context that doesn't contain an " + '$Actions widget with a mapping for the given intent type.\n' + 'The context used was:\n' + ' $context\n' + 'The intent type requested was:\n' + ' $type', + ); } return true; }()); @@ -925,16 +927,18 @@ class Actions extends StatefulWidget { assert(() { if (actionElement == null) { - throw FlutterError('Unable to find an action for an Intent with type ' - '${intent.runtimeType} in an $Actions widget in the given context.\n' - '$Actions.invoke() was unable to find an $Actions widget that ' - "contained a mapping for the given intent, or the intent type isn't the " - 'same as the type argument to invoke (which is $T - try supplying a ' - 'type argument to invoke if one was not given)\n' - 'The context used was:\n' - ' $context\n' - 'The intent type requested was:\n' - ' ${intent.runtimeType}'); + throw FlutterError( + 'Unable to find an action for an Intent with type ' + '${intent.runtimeType} in an $Actions widget in the given context.\n' + '$Actions.invoke() was unable to find an $Actions widget that ' + "contained a mapping for the given intent, or the intent type isn't the " + 'same as the type argument to invoke (which is $T - try supplying a ' + 'type argument to invoke if one was not given)\n' + 'The context used was:\n' + ' $context\n' + 'The intent type requested was:\n' + ' ${intent.runtimeType}', + ); } return true; }()); diff --git a/packages/flutter/lib/src/widgets/app.dart b/packages/flutter/lib/src/widgets/app.dart index 34bd001b87..10f7ab878f 100644 --- a/packages/flutter/lib/src/widgets/app.dart +++ b/packages/flutter/lib/src/widgets/app.dart @@ -1205,15 +1205,16 @@ class _WidgetsAppState extends State with WidgetsBindingObserver { : widget.routes![name]; if (pageContentBuilder != null) { - assert(widget.pageRouteBuilder != null, + assert( + widget.pageRouteBuilder != null, 'The default onGenerateRoute handler for WidgetsApp must have a ' - 'pageRouteBuilder set if the home or routes properties are set.'); + 'pageRouteBuilder set if the home or routes properties are set.', + ); final Route route = widget.pageRouteBuilder!( settings, pageContentBuilder, ); - assert(route != null, - 'The pageRouteBuilder for WidgetsApp must return a valid non-null Route.'); + assert(route != null, 'The pageRouteBuilder for WidgetsApp must return a valid non-null Route.'); return route; } if (widget.onGenerateRoute != null) diff --git a/packages/flutter/lib/src/widgets/focus_manager.dart b/packages/flutter/lib/src/widgets/focus_manager.dart index 1fd7de6279..6879a57f19 100644 --- a/packages/flutter/lib/src/widgets/focus_manager.dart +++ b/packages/flutter/lib/src/widgets/focus_manager.dart @@ -1676,8 +1676,10 @@ class FocusManager with DiagnosticableTreeMixin, ChangeNotifier { if (node.onKey != null) { // TODO(gspencergoog): Convert this from dynamic to KeyEventResult once migration is complete. final dynamic result = node.onKey!(node, event); - assert(result is bool || result is KeyEventResult, - 'Value returned from onKey handler must be a non-null bool or KeyEventResult, not ${result.runtimeType}'); + assert( + result is bool || result is KeyEventResult, + 'Value returned from onKey handler must be a non-null bool or KeyEventResult, not ${result.runtimeType}', + ); if (result is KeyEventResult) { switch (result) { case KeyEventResult.handled: diff --git a/packages/flutter/lib/src/widgets/framework.dart b/packages/flutter/lib/src/widgets/framework.dart index d382a20f84..f18d0a58e3 100644 --- a/packages/flutter/lib/src/widgets/framework.dart +++ b/packages/flutter/lib/src/widgets/framework.dart @@ -3435,12 +3435,14 @@ abstract class Element extends DiagnosticableTree implements BuildContext { void update(covariant Widget newWidget) { // This code is hot when hot reloading, so we try to // only call _AssertionError._evaluateAssertion once. - assert(_lifecycleState == _ElementLifecycle.active + assert( + _lifecycleState == _ElementLifecycle.active && widget != null && newWidget != null && newWidget != widget && depth != null - && Widget.canUpdate(widget, newWidget)); + && Widget.canUpdate(widget, newWidget), + ); // This Element was told to update and we can now release all the global key // reservations of forgotten children. We cannot do this earlier because the // forgotten children still represent global key duplications if the element @@ -5694,17 +5696,21 @@ abstract class RenderObjectElement extends Element { @override void deactivate() { super.deactivate(); - assert(!renderObject.attached, + assert( + !renderObject.attached, 'A RenderObject was still attached when attempting to deactivate its ' - 'RenderObjectElement: $renderObject'); + 'RenderObjectElement: $renderObject', + ); } @override void unmount() { super.unmount(); - assert(!renderObject.attached, + assert( + !renderObject.attached, 'A RenderObject was still attached when attempting to unmount its ' - 'RenderObjectElement: $renderObject'); + 'RenderObjectElement: $renderObject', + ); widget.didUnmountRenderObject(renderObject); } @@ -5798,15 +5804,19 @@ abstract class RenderObjectElement extends Element { name: 'insertChildRenderObject() was called on this Element', style: DiagnosticsTreeStyle.shallow, ), - ErrorDescription('insertChildRenderObject() has been deprecated in favor of ' + ErrorDescription( + 'insertChildRenderObject() has been deprecated in favor of ' 'insertRenderObjectChild(). See https://github.com/flutter/flutter/issues/63269 ' - 'for details.'), - ErrorHint('Rather than overriding insertChildRenderObject() in your ' + 'for details.', + ), + ErrorHint( + 'Rather than overriding insertChildRenderObject() in your ' 'RenderObjectElement subclass, override insertRenderObjectChild() instead, ' "and DON'T call super.insertRenderObjectChild(). If you're implementing a " 'new RenderObjectElement, you should override/implement ' 'insertRenderObjectChild(), moveRenderObjectChild(), and ' - 'removeRenderObjectChild().'), + 'removeRenderObjectChild().', + ), ]); }()); } @@ -5871,15 +5881,19 @@ abstract class RenderObjectElement extends Element { name: 'super.moveChildRenderObject() was called on this Element', style: DiagnosticsTreeStyle.shallow, ), - ErrorDescription('moveChildRenderObject() has been deprecated in favor of ' - 'moveRenderObjectChild(). See https://github.com/flutter/flutter/issues/63269 ' - 'for details.'), - ErrorHint('Rather than overriding moveChildRenderObject() in your ' - 'RenderObjectElement subclass, override moveRenderObjectChild() instead, ' - "and DON'T call super.moveRenderObjectChild(). If you're implementing a " - 'new RenderObjectElement, you should override/implement ' - 'insertRenderObjectChild(), moveRenderObjectChild(), and ' - 'removeRenderObjectChild().'), + ErrorDescription( + 'moveChildRenderObject() has been deprecated in favor of ' + 'moveRenderObjectChild(). See https://github.com/flutter/flutter/issues/63269 ' + 'for details.', + ), + ErrorHint( + 'Rather than overriding moveChildRenderObject() in your ' + 'RenderObjectElement subclass, override moveRenderObjectChild() instead, ' + "and DON'T call super.moveRenderObjectChild(). If you're implementing a " + 'new RenderObjectElement, you should override/implement ' + 'insertRenderObjectChild(), moveRenderObjectChild(), and ' + 'removeRenderObjectChild().', + ), ]); }()); } @@ -5938,15 +5952,19 @@ abstract class RenderObjectElement extends Element { name: 'super.removeChildRenderObject() was called on this Element', style: DiagnosticsTreeStyle.shallow, ), - ErrorDescription('removeChildRenderObject() has been deprecated in favor of ' - 'removeRenderObjectChild(). See https://github.com/flutter/flutter/issues/63269 ' - 'for details.'), - ErrorHint('Rather than overriding removeChildRenderObject() in your ' - 'RenderObjectElement subclass, override removeRenderObjectChild() instead, ' - "and DON'T call super.removeRenderObjectChild(). If you're implementing a " - 'new RenderObjectElement, you should override/implement ' - 'insertRenderObjectChild(), moveRenderObjectChild(), and ' - 'removeRenderObjectChild().'), + ErrorDescription( + 'removeChildRenderObject() has been deprecated in favor of ' + 'removeRenderObjectChild(). See https://github.com/flutter/flutter/issues/63269 ' + 'for details.', + ), + ErrorHint( + 'Rather than overriding removeChildRenderObject() in your ' + 'RenderObjectElement subclass, override removeRenderObjectChild() instead, ' + "and DON'T call super.removeRenderObjectChild(). If you're implementing a " + 'new RenderObjectElement, you should override/implement ' + 'insertRenderObjectChild(), moveRenderObjectChild(), and ' + 'removeRenderObjectChild().', + ), ]); }()); } diff --git a/packages/flutter/lib/src/widgets/interactive_viewer.dart b/packages/flutter/lib/src/widgets/interactive_viewer.dart index 86d16a2377..2f293ab82a 100644 --- a/packages/flutter/lib/src/widgets/interactive_viewer.dart +++ b/packages/flutter/lib/src/widgets/interactive_viewer.dart @@ -99,10 +99,12 @@ class InteractiveViewer extends StatefulWidget { assert(scaleEnabled != null), // boundaryMargin must be either fully infinite or fully finite, but not // a mix of both. - assert((boundaryMargin.horizontal.isInfinite + assert( + (boundaryMargin.horizontal.isInfinite && boundaryMargin.vertical.isInfinite) || (boundaryMargin.top.isFinite && boundaryMargin.right.isFinite && boundaryMargin.bottom.isFinite - && boundaryMargin.left.isFinite)), + && boundaryMargin.left.isFinite), + ), super(key: key); /// If set to [Clip.none], the child may extend beyond the size of the InteractiveViewer, @@ -582,11 +584,14 @@ class _InteractiveViewerState extends State with TickerProvid final Rect boundaryRect = widget.boundaryMargin.inflateRect(Offset.zero & childSize); // Boundaries that are partially infinite are not allowed because Matrix4's // rotation and translation methods don't handle infinites well. - assert(boundaryRect.isFinite || + assert( + boundaryRect.isFinite || (boundaryRect.left.isInfinite && boundaryRect.top.isInfinite && boundaryRect.right.isInfinite - && boundaryRect.bottom.isInfinite), 'boundaryRect must either be infinite in all directions or finite in all directions.'); + && boundaryRect.bottom.isInfinite), + 'boundaryRect must either be infinite in all directions or finite in all directions.', + ); return boundaryRect; } diff --git a/packages/flutter/lib/src/widgets/overlay.dart b/packages/flutter/lib/src/widgets/overlay.dart index 6e87fe1768..989f05ed09 100644 --- a/packages/flutter/lib/src/widgets/overlay.dart +++ b/packages/flutter/lib/src/widgets/overlay.dart @@ -785,8 +785,14 @@ class _RenderTheatre extends RenderBox with ContainerRenderObjectMixin { final AxisDirection axisDirection = _getDirection(context); final ScrollPhysics physics = _ForceImplicitScrollPhysics( allowImplicitScrolling: widget.allowImplicitScrolling, - ).applyTo(widget.pageSnapping + ).applyTo( + widget.pageSnapping ? _kPagePhysics.applyTo(widget.physics ?? widget.scrollBehavior?.getScrollPhysics(context)) - : widget.physics ?? widget.scrollBehavior?.getScrollPhysics(context)); + : widget.physics ?? widget.scrollBehavior?.getScrollPhysics(context), + ); return NotificationListener( onNotification: (ScrollNotification notification) { diff --git a/packages/flutter/lib/src/widgets/reorderable_list.dart b/packages/flutter/lib/src/widgets/reorderable_list.dart index 1dc6df11cd..2c47270d6e 100644 --- a/packages/flutter/lib/src/widgets/reorderable_list.dart +++ b/packages/flutter/lib/src/widgets/reorderable_list.dart @@ -829,8 +829,10 @@ class SliverReorderableListState extends State with Ticke // When dragging, the dragged item is still in the list but has been replaced // by a zero height SizedBox, so that the gap can move around. To make the // list extent stable we add a dummy entry to the end. - delegate: SliverChildBuilderDelegate(_itemBuilder, - childCount: widget.itemCount + (_dragInfo != null ? 1 : 0)), + delegate: SliverChildBuilderDelegate( + _itemBuilder, + childCount: widget.itemCount + (_dragInfo != null ? 1 : 0), + ), ); } } diff --git a/packages/flutter/lib/src/widgets/scroll_controller.dart b/packages/flutter/lib/src/widgets/scroll_controller.dart index bc7e3bd621..cf6598b1f2 100644 --- a/packages/flutter/lib/src/widgets/scroll_controller.dart +++ b/packages/flutter/lib/src/widgets/scroll_controller.dart @@ -321,9 +321,11 @@ class TrackingScrollController extends ScrollController { double initialScrollOffset = 0.0, bool keepScrollOffset = true, String? debugLabel, - }) : super(initialScrollOffset: initialScrollOffset, - keepScrollOffset: keepScrollOffset, - debugLabel: debugLabel); + }) : super( + initialScrollOffset: initialScrollOffset, + keepScrollOffset: keepScrollOffset, + debugLabel: debugLabel, + ); final Map _positionToListener = {}; ScrollPosition? _lastUpdated; diff --git a/packages/flutter/lib/src/widgets/scroll_simulation.dart b/packages/flutter/lib/src/widgets/scroll_simulation.dart index 2f1005003d..6d401857fc 100644 --- a/packages/flutter/lib/src/widgets/scroll_simulation.dart +++ b/packages/flutter/lib/src/widgets/scroll_simulation.dart @@ -183,9 +183,7 @@ class ClampingScrollSimulation extends Simulation { // See getSplineDeceleration(). double _splineDeceleration(double velocity) { - return math.log(_inflexion * - velocity.abs() / - (friction * _decelerationForFriction(0.84))); + return math.log(_inflexion * velocity.abs() / (friction * _decelerationForFriction(0.84))); } // See getSplineFlingDuration(). diff --git a/packages/flutter/lib/src/widgets/scrollable.dart b/packages/flutter/lib/src/widgets/scrollable.dart index b55f86df1e..a339e3cd77 100644 --- a/packages/flutter/lib/src/widgets/scrollable.dart +++ b/packages/flutter/lib/src/widgets/scrollable.dart @@ -676,8 +676,10 @@ class ScrollableState extends State with TickerProviderStateMixin, R // Returns the offset that should result from applying [event] to the current // position, taking min/max scroll extent into account. double _targetScrollOffsetForPointerScroll(double delta) { - return math.min(math.max(position.pixels + delta, position.minScrollExtent), - position.maxScrollExtent); + return math.min( + math.max(position.pixels + delta, position.minScrollExtent), + position.maxScrollExtent, + ); } // Returns the delta that should result from applying [event] with axis and diff --git a/packages/flutter/lib/src/widgets/shortcuts.dart b/packages/flutter/lib/src/widgets/shortcuts.dart index 68163239e8..61593c9e42 100644 --- a/packages/flutter/lib/src/widgets/shortcuts.dart +++ b/packages/flutter/lib/src/widgets/shortcuts.dart @@ -347,11 +347,13 @@ class ShortcutManager extends ChangeNotifier with Diagnosticable { return KeyEventResult.ignored; } assert(context != null); - assert(keysPressed != null || RawKeyboard.instance.keysPressed.isNotEmpty, + assert( + keysPressed != null || RawKeyboard.instance.keysPressed.isNotEmpty, 'Received a key down event when no keys are in keysPressed. ' "This state can occur if the key event being sent doesn't properly " 'set its modifier flags. This was the event: $event and its data: ' - '${event.data}'); + '${event.data}', + ); final Intent? matchedIntent = _find(keysPressed: keysPressed); if (matchedIntent != null) { final BuildContext primaryContext = primaryFocus!.context!; @@ -622,13 +624,15 @@ class Shortcuts extends StatefulWidget { final _ShortcutsMarker? inherited = context.dependOnInheritedWidgetOfExactType<_ShortcutsMarker>(); assert(() { if (inherited == null) { - throw FlutterError('Unable to find a $Shortcuts widget in the context.\n' - '$Shortcuts.of() was called with a context that does not contain a ' - '$Shortcuts widget.\n' - 'No $Shortcuts ancestor could be found starting from the context that was ' - 'passed to $Shortcuts.of().\n' - 'The context used was:\n' - ' $context'); + throw FlutterError( + 'Unable to find a $Shortcuts widget in the context.\n' + '$Shortcuts.of() was called with a context that does not contain a ' + '$Shortcuts widget.\n' + 'No $Shortcuts ancestor could be found starting from the context that was ' + 'passed to $Shortcuts.of().\n' + 'The context used was:\n' + ' $context', + ); } return true; }()); diff --git a/packages/flutter/lib/src/widgets/single_child_scroll_view.dart b/packages/flutter/lib/src/widgets/single_child_scroll_view.dart index 60646a584b..e735993835 100644 --- a/packages/flutter/lib/src/widgets/single_child_scroll_view.dart +++ b/packages/flutter/lib/src/widgets/single_child_scroll_view.dart @@ -620,8 +620,14 @@ class _RenderSingleChildViewport extends RenderBox with RenderObjectWithChildMix } if (_shouldClipAtPaintOffset(paintOffset) && clipBehavior != Clip.none) { - _clipRectLayer = context.pushClipRect(needsCompositing, offset, Offset.zero & size, paintContents, - clipBehavior: clipBehavior, oldLayer: _clipRectLayer); + _clipRectLayer = context.pushClipRect( + needsCompositing, + offset, + Offset.zero & size, + paintContents, + clipBehavior: clipBehavior, + oldLayer: _clipRectLayer, + ); } else { _clipRectLayer = null; paintContents(context, offset); diff --git a/packages/flutter/lib/src/widgets/text_selection.dart b/packages/flutter/lib/src/widgets/text_selection.dart index 1be4bd4f09..3a09fd12eb 100644 --- a/packages/flutter/lib/src/widgets/text_selection.dart +++ b/packages/flutter/lib/src/widgets/text_selection.dart @@ -340,10 +340,12 @@ class TextSelectionOverlay { _handlesVisible = handlesVisible, _value = value { final OverlayState? overlay = Overlay.of(context, rootOverlay: true); - assert(overlay != null, + assert( + overlay != null, 'No Overlay widget exists above $context.\n' 'Usually the Navigator created by WidgetsApp provides the overlay. Perhaps your ' - 'app content was created above the Navigator with the WidgetsApp builder parameter.'); + 'app content was created above the Navigator with the WidgetsApp builder parameter.', + ); _toolbarController = AnimationController(duration: fadeDuration, vsync: overlay!); } diff --git a/packages/flutter/lib/src/widgets/widget_inspector.dart b/packages/flutter/lib/src/widgets/widget_inspector.dart index d1f06e809d..f17411a6e1 100644 --- a/packages/flutter/lib/src/widgets/widget_inspector.dart +++ b/packages/flutter/lib/src/widgets/widget_inspector.dart @@ -1544,8 +1544,9 @@ mixin WidgetInspectorService { List _truncateNodes(Iterable nodes, int maxDescendentsTruncatableNode) { if (nodes.every((DiagnosticsNode node) => node.value is Element) && isWidgetCreationTracked()) { - final List localNodes = nodes.where((DiagnosticsNode node) => - _isValueCreatedByLocalProject(node.value)).toList(); + final List localNodes = nodes + .where((DiagnosticsNode node) => _isValueCreatedByLocalProject(node.value)) + .toList(); if (localNodes.isNotEmpty) { return localNodes; } diff --git a/packages/flutter/lib/src/widgets/widget_span.dart b/packages/flutter/lib/src/widgets/widget_span.dart index 83a4ce0730..0261377568 100644 --- a/packages/flutter/lib/src/widgets/widget_span.dart +++ b/packages/flutter/lib/src/widgets/widget_span.dart @@ -75,11 +75,13 @@ class WidgetSpan extends PlaceholderSpan { TextBaseline? baseline, TextStyle? style, }) : assert(child != null), - assert(baseline != null || !( - identical(alignment, ui.PlaceholderAlignment.aboveBaseline) || - identical(alignment, ui.PlaceholderAlignment.belowBaseline) || - identical(alignment, ui.PlaceholderAlignment.baseline) - )), + assert( + baseline != null || !( + identical(alignment, ui.PlaceholderAlignment.aboveBaseline) || + identical(alignment, ui.PlaceholderAlignment.belowBaseline) || + identical(alignment, ui.PlaceholderAlignment.baseline) + ), + ), super( alignment: alignment, baseline: baseline,