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

@@ -14,6 +14,7 @@ class _MyAutoLayoutDelegate extends AutoLayoutDelegate {
AutoLayoutRect p3 = new AutoLayoutRect();
AutoLayoutRect p4 = new AutoLayoutRect();
@override
List<al.Constraint> getConstraints(AutoLayoutRect parent) {
return <al.Constraint>[
// Sum of widths of each box must be equal to that of the container
@@ -44,6 +45,7 @@ class _MyAutoLayoutDelegate extends AutoLayoutDelegate {
];
}
@override
bool shouldUpdateConstraints(AutoLayoutDelegate oldDelegate) => true;
}

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));

View File

@@ -45,20 +45,24 @@ class RenderDots extends RenderBox {
/// Indicates that the size of this render object depends only on the
/// layout constraints provided by the parent.
@override
bool get sizedByParent => true;
/// By selecting the biggest value permitted by the incomming constraints
/// during layout, this function makes this render object as large as
/// possible (i.e., fills the entire screen).
@override
void performResize() {
size = constraints.biggest;
}
/// Makes this render object hittable so that it receives pointer events.
@override
bool hitTestSelf(Point position) => true;
/// Processes pointer events by mutating state and invalidating its previous
/// painting commands.
@override
void handleEvent(PointerEvent event, BoxHitTestEntry entry) {
if (event is PointerDownEvent) {
Color color = _kColors[event.pointer.remainder(_kColors.length)];
@@ -78,6 +82,7 @@ class RenderDots extends RenderBox {
}
/// Issues new painting commands.
@override
void paint(PaintingContext context, Offset offset) {
final Canvas canvas = context.canvas;
// The "size" property indicates the size of that this render box was

View File

@@ -74,6 +74,7 @@ class PianoApp extends StatelessWidget {
}
}
@override
Widget build(BuildContext context) {
List<Widget> children = <Widget>[];
for (PianoKey key in keys) {

View File

@@ -13,6 +13,7 @@ class _MyAutoLayoutDelegate extends AutoLayoutDelegate {
AutoLayoutRect p3 = new AutoLayoutRect();
AutoLayoutRect p4 = new AutoLayoutRect();
@override
List<al.Constraint> getConstraints(AutoLayoutRect parent) {
return <al.Constraint>[
// Sum of widths of each box must be equal to that of the container
@@ -43,16 +44,19 @@ class _MyAutoLayoutDelegate extends AutoLayoutDelegate {
];
}
@override
bool shouldUpdateConstraints(_MyAutoLayoutDelegate oldDelegate) => true;
}
class ColoredBoxes extends StatefulWidget {
@override
_ColoredBoxesState createState() => new _ColoredBoxesState();
}
class _ColoredBoxesState extends State<ColoredBoxes> {
final _MyAutoLayoutDelegate delegate = new _MyAutoLayoutDelegate();
@override
Widget build(BuildContext context) {
return new AutoLayout(
delegate: delegate,

View File

@@ -9,10 +9,12 @@ class RenderDots extends RenderConstrainedBox {
RenderDots() : super(additionalConstraints: const BoxConstraints.expand());
// Makes this render box hittable so that we'll get pointer events.
@override
bool hitTestSelf(Point position) => true;
final Map<int, Point> _dots = <int, Point>{};
@override
void handleEvent(PointerEvent event, BoxHitTestEntry entry) {
if (event is PointerDownEvent || event is PointerMoveEvent) {
_dots[event.pointer] = event.position;
@@ -23,6 +25,7 @@ class RenderDots extends RenderConstrainedBox {
}
}
@override
void paint(PaintingContext context, Offset offset) {
final Canvas canvas = context.canvas;
canvas.drawRect(offset & size, new Paint()..color = new Color(0xFF0000FF));
@@ -37,6 +40,8 @@ class RenderDots extends RenderConstrainedBox {
class Dots extends SingleChildRenderObjectWidget {
Dots({ Key key, Widget child }) : super(key: key, child: child);
@override
RenderDots createRenderObject(BuildContext context) => new RenderDots();
}

View File

@@ -25,6 +25,7 @@ class _GesturePainter extends CustomPainter {
final bool doubleTapEnabled;
final bool longPressEnabled;
@override
void paint(Canvas canvas, Size size) {
Point center = (size.center(Point.origin).toOffset() * zoom + offset).toPoint();
double radius = size.width / 2.0 * zoom;
@@ -42,6 +43,7 @@ class _GesturePainter extends CustomPainter {
canvas.drawCircle(center, radius, paint);
}
@override
bool shouldRepaint(_GesturePainter oldPainter) {
return oldPainter.zoom != zoom
|| oldPainter.offset != offset
@@ -55,6 +57,7 @@ class _GesturePainter extends CustomPainter {
}
class GestureDemo extends StatefulWidget {
@override
_GestureDemoState createState() => new _GestureDemoState();
}
@@ -134,6 +137,7 @@ class _GestureDemoState extends State<GestureDemo> {
});
}
@override
Widget build(BuildContext context) {
return new Stack(
children: <Widget>[

View File

@@ -9,6 +9,7 @@ class AdaptedListItem extends StatelessWidget {
final String name;
@override
Widget build(BuildContext context) {
return new Row(
children: <Widget>[
@@ -31,6 +32,7 @@ class AdaptedGridItem extends StatelessWidget {
final String name;
@override
Widget build(BuildContext context) {
return new Card(
child: new Column(
@@ -70,6 +72,7 @@ class AdaptiveContainer extends StatelessWidget {
final List<String> names;
@override
Widget build(BuildContext context) {
if (MediaQuery.of(context).size.width < _kGridViewBreakpoint) {
return new ScrollableList(

View File

@@ -17,6 +17,7 @@ RenderBox initCircle() {
}
class SectorApp extends StatefulWidget {
@override
SectorAppState createState() => new SectorAppState();
}
@@ -147,6 +148,7 @@ class SectorAppState extends State<SectorApp> {
);
}
@override
Widget build(BuildContext context) {
return new MaterialApp(
theme: new ThemeData.light(),

View File

@@ -18,7 +18,10 @@ void addFlexChildSolidColor(RenderFlex parent, Color backgroundColor, { int flex
// Solid colour, Widget version
class Rectangle extends StatelessWidget {
Rectangle(this.color, { Key key }) : super(key: key);
final Color color;
@override
Widget build(BuildContext context) {
return new Flexible(
child: new Container(

View File

@@ -5,12 +5,14 @@
import 'package:flutter/widgets.dart';
class SpinningSquare extends StatefulWidget {
@override
_SpinningSquareState createState() => new _SpinningSquareState();
}
class _SpinningSquareState extends State<SpinningSquare> {
AnimationController _animation;
@override
void initState() {
super.initState();
// We use 3600 milliseconds instead of 1800 milliseconds because 0.0 -> 1.0
@@ -21,6 +23,7 @@ class _SpinningSquareState extends State<SpinningSquare> {
)..repeat();
}
@override
Widget build(BuildContext context) {
return new RotationTransition(
turns: _animation,

View File

@@ -58,6 +58,7 @@ Widget toStyledText(String name, String text) {
Widget toPlainText(String name, String text) => new Text(name + ":" + text);
class SpeakerSeparator extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Container(
constraints: const BoxConstraints.expand(height: 0.0),
@@ -72,10 +73,12 @@ class SpeakerSeparator extends StatelessWidget {
}
class StyledTextDemo extends StatefulWidget {
@override
_StyledTextDemoState createState() => new _StyledTextDemoState();
}
class _StyledTextDemoState extends State<StyledTextDemo> {
@override
void initState() {
super.initState();
_toText = toStyledText;
@@ -89,6 +92,7 @@ class _StyledTextDemoState extends State<StyledTextDemo> {
});
}
@override
Widget build(BuildContext context) {
List<Widget> lines = _kNameLines
.map((List<String> nameAndText) => Function.apply(_toText, nameAndText))