How can I create an infinte grid in flutter?

Viewed 208

I want to create a grid with large number of cells. On screen not all cells should be shown, but only some cells at the center of the screen. Just like the app Desmos. It should be possible to scroll from any direction in the app.

// THE PROBLEM IS WITH THE NEXT LINE , AS I DON'T THINK I CAN USE double.infinity.toInt() FOR INFINITE //NUMBER OF CELLS. AND EVEN IF IT WORKS HOW CAN I SET THE NUMBER OF CELLS IN A VERTICAL COLUMN TO  //INFINITE OR ANY LARGE NUMBER.
GridView.count(crossAxisCount: double.infinity.toInt()),
.....
//Here is the code that will define the 4 Coordinates for each cell.
),
1 Answers

GridView.count creates a scrollable, 2D array of widgets with a fixed number of tiles in the cross axis.

What you need to use is some other GridView constructor like GridView.builder.

https://api.flutter.dev/flutter/widgets/GridView/GridView.builder.html

Creates a scrollable, 2D array of widgets that are created on demand.

This constructor is appropriate for grid views with a large (or infinite) number of children because the builder is called only for those children that are actually visible.

Related