How can I create an infinte grid in flutter?

181

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.

Share:
181
Mayur Agarwal
Author by

Mayur Agarwal

Updated on December 23, 2022

Comments

  • Mayur Agarwal
    Mayur Agarwal over 1 year

    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.
    ),
    
  • Mayur Agarwal
    Mayur Agarwal over 3 years
    Can I create an infinite grid or a grid with large number of cells ? As I need to make a grid graph and focus the screen on the center of he graph. :)