SliverGridDelegateWithFixedCrossAxisCount class Null safety

Creates grid layouts with a fixed number of tiles in the cross axis.

For example, if the grid is vertical, this delegate will create a layout with a fixed number of columns. If the grid is horizontal, this delegate will create a layout with a fixed number of rows.

This delegate creates grids with equally sized and spaced tiles.

Here is an example using the childAspectRatio property. On a device with a screen width of 800.0, it creates a GridView with each tile with a width of 200.0 and a height of 100.0.
To create a local project with this code sample, run:
flutter create --sample=rendering.SliverGridDelegateWithFixedCrossAxisCount.1 mysample

Here is an example using the mainAxisExtent property. On a device with a screen width of 800.0, it creates a GridView with each tile with a width of 200.0 and a height of 150.0.
To create a local project with this code sample, run:
flutter create --sample=rendering.SliverGridDelegateWithFixedCrossAxisCount.2 mysample

See also:

Inheritance

Constructors

SliverGridDelegateWithFixedCrossAxisCount({required int crossAxisCount, double mainAxisSpacing, double crossAxisSpacing, double childAspectRatio, double? mainAxisExtent})
Creates a delegate that makes grid layouts with a fixed number of tiles in the cross axis. [...]
const

Properties

childAspectRatio double
The ratio of the cross-axis to the main-axis extent of each child.
final
crossAxisCount int
The number of children in the cross axis.
final
crossAxisSpacing double
The number of logical pixels between each child along the cross axis.
final
hashCode int
The hash code for this object. [...]
read-only, inherited
mainAxisExtent double?
The extent of each tile in the main axis. If provided it would define the logical pixels taken by each tile in the main-axis. [...]
final
mainAxisSpacing double
The number of logical pixels between each child along the main axis.
final
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

getLayout(SliverConstraints constraints) SliverGridLayout
Returns information about the size and position of the tiles in the grid.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
shouldRelayout(covariant SliverGridDelegateWithFixedCrossAxisCount oldDelegate) bool
Override this method to return true when the children need to be laid out. [...]
override
toString() String
A string representation of this object. [...]
inherited

Operators

operator ==(Object other) bool
The equality operator. [...]
inherited