Auto-format Framework (#160545)

This auto-formats all *.dart files in the repository outside of the
`engine` subdirectory and enforces that these files stay formatted with
a presubmit check.

**Reviewers:** Please carefully review all the commits except for the
one titled "formatted". The "formatted" commit was auto-generated by
running `dev/tools/format.sh -a -f`. The other commits were hand-crafted
to prepare the repo for the formatting change. I recommend reviewing the
commits one-by-one via the "Commits" tab and avoiding Github's "Files
changed" tab as it will likely slow down your browser because of the
size of this PR.

---------

Co-authored-by: Kate Lovett <katelovett@google.com>
Co-authored-by: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com>
This commit is contained in:
Michael Goderbauer
2024-12-19 12:06:21 -08:00
committed by GitHub
parent 8e0993eda8
commit 5491c8c146
4411 changed files with 455108 additions and 415991 deletions

View File

@@ -8,21 +8,13 @@ import 'package:flutter/rendering.dart';
/// Flutter code sample for [SlottedMultiChildRenderObjectWidget].
/// Slots used for the children of [Diagonal] and [RenderDiagonal].
enum DiagonalSlot {
topLeft,
bottomRight,
}
enum DiagonalSlot { topLeft, bottomRight }
/// A widget that demonstrates the usage of
/// [SlottedMultiChildRenderObjectWidget] by providing slots for two
/// children that will be arranged diagonally.
class Diagonal extends SlottedMultiChildRenderObjectWidget<DiagonalSlot, RenderBox> {
const Diagonal({
super.key,
this.topLeft,
this.bottomRight,
this.backgroundColor,
});
const Diagonal({super.key, this.topLeft, this.bottomRight, this.backgroundColor});
final Widget? topLeft;
final Widget? bottomRight;
@@ -34,7 +26,7 @@ class Diagonal extends SlottedMultiChildRenderObjectWidget<DiagonalSlot, RenderB
@override
Widget? childForSlot(DiagonalSlot slot) {
return switch (slot) {
DiagonalSlot.topLeft => topLeft,
DiagonalSlot.topLeft => topLeft,
DiagonalSlot.bottomRight => bottomRight,
};
}
@@ -50,9 +42,7 @@ class Diagonal extends SlottedMultiChildRenderObjectWidget<DiagonalSlot, RenderB
SlottedContainerRenderObjectMixin<DiagonalSlot, RenderBox> createRenderObject(
BuildContext context,
) {
return RenderDiagonal(
backgroundColor: backgroundColor,
);
return RenderDiagonal(backgroundColor: backgroundColor);
}
@override
@@ -124,10 +114,7 @@ class RenderDiagonal extends RenderBox
final RenderBox? bottomRight = _bottomRight;
if (bottomRight != null) {
bottomRight.layout(childConstraints, parentUsesSize: true);
_positionChild(
bottomRight,
Offset(topLeftSize.width, topLeftSize.height),
);
_positionChild(bottomRight, Offset(topLeftSize.width, topLeftSize.height));
bottomRightSize = bottomRight.size;
}
@@ -150,10 +137,7 @@ class RenderDiagonal extends RenderBox
void paint(PaintingContext context, Offset offset) {
// Paint the background.
if (backgroundColor != null) {
context.canvas.drawRect(
offset & size,
Paint()..color = backgroundColor!,
);
context.canvas.drawRect(offset & size, Paint()..color = backgroundColor!);
}
void paintChild(RenderBox child, PaintingContext context, Offset offset) {
@@ -174,12 +158,7 @@ class RenderDiagonal extends RenderBox
// Paint an overflow indicator in debug mode if the children want to be
// larger than the incoming constraints allow.
assert(() {
paintOverflowIndicator(
context,
offset,
Offset.zero & size,
Offset.zero & _childrenSize,
);
paintOverflowIndicator(context, offset, Offset.zero & size, Offset.zero & _childrenSize);
return true;
}());
}
@@ -242,10 +221,9 @@ class RenderDiagonal extends RenderBox
const BoxConstraints childConstraints = BoxConstraints();
final Size topLeftSize = _topLeft?.getDryLayout(childConstraints) ?? Size.zero;
final Size bottomRightSize = _bottomRight?.getDryLayout(childConstraints) ?? Size.zero;
return constraints.constrain(Size(
topLeftSize.width + bottomRightSize.width,
topLeftSize.height + bottomRightSize.height,
));
return constraints.constrain(
Size(topLeftSize.width + bottomRightSize.width, topLeftSize.height + bottomRightSize.height),
);
}
}
@@ -263,17 +241,13 @@ class ExampleWidget extends StatelessWidget {
color: Colors.green,
height: 100,
width: 200,
child: const Center(
child: Text('topLeft'),
),
child: const Center(child: Text('topLeft')),
),
bottomRight: Container(
color: Colors.yellow,
height: 60,
width: 30,
child: const Center(
child: Text('bottomRight'),
),
child: const Center(child: Text('bottomRight')),
),
backgroundColor: Colors.blue,
),