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:
committed by
GitHub
parent
8e0993eda8
commit
5491c8c146
@@ -21,7 +21,7 @@ class ViewRenderingFlutterBinding extends RenderingFlutterBinding {
|
||||
///
|
||||
/// This binding does not automatically schedule any frames. Callers are
|
||||
/// responsible for deciding when to first call [scheduleFrame].
|
||||
ViewRenderingFlutterBinding({ RenderBox? root }) : _root = root;
|
||||
ViewRenderingFlutterBinding({RenderBox? root}) : _root = root;
|
||||
|
||||
@override
|
||||
void initInstances() {
|
||||
|
||||
@@ -17,7 +17,7 @@ class SectorConstraints extends Constraints {
|
||||
}) : assert(maxDeltaRadius >= minDeltaRadius),
|
||||
assert(maxDeltaTheta >= minDeltaTheta);
|
||||
|
||||
const SectorConstraints.tight({ double deltaRadius = 0.0, double deltaTheta = 0.0 })
|
||||
const SectorConstraints.tight({double deltaRadius = 0.0, double deltaTheta = 0.0})
|
||||
: minDeltaRadius = deltaRadius,
|
||||
maxDeltaRadius = deltaRadius,
|
||||
minDeltaTheta = deltaTheta,
|
||||
@@ -53,7 +53,7 @@ class SectorConstraints extends Constraints {
|
||||
}
|
||||
|
||||
class SectorDimensions {
|
||||
const SectorDimensions({ this.deltaRadius = 0.0, this.deltaTheta = 0.0 });
|
||||
const SectorDimensions({this.deltaRadius = 0.0, this.deltaTheta = 0.0});
|
||||
|
||||
factory SectorDimensions.withConstraints(
|
||||
SectorConstraints constraints, {
|
||||
@@ -88,7 +88,6 @@ class SectorParentData extends ParentData {
|
||||
/// * [RenderBox], which is the base class for [RenderObject]s that live in a
|
||||
/// Cartesian coordinate space.
|
||||
abstract class RenderSector extends RenderObject {
|
||||
|
||||
@override
|
||||
void setupParentData(RenderObject child) {
|
||||
if (child.parentData is! SectorParentData) {
|
||||
@@ -137,25 +136,32 @@ abstract class RenderSector extends RenderObject {
|
||||
Rect get paintBounds => Rect.fromLTWH(0.0, 0.0, 2.0 * deltaRadius, 2.0 * deltaRadius);
|
||||
|
||||
@override
|
||||
Rect get semanticBounds => Rect.fromLTWH(-deltaRadius, -deltaRadius, 2.0 * deltaRadius, 2.0 * deltaRadius);
|
||||
Rect get semanticBounds =>
|
||||
Rect.fromLTWH(-deltaRadius, -deltaRadius, 2.0 * deltaRadius, 2.0 * deltaRadius);
|
||||
|
||||
bool hitTest(SectorHitTestResult result, { required double radius, required double theta }) {
|
||||
if (radius < parentData!.radius || radius >= parentData!.radius + deltaRadius ||
|
||||
theta < parentData!.theta || theta >= parentData!.theta + deltaTheta) {
|
||||
bool hitTest(SectorHitTestResult result, {required double radius, required double theta}) {
|
||||
if (radius < parentData!.radius ||
|
||||
radius >= parentData!.radius + deltaRadius ||
|
||||
theta < parentData!.theta ||
|
||||
theta >= parentData!.theta + deltaTheta) {
|
||||
return false;
|
||||
}
|
||||
hitTestChildren(result, radius: radius, theta: theta);
|
||||
result.add(SectorHitTestEntry(this, radius: radius, theta: theta));
|
||||
return true;
|
||||
}
|
||||
void hitTestChildren(SectorHitTestResult result, { required double radius, required double theta }) { }
|
||||
|
||||
void hitTestChildren(
|
||||
SectorHitTestResult result, {
|
||||
required double radius,
|
||||
required double theta,
|
||||
}) {}
|
||||
|
||||
late double deltaRadius;
|
||||
late double deltaTheta;
|
||||
}
|
||||
|
||||
abstract class RenderDecoratedSector extends RenderSector {
|
||||
|
||||
RenderDecoratedSector(BoxDecoration? decoration) : _decoration = decoration;
|
||||
|
||||
BoxDecoration? _decoration;
|
||||
@@ -182,31 +188,47 @@ abstract class RenderDecoratedSector extends RenderSector {
|
||||
final Paint paint = Paint()..color = _decoration!.color!;
|
||||
final Path path = Path();
|
||||
final double outerRadius = parentData!.radius + deltaRadius;
|
||||
final Rect outerBounds = Rect.fromLTRB(offset.dx-outerRadius, offset.dy-outerRadius, offset.dx+outerRadius, offset.dy+outerRadius);
|
||||
final Rect outerBounds = Rect.fromLTRB(
|
||||
offset.dx - outerRadius,
|
||||
offset.dy - outerRadius,
|
||||
offset.dx + outerRadius,
|
||||
offset.dy + outerRadius,
|
||||
);
|
||||
path.arcTo(outerBounds, parentData!.theta, deltaTheta, true);
|
||||
final double innerRadius = parentData!.radius;
|
||||
final Rect innerBounds = Rect.fromLTRB(offset.dx-innerRadius, offset.dy-innerRadius, offset.dx+innerRadius, offset.dy+innerRadius);
|
||||
final Rect innerBounds = Rect.fromLTRB(
|
||||
offset.dx - innerRadius,
|
||||
offset.dy - innerRadius,
|
||||
offset.dx + innerRadius,
|
||||
offset.dy + innerRadius,
|
||||
);
|
||||
path.arcTo(innerBounds, parentData!.theta + deltaTheta, -deltaTheta, false);
|
||||
path.close();
|
||||
canvas.drawPath(path, paint);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class SectorChildListParentData extends SectorParentData with ContainerParentDataMixin<RenderSector> { }
|
||||
class SectorChildListParentData extends SectorParentData
|
||||
with ContainerParentDataMixin<RenderSector> {}
|
||||
|
||||
class RenderSectorWithChildren extends RenderDecoratedSector with ContainerRenderObjectMixin<RenderSector, SectorChildListParentData> {
|
||||
class RenderSectorWithChildren extends RenderDecoratedSector
|
||||
with ContainerRenderObjectMixin<RenderSector, SectorChildListParentData> {
|
||||
RenderSectorWithChildren(super.decoration);
|
||||
|
||||
@override
|
||||
void hitTestChildren(SectorHitTestResult result, { required double radius, required double theta }) {
|
||||
void hitTestChildren(
|
||||
SectorHitTestResult result, {
|
||||
required double radius,
|
||||
required double theta,
|
||||
}) {
|
||||
RenderSector? child = lastChild;
|
||||
while (child != null) {
|
||||
if (child.hitTest(result, radius: radius, theta: theta)) {
|
||||
return;
|
||||
}
|
||||
final SectorChildListParentData childParentData = child.parentData! as SectorChildListParentData;
|
||||
final SectorChildListParentData childParentData =
|
||||
child.parentData! as SectorChildListParentData;
|
||||
child = childParentData.previousSibling;
|
||||
}
|
||||
}
|
||||
@@ -216,7 +238,8 @@ class RenderSectorWithChildren extends RenderDecoratedSector with ContainerRende
|
||||
RenderSector? child = lastChild;
|
||||
while (child != null) {
|
||||
visitor(child);
|
||||
final SectorChildListParentData childParentData = child.parentData! as SectorChildListParentData;
|
||||
final SectorChildListParentData childParentData =
|
||||
child.parentData! as SectorChildListParentData;
|
||||
child = childParentData.previousSibling;
|
||||
}
|
||||
}
|
||||
@@ -269,17 +292,24 @@ class RenderSectorRing extends RenderSectorWithChildren {
|
||||
final double childRadius = radius + padding;
|
||||
final double paddingTheta = math.atan(padding / (radius + outerDeltaRadius));
|
||||
double innerTheta = paddingTheta; // increments with each child
|
||||
double remainingDeltaTheta = math.max(0.0, constraints.maxDeltaTheta - (innerTheta + paddingTheta));
|
||||
double remainingDeltaTheta = math.max(
|
||||
0.0,
|
||||
constraints.maxDeltaTheta - (innerTheta + paddingTheta),
|
||||
);
|
||||
RenderSector? child = firstChild;
|
||||
while (child != null) {
|
||||
final SectorConstraints innerConstraints = SectorConstraints(
|
||||
maxDeltaRadius: innerDeltaRadius,
|
||||
maxDeltaTheta: remainingDeltaTheta,
|
||||
);
|
||||
final SectorDimensions childDimensions = child.getIntrinsicDimensions(innerConstraints, childRadius);
|
||||
final SectorDimensions childDimensions = child.getIntrinsicDimensions(
|
||||
innerConstraints,
|
||||
childRadius,
|
||||
);
|
||||
innerTheta += childDimensions.deltaTheta;
|
||||
remainingDeltaTheta -= childDimensions.deltaTheta;
|
||||
final SectorChildListParentData childParentData = child.parentData! as SectorChildListParentData;
|
||||
final SectorChildListParentData childParentData =
|
||||
child.parentData! as SectorChildListParentData;
|
||||
child = childParentData.nextSibling;
|
||||
if (child != null) {
|
||||
innerTheta += paddingTheta;
|
||||
@@ -315,7 +345,8 @@ class RenderSectorRing extends RenderSectorWithChildren {
|
||||
child.layout(innerConstraints, parentUsesSize: true);
|
||||
innerTheta += child.deltaTheta;
|
||||
remainingDeltaTheta -= child.deltaTheta;
|
||||
final SectorChildListParentData childParentData = child.parentData! as SectorChildListParentData;
|
||||
final SectorChildListParentData childParentData =
|
||||
child.parentData! as SectorChildListParentData;
|
||||
child = childParentData.nextSibling;
|
||||
if (child != null) {
|
||||
innerTheta += paddingTheta;
|
||||
@@ -334,21 +365,20 @@ class RenderSectorRing extends RenderSectorWithChildren {
|
||||
RenderSector? child = firstChild;
|
||||
while (child != null) {
|
||||
context.paintChild(child, offset);
|
||||
final SectorChildListParentData childParentData = child.parentData! as SectorChildListParentData;
|
||||
final SectorChildListParentData childParentData =
|
||||
child.parentData! as SectorChildListParentData;
|
||||
child = childParentData.nextSibling;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class RenderSectorSlice extends RenderSectorWithChildren {
|
||||
// lays out RenderSector children in a stack
|
||||
|
||||
RenderSectorSlice({
|
||||
BoxDecoration? decoration,
|
||||
double deltaTheta = kTwoPi,
|
||||
double padding = 0.0,
|
||||
}) : _padding = padding, _desiredDeltaTheta = deltaTheta, super(decoration);
|
||||
RenderSectorSlice({BoxDecoration? decoration, double deltaTheta = kTwoPi, double padding = 0.0})
|
||||
: _padding = padding,
|
||||
_desiredDeltaTheta = deltaTheta,
|
||||
super(decoration);
|
||||
|
||||
double _desiredDeltaTheta;
|
||||
double get desiredDeltaTheta => _desiredDeltaTheta;
|
||||
@@ -391,10 +421,14 @@ class RenderSectorSlice extends RenderSectorWithChildren {
|
||||
maxDeltaRadius: remainingDeltaRadius,
|
||||
maxDeltaTheta: innerDeltaTheta,
|
||||
);
|
||||
final SectorDimensions childDimensions = child.getIntrinsicDimensions(innerConstraints, childRadius);
|
||||
final SectorDimensions childDimensions = child.getIntrinsicDimensions(
|
||||
innerConstraints,
|
||||
childRadius,
|
||||
);
|
||||
childRadius += childDimensions.deltaRadius;
|
||||
remainingDeltaRadius -= childDimensions.deltaRadius;
|
||||
final SectorChildListParentData childParentData = child.parentData! as SectorChildListParentData;
|
||||
final SectorChildListParentData childParentData =
|
||||
child.parentData! as SectorChildListParentData;
|
||||
child = childParentData.nextSibling;
|
||||
childRadius += padding;
|
||||
remainingDeltaRadius -= padding;
|
||||
@@ -427,7 +461,8 @@ class RenderSectorSlice extends RenderSectorWithChildren {
|
||||
child.layout(innerConstraints, parentUsesSize: true);
|
||||
childRadius += child.deltaRadius;
|
||||
remainingDeltaRadius -= child.deltaRadius;
|
||||
final SectorChildListParentData childParentData = child.parentData! as SectorChildListParentData;
|
||||
final SectorChildListParentData childParentData =
|
||||
child.parentData! as SectorChildListParentData;
|
||||
child = childParentData.nextSibling;
|
||||
childRadius += padding;
|
||||
remainingDeltaRadius -= padding;
|
||||
@@ -445,15 +480,16 @@ class RenderSectorSlice extends RenderSectorWithChildren {
|
||||
while (child != null) {
|
||||
assert(child.parentData is SectorChildListParentData);
|
||||
context.paintChild(child, offset);
|
||||
final SectorChildListParentData childParentData = child.parentData! as SectorChildListParentData;
|
||||
final SectorChildListParentData childParentData =
|
||||
child.parentData! as SectorChildListParentData;
|
||||
child = childParentData.nextSibling;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class RenderBoxToRenderSectorAdapter extends RenderBox with RenderObjectWithChildMixin<RenderSector> {
|
||||
RenderBoxToRenderSectorAdapter({ double innerRadius = 0.0, RenderSector? child })
|
||||
class RenderBoxToRenderSectorAdapter extends RenderBox
|
||||
with RenderObjectWithChildMixin<RenderSector> {
|
||||
RenderBoxToRenderSectorAdapter({double innerRadius = 0.0, RenderSector? child})
|
||||
: _innerRadius = innerRadius {
|
||||
this.child = child;
|
||||
}
|
||||
@@ -504,17 +540,17 @@ class RenderBoxToRenderSectorAdapter extends RenderBox with RenderObjectWithChil
|
||||
return getIntrinsicDimensions(width: width).height;
|
||||
}
|
||||
|
||||
Size getIntrinsicDimensions({
|
||||
double width = double.infinity,
|
||||
double height = double.infinity,
|
||||
}) {
|
||||
Size getIntrinsicDimensions({double width = double.infinity, double height = double.infinity}) {
|
||||
assert(child is RenderSector);
|
||||
assert(child!.parentData is SectorParentData);
|
||||
if (!width.isFinite && !height.isFinite) {
|
||||
return Size.zero;
|
||||
}
|
||||
final double maxChildDeltaRadius = math.max(0.0, math.min(width, height) / 2.0 - innerRadius);
|
||||
final SectorDimensions childDimensions = child!.getIntrinsicDimensions(SectorConstraints(maxDeltaRadius: maxChildDeltaRadius), innerRadius);
|
||||
final SectorDimensions childDimensions = child!.getIntrinsicDimensions(
|
||||
SectorConstraints(maxDeltaRadius: maxChildDeltaRadius),
|
||||
innerRadius,
|
||||
);
|
||||
final double dimension = (innerRadius + childDimensions.deltaRadius) * 2.0;
|
||||
return Size.square(dimension);
|
||||
}
|
||||
@@ -528,7 +564,8 @@ class RenderBoxToRenderSectorAdapter extends RenderBox with RenderObjectWithChil
|
||||
}
|
||||
assert(child is RenderSector);
|
||||
assert(child!.parentData is SectorParentData);
|
||||
final double maxChildDeltaRadius = math.min(constraints.maxWidth, constraints.maxHeight) / 2.0 - innerRadius;
|
||||
final double maxChildDeltaRadius =
|
||||
math.min(constraints.maxWidth, constraints.maxHeight) / 2.0 - innerRadius;
|
||||
child!.parentData!.radius = innerRadius;
|
||||
child!.parentData!.theta = 0.0;
|
||||
child!.layout(SectorConstraints(maxDeltaRadius: maxChildDeltaRadius), parentUsesSize: true);
|
||||
@@ -547,7 +584,7 @@ class RenderBoxToRenderSectorAdapter extends RenderBox with RenderObjectWithChil
|
||||
}
|
||||
|
||||
@override
|
||||
bool hitTest(BoxHitTestResult result, { required Offset position }) {
|
||||
bool hitTest(BoxHitTestResult result, {required Offset position}) {
|
||||
if (child == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -636,7 +673,7 @@ class SectorHitTestResult extends HitTestResult {
|
||||
/// A hit test entry used by [RenderSector].
|
||||
class SectorHitTestEntry extends HitTestEntry {
|
||||
/// Creates a box hit test entry.
|
||||
SectorHitTestEntry(RenderSector super.target, { required this.radius, required this.theta });
|
||||
SectorHitTestEntry(RenderSector super.target, {required this.radius, required this.theta});
|
||||
|
||||
@override
|
||||
RenderSector get target => super.target as RenderSector;
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
import 'package:flutter/rendering.dart';
|
||||
|
||||
class RenderSolidColorBox extends RenderDecoratedBox {
|
||||
RenderSolidColorBox(this.backgroundColor, { this.desiredSize = Size.infinite })
|
||||
: super(decoration: BoxDecoration(color: backgroundColor));
|
||||
RenderSolidColorBox(this.backgroundColor, {this.desiredSize = Size.infinite})
|
||||
: super(decoration: BoxDecoration(color: backgroundColor));
|
||||
|
||||
final Size desiredSize;
|
||||
final Color backgroundColor;
|
||||
|
||||
Reference in New Issue
Block a user