Commit f5a6c432 authored by Adam Barth's avatar Adam Barth Committed by GitHub

Add docs for RenderSliverGrid (#8737)

Most of these docs were already in place, but this patch adds the remaining
missing ones.
parent b10e60bc
...@@ -227,6 +227,12 @@ abstract class SliverGridDelegate { ...@@ -227,6 +227,12 @@ abstract class SliverGridDelegate {
/// Returns information about the size and position of the tiles in the grid. /// Returns information about the size and position of the tiles in the grid.
SliverGridLayout getLayout(SliverConstraints constraints); SliverGridLayout getLayout(SliverConstraints constraints);
/// Override this method to return true when the children need to be
/// laid out.
///
/// This should compare the fields of the current delegate and the given
/// `oldDelegate` and return true if the fields are such that the layout would
/// be different.
bool shouldRelayout(covariant SliverGridDelegate oldDelegate); bool shouldRelayout(covariant SliverGridDelegate oldDelegate);
} }
...@@ -401,20 +407,44 @@ class SliverGridDelegateWithMaxCrossAxisExtent extends SliverGridDelegate { ...@@ -401,20 +407,44 @@ class SliverGridDelegateWithMaxCrossAxisExtent extends SliverGridDelegate {
} }
} }
/// Parent data structure used by [RenderSliverGrid].
class SliverGridParentData extends SliverMultiBoxAdaptorParentData { class SliverGridParentData extends SliverMultiBoxAdaptorParentData {
/// The offset of the child in the non-scrolling axis.
///
/// If the scroll axis is vertical, this offset is from the left-most edge of
/// the parent to the left-most edge of the child. If the scroll axis is
/// horizontal, this offset is from the top-most edge of the parent to the
/// top-most edge of the child.
double crossAxisOffset; double crossAxisOffset;
@override @override
String toString() => 'crossAxisOffset=$crossAxisOffset; ${super.toString()}'; String toString() => 'crossAxisOffset=$crossAxisOffset; ${super.toString()}';
} }
/// A sliver that contains multiple box children that whose size and position
/// are determined by a delegate.
///
/// [RenderSliverGrid] places its children in arbitrary positions determined by
/// [gridDelegate]. Each child is forced to have the size specified by the
/// [gridDelegate].
///
/// See also:
///
/// * [RenderSliverList], which places its children in a linear
/// array.
/// * [RenderSliverFixedExtentList], which places its children in a linear
/// array with a fixed extent in the main axis.
class RenderSliverGrid extends RenderSliverMultiBoxAdaptor { class RenderSliverGrid extends RenderSliverMultiBoxAdaptor {
/// Creates a sliver that contains multiple box children that whose size and
/// position are determined by a delegate.
///
/// The [childManager] and [gridDelegate] arguments must not be null.
RenderSliverGrid({ RenderSliverGrid({
@required RenderSliverBoxChildManager childManager, @required RenderSliverBoxChildManager childManager,
@required SliverGridDelegate gridDelegate, @required SliverGridDelegate gridDelegate,
}) : _gridDelegate = gridDelegate, }) : _gridDelegate = gridDelegate,
super(childManager: childManager) { super(childManager: childManager) {
gridDelegate != null; assert(gridDelegate != null);
} }
@override @override
...@@ -423,9 +453,9 @@ class RenderSliverGrid extends RenderSliverMultiBoxAdaptor { ...@@ -423,9 +453,9 @@ class RenderSliverGrid extends RenderSliverMultiBoxAdaptor {
child.parentData = new SliverGridParentData(); child.parentData = new SliverGridParentData();
} }
/// The delegate that controls the size and position of the children.
SliverGridDelegate get gridDelegate => _gridDelegate; SliverGridDelegate get gridDelegate => _gridDelegate;
SliverGridDelegate _gridDelegate; SliverGridDelegate _gridDelegate;
set gridDelegate(SliverGridDelegate value) { set gridDelegate(SliverGridDelegate value) {
assert(value != null); assert(value != null);
if (_gridDelegate == value) if (_gridDelegate == value)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment