Add @override annotations to flutter framework

This commit is contained in:
Hixie
2016-03-14 13:31:43 -07:00
parent 9bc6d281fe
commit 797e27edd3
322 changed files with 2544 additions and 9 deletions

View File

@@ -36,9 +36,13 @@ class SectorConstraints extends Constraints {
return deltaTheta.clamp(minDeltaTheta, maxDeltaTheta);
}
@override
bool get isTight => minDeltaTheta >= maxDeltaTheta && minDeltaTheta >= maxDeltaTheta;
@override
bool get isNormalized => minDeltaRadius <= maxDeltaRadius && minDeltaTheta <= maxDeltaTheta;
@override
bool get debugAssertIsNormalized {
assert(isNormalized);
return isNormalized;
@@ -69,6 +73,7 @@ class SectorParentData extends ParentData {
abstract class RenderSector extends RenderObject {
@override
void setupParentData(RenderObject child) {
if (child.parentData is! SectorParentData)
child.parentData = new SectorParentData();
@@ -76,13 +81,17 @@ abstract class RenderSector extends RenderObject {
// RenderSectors always use SectorParentData subclasses, as they need to be
// able to read their position information for painting and hit testing.
@override
SectorParentData get parentData => super.parentData;
SectorDimensions getIntrinsicDimensions(SectorConstraints constraints, double radius) {
return new SectorDimensions.withConstraints(constraints);
}
@override
SectorConstraints get constraints => super.constraints;
@override
void debugAssertDoesMeetConstraints() {
assert(constraints != null);
assert(deltaRadius != null);
@@ -94,11 +103,15 @@ abstract class RenderSector extends RenderObject {
assert(constraints.minDeltaTheta <= deltaTheta);
assert(deltaTheta <= math.max(constraints.minDeltaTheta, constraints.maxDeltaTheta));
}
@override
void performResize() {
// default behavior for subclasses that have sizedByParent = true
deltaRadius = constraints.constrainDeltaRadius(0.0);
deltaTheta = constraints.constrainDeltaTheta(0.0);
}
@override
void performLayout() {
// descendants have to either override performLayout() to set both
// the dimensions and lay out children, or, set sizedByParent to
@@ -106,7 +119,10 @@ abstract class RenderSector extends RenderObject {
assert(sizedByParent);
}
@override
Rect get paintBounds => new Rect.fromLTWH(0.0, 0.0, 2.0 * deltaRadius, 2.0 * deltaRadius);
@override
Rect get semanticBounds => new Rect.fromLTWH(-deltaRadius, -deltaRadius, 2.0 * deltaRadius, 2.0 * deltaRadius);
bool hitTest(HitTestResult result, { double radius, double theta }) {
@@ -137,6 +153,7 @@ abstract class RenderDecoratedSector extends RenderSector {
}
// offset must point to the center of the circle
@override
void paint(PaintingContext context, Offset offset) {
assert(deltaRadius != null);
assert(deltaTheta != null);
@@ -167,6 +184,7 @@ class SectorChildListParentData extends SectorParentData with ContainerParentDat
class RenderSectorWithChildren extends RenderDecoratedSector with ContainerRenderObjectMixin<RenderSector, SectorChildListParentData> {
RenderSectorWithChildren(BoxDecoration decoration) : super(decoration);
@override
void hitTestChildren(HitTestResult result, { double radius, double theta }) {
RenderSector child = lastChild;
while (child != null) {
@@ -177,6 +195,7 @@ class RenderSectorWithChildren extends RenderDecoratedSector with ContainerRende
}
}
@override
void visitChildren(RenderObjectVisitor visitor) {
RenderSector child = lastChild;
while (child != null) {
@@ -217,12 +236,14 @@ class RenderSectorRing extends RenderSectorWithChildren {
}
}
@override
void setupParentData(RenderObject child) {
// TODO(ianh): avoid code duplication
if (child.parentData is! SectorChildListParentData)
child.parentData = new SectorChildListParentData();
}
@override
SectorDimensions getIntrinsicDimensions(SectorConstraints constraints, double radius) {
double outerDeltaRadius = constraints.constrainDeltaRadius(desiredDeltaRadius);
double innerDeltaRadius = outerDeltaRadius - padding * 2.0;
@@ -251,6 +272,7 @@ class RenderSectorRing extends RenderSectorWithChildren {
deltaTheta: innerTheta);
}
@override
void performLayout() {
assert(this.parentData is SectorParentData);
deltaRadius = constraints.constrainDeltaRadius(desiredDeltaRadius);
@@ -284,6 +306,7 @@ class RenderSectorRing extends RenderSectorWithChildren {
// offset must point to the center of our circle
// each sector then knows how to paint itself at its location
@override
void paint(PaintingContext context, Offset offset) {
// TODO(ianh): avoid code duplication
super.paint(context, offset);
@@ -327,12 +350,14 @@ class RenderSectorSlice extends RenderSectorWithChildren {
}
}
@override
void setupParentData(RenderObject child) {
// TODO(ianh): avoid code duplication
if (child.parentData is! SectorChildListParentData)
child.parentData = new SectorChildListParentData();
}
@override
SectorDimensions getIntrinsicDimensions(SectorConstraints constraints, double radius) {
assert(this.parentData is SectorParentData);
double paddingTheta = math.atan(padding / this.parentData.radius);
@@ -359,6 +384,7 @@ class RenderSectorSlice extends RenderSectorWithChildren {
deltaTheta: outerDeltaTheta);
}
@override
void performLayout() {
assert(this.parentData is SectorParentData);
deltaTheta = constraints.constrainDeltaTheta(desiredDeltaTheta);
@@ -389,6 +415,7 @@ class RenderSectorSlice extends RenderSectorWithChildren {
// offset must point to the center of our circle
// each sector then knows how to paint itself at its location
@override
void paint(PaintingContext context, Offset offset) {
// TODO(ianh): avoid code duplication
super.paint(context, offset);
@@ -417,29 +444,34 @@ class RenderBoxToRenderSectorAdapter extends RenderBox with RenderObjectWithChil
markNeedsLayout();
}
@override
void setupParentData(RenderObject child) {
if (child.parentData is! SectorParentData)
child.parentData = new SectorParentData();
}
@override
double getMinIntrinsicWidth(BoxConstraints constraints) {
if (child == null)
return super.getMinIntrinsicWidth(constraints);
return getIntrinsicDimensions(constraints).width;
}
@override
double getMaxIntrinsicWidth(BoxConstraints constraints) {
if (child == null)
return super.getMaxIntrinsicWidth(constraints);
return getIntrinsicDimensions(constraints).width;
}
@override
double getMinIntrinsicHeight(BoxConstraints constraints) {
if (child == null)
return super.getMinIntrinsicHeight(constraints);
return getIntrinsicDimensions(constraints).height;
}
@override
double getMaxIntrinsicHeight(BoxConstraints constraints) {
if (child == null)
return super.getMaxIntrinsicHeight(constraints);
@@ -456,6 +488,7 @@ class RenderBoxToRenderSectorAdapter extends RenderBox with RenderObjectWithChil
return constraints.constrain(new Size(dimension, dimension));
}
@override
void performLayout() {
if (child == null) {
size = constraints.constrain(Size.zero);
@@ -472,6 +505,7 @@ class RenderBoxToRenderSectorAdapter extends RenderBox with RenderObjectWithChil
}
}
@override
void paint(PaintingContext context, Offset offset) {
super.paint(context, offset);
if (child != null) {
@@ -481,6 +515,7 @@ class RenderBoxToRenderSectorAdapter extends RenderBox with RenderObjectWithChil
}
}
@override
bool hitTest(HitTestResult result, { Point position }) {
if (child == null)
return false;
@@ -516,15 +551,18 @@ class RenderSolidColor extends RenderDecoratedSector {
double desiredDeltaTheta;
final Color backgroundColor;
@override
SectorDimensions getIntrinsicDimensions(SectorConstraints constraints, double radius) {
return new SectorDimensions.withConstraints(constraints, deltaTheta: desiredDeltaTheta);
}
@override
void performLayout() {
deltaRadius = constraints.constrainDeltaRadius(desiredDeltaRadius);
deltaTheta = constraints.constrainDeltaTheta(desiredDeltaTheta);
}
@override
void handleEvent(PointerEvent event, HitTestEntry entry) {
if (event is PointerDownEvent) {
decoration = new BoxDecoration(backgroundColor: const Color(0xFFFF0000));

View File

@@ -13,34 +13,40 @@ class RenderSolidColorBox extends RenderDecoratedBox {
: backgroundColor = backgroundColor,
super(decoration: new BoxDecoration(backgroundColor: backgroundColor));
@override
double getMinIntrinsicWidth(BoxConstraints constraints) {
return constraints.constrainHeight(
this.desiredSize == Size.infinite ? 0.0 : desiredSize.width
);
}
@override
double getMaxIntrinsicWidth(BoxConstraints constraints) {
return constraints.constrainWidth(
this.desiredSize == Size.infinite ? 0.0 : desiredSize.width
);
}
@override
double getMinIntrinsicHeight(BoxConstraints constraints) {
return constraints.constrainHeight(
this.desiredSize == Size.infinite ? 0.0 : desiredSize.height
);
}
@override
double getMaxIntrinsicHeight(BoxConstraints constraints) {
return constraints.constrainHeight(
this.desiredSize == Size.infinite ? 0.0 : desiredSize.height
);
}
@override
void performLayout() {
size = constraints.constrain(desiredSize);
}
@override
void handleEvent(PointerEvent event, BoxHitTestEntry entry) {
if (event is PointerDownEvent) {
decoration = new BoxDecoration(backgroundColor: const Color(0xFFFF0000));