From 57ee52636b1ed3203d5db71898330b964409d633 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Mon, 6 Feb 2017 10:30:49 -0800 Subject: [PATCH] Remove old-style grid widgets (#7898) These widget don't have any clients anymore. Consider using GridView instead. --- packages/flutter/lib/src/widgets/basic.dart | 153 -------------------- 1 file changed, 153 deletions(-) diff --git a/packages/flutter/lib/src/widgets/basic.dart b/packages/flutter/lib/src/widgets/basic.dart index 26e4ffa5ae..22fdcfb0fe 100644 --- a/packages/flutter/lib/src/widgets/basic.dart +++ b/packages/flutter/lib/src/widgets/basic.dart @@ -1784,159 +1784,6 @@ class Positioned extends ParentDataWidget { } } -/// 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 children: const [], - }) : 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 children: const [], - }) : 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 children: const [], - }) : 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 extends ParentDataWidget { - /// 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 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