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));
}
Related
These boxes will basically be images of unknown resolutions. I want them to fit in such wrap structure that they are put one by one from left to right, but if there's more space in right column then the image should be placed in the right column instead of the left one.
I was wondering if this is possible with "wrap" widget, I tried it and couldn't get it to work without having to set a fixed height and wrap alignment to vertical. But I can't have a fixed height because there will be unknown number of images.
If nothing works, I will have to have a custom solution using columns or rows and I can do that but I just want to know if there's a simpler way to do this. Thank you in advance!
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
I am trying to put a dot between the labels, but only only between each item in each "row". There will be 8 dots total. each line shouldn't start or end with a dot. Any thoughts on how to do this?
Edit:
I want to give a list of widgets as a parameter. I do not know the height or width of the widgets that will be passed in. Creating this with a row is tricky, because I have to have some kind of logic that determines if there will be enough space for the widget before going to the next row.
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.
I'm trying to produce a widget like this below to be contained inside of a listview. I have managed an effect like this rather simply based on the example given on the flutter website for YouTube. However, the part I'm struggling with is that I would like the image to resize vertically depending on how large the text is.
Currently this is created with a row. If possible I'd like to set the row height somehow but only dependent on the height of the text. As some elements will have more text and some will have less I would like to have the image fill the vertical space so the height is the same as the text height.
I basically want this - https://api.flutter.dev/flutter/material/ListTile-class.html#material.ListTile.4
but where the image height on the left matches the text height on the right
Thanks in advance!