Commit 57ee5263 authored by Adam Barth's avatar Adam Barth Committed by GitHub

Remove old-style grid widgets (#7898)

These widget don't have any clients anymore. Consider using GridView instead.
parent b6aec82e
......@@ -1784,159 +1784,6 @@ class Positioned extends ParentDataWidget<Stack> {
}
}
/// A [MultiChildRenderObjectWidget] for use with [RenderGrid].
///
/// Typically not used directly. Instead, consider using one of its subclasses,
/// such as:
///
/// * [FixedColumnCountGrid] (which creates a grid with a fixed number of columns)
/// * [CustomGrid] (which lets you supply your own [GridDelegate])
abstract class GridRenderObjectWidget extends MultiChildRenderObjectWidget {
/// Initializes fields for subclasses.
GridRenderObjectWidget({
Key key,
List<Widget> children: const <Widget>[],
}) : super(key: key, children: children) {
_delegate = createDelegate();
}
GridDelegate _delegate;
/// The delegate that controls the layout of the children.
GridDelegate createDelegate();
@override
RenderGrid createRenderObject(BuildContext context) => new RenderGrid(delegate: _delegate);
@override
void updateRenderObject(BuildContext context, RenderGrid renderObject) {
renderObject.delegate = _delegate;
}
}
/// A widget that creates a grid using a custom [delegate].
///
/// For details about the grid layout algorithm, see [RenderGrid].
///
/// To pass data to your delegate's [GridDelegate.getChildPlacement] function,
/// consider using [GridPlacementData].
class CustomGrid extends GridRenderObjectWidget {
/// Creates a grid with a custom [delegate].
///
/// The [delegate] argument must not be null.
CustomGrid({
Key key,
@required this.delegate,
List<Widget> children: const <Widget>[],
}) : super(key: key, children: children) {
assert(delegate != null);
}
/// The delegate that controls the layout of the children.
///
/// For example, a [FixedColumnCountGridDelegate] for grids that have a fixed
/// number of columns or a [MaxTileWidthGridDelegate] for grids that have a
/// maximum tile width.
final GridDelegate delegate;
@override
GridDelegate createDelegate() => delegate;
}
/// A widget that uses a grid layout with a fixed column count.
///
/// For details about the grid layout algorithm, see [FixedColumnCountGridDelegate].
class FixedColumnCountGrid extends GridRenderObjectWidget {
/// Creates a grid with a fixed number of columns.
///
/// The [columnCount] argument must not be negative.
FixedColumnCountGrid({
Key key,
@required this.columnCount,
this.columnSpacing: 0.0,
this.rowSpacing: 0.0,
this.tileAspectRatio: 1.0,
this.padding: EdgeInsets.zero,
List<Widget> children: const <Widget>[],
}) : super(key: key, children: children) {
assert(columnCount != null && columnCount >= 0);
assert(tileAspectRatio != null && tileAspectRatio > 0.0);
}
/// The number of columns in the grid.
final int columnCount;
/// The horizontal distance between columns.
final double columnSpacing;
/// The vertical distance between rows.
final double rowSpacing;
/// The ratio of the width to the height of each tile in the grid.
final double tileAspectRatio;
/// The amount of padding to apply to each child.
final EdgeInsets padding;
@override
FixedColumnCountGridDelegate createDelegate() {
return new FixedColumnCountGridDelegate(
columnCount: columnCount,
columnSpacing: columnSpacing,
rowSpacing: rowSpacing,
tileAspectRatio: tileAspectRatio,
padding: padding
);
}
}
/// A widget that controls the placement of a child in a grid.
///
/// The [placementData] this widget associates with the child is interpreted by
/// the grid's [GridDelegate] in its [GridDelegate.getChildPlacement] function.
/// During layout, the grid calls the delegate's
/// [GridDelegate.getChildPlacement] function for each child, passing the
/// [placementData] associated with that child as context. The return value of
/// [GridDelegate.getChildPlacement] is then used to determine the size and
/// position of that child within the grid.
///
/// A [GridPlacementData] widget must be a descendant of a
/// [GridRenderObjectWidget], and the path from the [GridPlacementData] widget
/// to its enclosing [GridRenderObjectWidget] must contain only
/// [StatelessWidget]s or [StatefulWidget]s (not other kinds of widgets, like
/// [RenderObjectWidget]s).
class GridPlacementData<DataType> extends ParentDataWidget<GridRenderObjectWidget> {
/// Creates a widget that controls placement of a child in a grid.
///
/// The [placementData] and [child] arguments are required.
GridPlacementData({
Key key,
@required this.placementData,
@required Widget child
}) : super(key: key, child: child);
/// Opaque data passed to the getChildPlacement method of the grid's [GridDelegate].
final DataType placementData;
@override
void applyParentData(RenderObject renderObject) {
assert(renderObject.parentData is GridParentData);
final GridParentData parentData = renderObject.parentData;
if (parentData.placementData != placementData) {
parentData.placementData = placementData;
AbstractNode targetParent = renderObject.parent;
if (targetParent is RenderObject)
targetParent.markNeedsLayout();
}
}
@override
void debugFillDescription(List<String> description) {
super.debugFillDescription(description);
description.add('placementData: $placementData');
}
}
/// A widget that displays its children in a one-dimensional array.
///
/// The [Flex] widget allows you to control the axis along which the children are
......
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