How can I create an infinte grid in flutter? - flutter

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.
),

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

Resizing Panels in proportion to form

I am developing a Delphi game for my (grade 10) PAT.
I am using an image as a grid for my game and placing individual panels in each grid because I do not know how to use string grids as it's my first year with Delphi. When I place the panels perfectly in each grid of the image and run my code everything looks normal until I go full screen,then all the panels are in each grid but the size is not in proportion with the image as I placed it before.
A solution would be much appreciated.
Thanks in advance.
Use a TGridPanel in place of your image. Each panel goes into one cell of the grid, and with the column widths and row heights set as a percentage (which is the default), and both the grid and the panels in the grid having Align set to alClient, the cells, and therefore the panels, will adjust their size proportional to the entire form.

trouble with fixing elements in row in flutter

look at the pic
I don't want elements to change their positions especially in horizontal axis when their strings changed
I mean it should be like a table with fixed columns.
can I do this just with row?
It's probably because you set a defined width for spacing.
You could use a combination of Flexible & Expanded widgets to wrap all the children in your Row.
That should align them correctly.
You can find the corresponding code here

Flutter: Differences between SliverList and SliverFixedExtentList

What are the differences between SliverList and SliverFixedExtentList in Flutter?
According to the documentation of each widget:
SliverList: "A sliver that places multiple box children in a linear array along the main axis."
SliverFixedExtentList: "A sliver that places multiple box children with the same main axis extent in a linear array."
It seems that we should use SliverFixedExtentList over SliverList if all children have the same main axis extent. However, what does "same main axis extent" really mean?
It means all children have the same height. If you are familiar with ListView, it has itemExtent property that does the same thing.
Essentially, if you cannot guarantee all list items will have "equal size on the main axis" (e.g. equal height on a vertical scrolling list, or equal width on a horizontal scrolling list), then we cannot know the "exact size" of each item in the list, until we load it. However, if you can guarantee that they will all have the same size, for example, 100 units in height, then we don't need to load each item to measure its size.
Knowing item size before loading them is very useful when you want to jump a large distance. For example, if you want to scroll 10,000 px down, and if we know each item is fixed at 200 px tall, then we can easily jump 50 items, just load the 51th item and display it. If we don't know that (if you cannot guarantee that) then we will have to literally lay out all items in-between to see where 10,000 px will land us.

GridView.count vs GridView.builder Difference In Flutter

What is the difference between gridview.builder and gridview.count in Flutter?
Like any other .builder GridView.builder create Widgets on demand.
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.
But GridView.count allows to directly have crossAxisCount that use to count item on single row. Full Grandview will follow this pattern.
Creates a scrollable, 2D array of widgets with a fixed number of tiles in the cross axis.
When you have the large number of widgets, consider using GridView.builder to get better performance. Also, using gridDelegate gives you more controls over UI.
You can explore GridView.

How to draw vertical lines of different heights in flutter?

I have an array of integers and for each element of that array , I Want to draw a vertical line on screen of that height.How can I implement this using flutter? Below is the structure that I want but with different heights.
I got an idea, Try mapping the list,then Use this
Row(children:your_intger_list.map((val)=>_widget(height)).toList());
Widget _widget(int height){
return Container(height:height,width:20,decoration:BoxDecoration(color:Colors.black));
}