Skip to content

Commit 73e62d3

Browse files
committed
Merge pull request flutter#779 from abarth/basic_docs
Add some dartdoc to basic widgets
2 parents 429e17c + 069fc6d commit 73e62d3

File tree

5 files changed

+298
-75
lines changed

5 files changed

+298
-75
lines changed

packages/flutter/lib/src/rendering/custom_layout.dart

+9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import 'box.dart';
66
import 'object.dart';
77

88
class MultiChildLayoutParentData extends ContainerBoxParentDataMixin<RenderBox> {
9+
/// An object representing the identity of this child.
910
Object id;
1011

1112
void merge(MultiChildLayoutParentData other) {
@@ -17,6 +18,7 @@ class MultiChildLayoutParentData extends ContainerBoxParentDataMixin<RenderBox>
1718
String toString() => '${super.toString()}; id=$id';
1819
}
1920

21+
/// A delegate that controls the layout of multiple children.
2022
abstract class MultiChildLayoutDelegate {
2123
Map<Object, RenderBox> _idToChild;
2224
Set<RenderBox> _debugChildrenNeedingLayout;
@@ -94,6 +96,12 @@ abstract class MultiChildLayoutDelegate {
9496
void performLayout(Size size, BoxConstraints constraints);
9597
}
9698

99+
/// Defers the layout of multiple children to a delegate.
100+
///
101+
/// The delegate can determine the layout constraints for each child and can
102+
/// decide where to position each child. The delegate can also determine the
103+
/// size of the parent, but the size of the parent cannot depend on the sizes of
104+
/// the children.
97105
class RenderCustomMultiChildLayoutBox extends RenderBox
98106
with ContainerRenderObjectMixin<RenderBox, MultiChildLayoutParentData>,
99107
RenderBoxContainerDefaultsMixin<RenderBox, MultiChildLayoutParentData> {
@@ -110,6 +118,7 @@ class RenderCustomMultiChildLayoutBox extends RenderBox
110118
child.parentData = new MultiChildLayoutParentData();
111119
}
112120

121+
/// The delegate that controls the layout of the children.
113122
MultiChildLayoutDelegate get delegate => _delegate;
114123
MultiChildLayoutDelegate _delegate;
115124
void set delegate (MultiChildLayoutDelegate newDelegate) {

packages/flutter/lib/src/rendering/proxy_box.dart

+51-49
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export 'package:flutter/gestures.dart' show
2121
PointerUpEvent,
2222
PointerCancelEvent;
2323

24-
/// A base class for render objects that resemble their children
24+
/// A base class for render objects that resemble their children.
2525
///
2626
/// A proxy box has a single child and simply mimics all the properties of that
2727
/// child by calling through to the child for each function in the render box
@@ -87,15 +87,16 @@ class RenderProxyBox extends RenderBox with RenderObjectWithChildMixin<RenderBox
8787
}
8888
}
8989

90-
/// A render object that imposes additional constraints on its child
90+
/// Imposes additional constraints on its child.
9191
///
9292
/// A render constrained box proxies most functions in the render box protocol
9393
/// to its child, except that when laying out its child, it tightens the
9494
/// constraints provided by its parent by enforcing the [additionalConstraints]
9595
/// as well.
9696
///
97-
/// For example, if you wanted [child] to have a minimum height, you could use
98-
/// `const BoxConstraints(minHeight: 50.0)`` as the [additionalConstraints].
97+
/// For example, if you wanted [child] to have a minimum height of 50.0 logical
98+
/// pixels, you could use `const BoxConstraints(minHeight: 50.0)`` as the
99+
/// [additionalConstraints].
99100
class RenderConstrainedBox extends RenderProxyBox {
100101
RenderConstrainedBox({
101102
RenderBox child,
@@ -260,7 +261,7 @@ class RenderFractionallySizedBox extends RenderProxyBox {
260261
}
261262
}
262263

263-
/// Forces child to layout at a specific aspect ratio
264+
/// Forces child to layout at a specific aspect ratio.
264265
///
265266
/// The width of this render object is the largest width permited by the layout
266267
/// constraints. The height of the render object is determined by applying the
@@ -284,7 +285,7 @@ class RenderAspectRatio extends RenderProxyBox {
284285
assert(_aspectRatio != null);
285286
}
286287

287-
/// The aspect ratio to use when computing the height from the width
288+
/// The aspect ratio to use when computing the height from the width.
288289
///
289290
/// The aspect ratio is expressed as a ratio of width to height. For example,
290291
/// a 16:9 width:height aspect ratio would have a value of 16.0/9.0.
@@ -329,18 +330,18 @@ class RenderAspectRatio extends RenderProxyBox {
329330
}
330331
}
331332

332-
/// Sizes its child to the child's intrinsic width
333+
/// Sizes its child to the child's intrinsic width.
333334
///
334-
/// This class will size its child's width to the child's maximum intrinsic
335-
/// width. If [stepWidth] is non-null, the child's width will be snapped to a
336-
/// multiple of the [stepWidth]. Similarly, if [stepHeight] is non-null, the
337-
/// child's height will be snapped to a multiple of the [stepHeight].
335+
/// Sizes its child's width to the child's maximum intrinsic width. If
336+
/// [stepWidth] is non-null, the child's width will be snapped to a multiple of
337+
/// the [stepWidth]. Similarly, if [stepHeight] is non-null, the child's height
338+
/// will be snapped to a multiple of the [stepHeight].
338339
///
339340
/// This class is useful, for example, when unlimited width is available and
340341
/// you would like a child that would otherwise attempt to expand infinitely to
341342
/// instead size itself to a more reasonable width.
342343
///
343-
/// Note: This class is relatively expensive. Avoid using it where possible.
344+
/// This class is relatively expensive. Avoid using it where possible.
344345
class RenderIntrinsicWidth extends RenderProxyBox {
345346

346347
RenderIntrinsicWidth({
@@ -349,7 +350,7 @@ class RenderIntrinsicWidth extends RenderProxyBox {
349350
RenderBox child
350351
}) : _stepWidth = stepWidth, _stepHeight = stepHeight, super(child);
351352

352-
/// If non-null, force the child's width to be a multiple of this value
353+
/// If non-null, force the child's width to be a multiple of this value.
353354
double get stepWidth => _stepWidth;
354355
double _stepWidth;
355356
void set stepWidth(double newStepWidth) {
@@ -359,7 +360,7 @@ class RenderIntrinsicWidth extends RenderProxyBox {
359360
markNeedsLayout();
360361
}
361362

362-
/// If non-null, force the child's height to be a multiple of this value
363+
/// If non-null, force the child's height to be a multiple of this value.
363364
double get stepHeight => _stepHeight;
364365
double _stepHeight;
365366
void set stepHeight(double newStepHeight) {
@@ -428,16 +429,13 @@ class RenderIntrinsicWidth extends RenderProxyBox {
428429
}
429430
}
430431

431-
/// Sizes its child to the child's intrinsic height
432-
///
433-
/// This class will size its child's height to the child's maximum intrinsic
434-
/// height.
432+
/// Sizes its child to the child's intrinsic height.
435433
///
436434
/// This class is useful, for example, when unlimited height is available and
437435
/// you would like a child that would otherwise attempt to expand infinitely to
438436
/// instead size itself to a more reasonable height.
439437
///
440-
/// Note: This class is relatively expensive. Avoid using it where possible.
438+
/// This class is relatively expensive. Avoid using it where possible.
441439
class RenderIntrinsicHeight extends RenderProxyBox {
442440

443441
RenderIntrinsicHeight({
@@ -486,20 +484,20 @@ class RenderIntrinsicHeight extends RenderProxyBox {
486484

487485
}
488486

489-
/// Makes its child partially transparent
487+
/// Makes its child partially transparent.
490488
///
491489
/// This class paints its child into an intermediate buffer and then blends the
492490
/// child back into the scene partially transparent.
493491
///
494-
/// Note: This class is relatively expensive because it requires painting the
495-
/// child into an intermediate buffer.
492+
/// This class is relatively expensive because it requires painting the child
493+
/// into an intermediate buffer.
496494
class RenderOpacity extends RenderProxyBox {
497495
RenderOpacity({ RenderBox child, double opacity })
498496
: this._opacity = opacity, super(child) {
499497
assert(opacity >= 0.0 && opacity <= 1.0);
500498
}
501499

502-
/// The fraction to scale the child's alpha value
500+
/// The fraction to scale the child's alpha value.
503501
///
504502
/// An opacity of 1.0 is fully opaque. An opacity of 0.0 is fully transparent
505503
/// (i.e., invisible).
@@ -566,7 +564,10 @@ class RenderShaderMask extends RenderProxyBox {
566564
}
567565
}
568566

567+
/// A class that provides custom clips.
569568
abstract class CustomClipper<T> {
569+
/// Returns a description of the clip given that the render object being
570+
/// clipped is of the given size.
570571
T getClip(Size size);
571572
bool shouldRepaint(CustomClipper oldClipper);
572573
}
@@ -577,6 +578,7 @@ abstract class _RenderCustomClip<T> extends RenderProxyBox {
577578
CustomClipper<T> clipper
578579
}) : _clipper = clipper, super(child);
579580

581+
/// If non-null, determines which clip to use on the child.
580582
CustomClipper<T> get clipper => _clipper;
581583
CustomClipper<T> _clipper;
582584
void set clipper (CustomClipper<T> newClipper) {
@@ -598,7 +600,7 @@ abstract class _RenderCustomClip<T> extends RenderProxyBox {
598600
T get _clip => _clipper?.getClip(size) ?? _defaultClip;
599601
}
600602

601-
/// Clips its child using a rectangle
603+
/// Clips its child using a rectangle.
602604
///
603605
/// Prevents its child from painting outside its bounds.
604606
class RenderClipRect extends _RenderCustomClip<Rect> {
@@ -624,7 +626,7 @@ class RenderClipRect extends _RenderCustomClip<Rect> {
624626
}
625627
}
626628

627-
/// Clips its child using a rounded rectangle
629+
/// Clips its child using a rounded rectangle.
628630
///
629631
/// Creates a rounded rectangle from its layout dimensions and the given x and
630632
/// y radius values and prevents its child from painting outside that rounded
@@ -639,7 +641,7 @@ class RenderClipRRect extends RenderProxyBox {
639641
assert(_yRadius != null);
640642
}
641643

642-
/// The radius of the rounded corners in the horizontal direction in logical pixels
644+
/// The radius of the rounded corners in the horizontal direction in logical pixels.
643645
///
644646
/// Values are clamped to be between zero and half the width of the render
645647
/// object.
@@ -653,7 +655,7 @@ class RenderClipRRect extends RenderProxyBox {
653655
markNeedsPaint();
654656
}
655657

656-
/// The radius of the rounded corners in the vertical direction in logical pixels
658+
/// The radius of the rounded corners in the vertical direction in logical pixels.
657659
///
658660
/// Values are clamped to be between zero and half the height of the render
659661
/// object.
@@ -676,7 +678,7 @@ class RenderClipRRect extends RenderProxyBox {
676678
}
677679
}
678680

679-
/// Clips its child using an oval
681+
/// Clips its child using an oval.
680682
///
681683
/// Inscribes an oval into its layout dimensions and prevents its child from
682684
/// painting outside that oval.
@@ -717,16 +719,16 @@ class RenderClipOval extends _RenderCustomClip<Rect> {
717719
}
718720
}
719721

720-
/// Where to paint a box decoration
722+
/// Where to paint a box decoration.
721723
enum BoxDecorationPosition {
722-
/// Paint the box decoration behind the children
724+
/// Paint the box decoration behind the children.
723725
background,
724726

725-
/// Paint the box decoration in front of the children
727+
/// Paint the box decoration in front of the children.
726728
foreground,
727729
}
728730

729-
/// Paints a [BoxDecoration] either before or after its child paints
731+
/// Paints a [BoxDecoration] either before or after its child paints.
730732
class RenderDecoratedBox extends RenderProxyBox {
731733

732734
RenderDecoratedBox({
@@ -740,7 +742,7 @@ class RenderDecoratedBox extends RenderProxyBox {
740742
assert(position != null);
741743
}
742744

743-
/// Where to paint the box decoration
745+
/// Where to paint the box decoration.
744746
BoxDecorationPosition get position => _position;
745747
BoxDecorationPosition _position;
746748
void set position (BoxDecorationPosition newPosition) {
@@ -750,7 +752,7 @@ class RenderDecoratedBox extends RenderProxyBox {
750752
markNeedsPaint();
751753
}
752754

753-
/// What decoration to paint
755+
/// What decoration to paint.
754756
BoxDecoration get decoration => _painter.decoration;
755757
void set decoration (BoxDecoration newDecoration) {
756758
assert(newDecoration != null);
@@ -820,7 +822,7 @@ class RenderDecoratedBox extends RenderProxyBox {
820822
}
821823
}
822824

823-
/// Applies a transformation before painting its child
825+
/// Applies a transformation before painting its child.
824826
class RenderTransform extends RenderProxyBox {
825827
RenderTransform({
826828
Matrix4 transform,
@@ -836,7 +838,7 @@ class RenderTransform extends RenderProxyBox {
836838
}
837839

838840
/// The origin of the coordinate system (relative to the upper left corder of
839-
/// this render object) in which to apply the matrix
841+
/// this render object) in which to apply the matrix.
840842
///
841843
/// Setting an origin is equivalent to conjugating the transform matrix by a
842844
/// translation. This property is provided just for convenience.
@@ -866,7 +868,7 @@ class RenderTransform extends RenderProxyBox {
866868
// Note the lack of a getter for transform because Matrix4 is not immutable
867869
Matrix4 _transform;
868870

869-
/// The matrix to transform the child by during painting
871+
/// The matrix to transform the child by during painting.
870872
void set transform(Matrix4 newTransform) {
871873
assert(newTransform != null);
872874
if (_transform == newTransform)
@@ -875,37 +877,37 @@ class RenderTransform extends RenderProxyBox {
875877
markNeedsPaint();
876878
}
877879

878-
/// Sets the transform to the identity matrix
880+
/// Sets the transform to the identity matrix.
879881
void setIdentity() {
880882
_transform.setIdentity();
881883
markNeedsPaint();
882884
}
883885

884-
/// Concatenates a rotation about the x axis into the transform
886+
/// Concatenates a rotation about the x axis into the transform.
885887
void rotateX(double radians) {
886888
_transform.rotateX(radians);
887889
markNeedsPaint();
888890
}
889891

890-
/// Concatenates a rotation about the y axis into the transform
892+
/// Concatenates a rotation about the y axis into the transform.
891893
void rotateY(double radians) {
892894
_transform.rotateY(radians);
893895
markNeedsPaint();
894896
}
895897

896-
/// Concatenates a rotation about the z axis into the transform
898+
/// Concatenates a rotation about the z axis into the transform.
897899
void rotateZ(double radians) {
898900
_transform.rotateZ(radians);
899901
markNeedsPaint();
900902
}
901903

902-
/// Concatenates a translation by (x, y, z) into the transform
904+
/// Concatenates a translation by (x, y, z) into the transform.
903905
void translate(x, [double y = 0.0, double z = 0.0]) {
904906
_transform.translate(x, y, z);
905907
markNeedsPaint();
906908
}
907909

908-
/// Concatenates a scale into the transform
910+
/// Concatenates a scale into the transform.
909911
void scale(x, [double y, double z]) {
910912
_transform.scale(x, y, z);
911913
markNeedsPaint();
@@ -963,13 +965,13 @@ class RenderTransform extends RenderProxyBox {
963965
}
964966
}
965967

966-
/// Called when a size changes
968+
/// Called when a size changes.
967969
typedef void SizeChangedCallback(Size newSize);
968970

969971
/// Calls [onSizeChanged] whenever the child's layout size changes
970972
///
971-
/// Note: Size observer calls its callback during layout, which means you cannot
972-
/// dirty layout information during the callback.
973+
/// Because size observer calls its callback during layout, you cannot modify
974+
/// layout information during the callback.
973975
class RenderSizeObserver extends RenderProxyBox {
974976
RenderSizeObserver({
975977
this.onSizeChanged,
@@ -1007,13 +1009,13 @@ abstract class CustomPainter {
10071009
/// current canvas and then paints its children. After painting its children,
10081010
/// custom paint asks foregroundPainter to paint. The coodinate system of the
10091011
/// canvas matches the coordinate system of the custom paint object. The
1010-
/// painters are expected to paint with in a rectangle starting at the origin
1012+
/// painters are expected to paint within a rectangle starting at the origin
10111013
/// and encompassing a region of the given size. If the painters paints outside
10121014
/// those bounds, there might be insufficient memory allocated to rasterize the
10131015
/// painting commands and the resulting behavior is undefined.
10141016
///
1015-
/// Note: Custom paint calls its painters during paint, which means you cannot
1016-
/// dirty layout or paint information during the callback.
1017+
/// Because custom paint calls its painters during paint, you cannot dirty
1018+
/// layout or paint information during the callback.
10171019
class RenderCustomPaint extends RenderProxyBox {
10181020
RenderCustomPaint({
10191021
CustomPainter painter,

0 commit comments

Comments
 (0)