AdaptiveResponsiveGrid class
A grid whose column count follows the width it is given.
The caller states the smallest acceptable width for one cell (minChildWidth); the widget fits as many columns as that allows. This is how a phone shows one or two cards per row and a tablet in landscape shows four, from a single call site.
AdaptiveResponsiveGrid(
minChildWidth: 180,
children: <Widget>[for (final Product p in products) ProductCard(p)],
)
More columns, not bigger text
Extra width buys extra cells. It never buys a larger fontSize: the text
inside a cell keeps the size the user asked for, from AdaptiveTypography
and the platform's accessibility setting. A grid that also inflated its
type would break both design languages at once.
Measures its box, not the window
Column count comes from a LayoutBuilder, so the grid is correct inside a
detail pane, an iPad Slide Over window or a dialog — places where the
window width reported by MediaQuery is far wider than the space actually
available.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- AdaptiveResponsiveGrid
Constructors
Properties
- childAspectRatio → double
-
Width-to-height ratio of a cell, forwarded to GridView.count.
final
-
children
→ List<
Widget> -
The cells, laid out in order, left to right then top to bottom.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- maxColumns → int
-
Hard ceiling on the column count.
final
- minChildWidth → double
-
Smallest width one cell may take, in logical pixels.
final
- padding → EdgeInsets?
-
Padding around the grid, excluded from the width used to count columns.
final
- runSpacing → double?
-
Vertical gap between rows. Defaults to spacing.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scrollable → bool
-
Whether the grid scrolls on its own.
final
- spacing → double
-
Horizontal gap between columns.
final
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
override
-
createElement(
) → StatelessElement -
Creates a StatelessElement to manage this widget's location in the tree.
inherited
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited