flutter gridView child height is fixed, add other widget cannot show? - flutter

here:
below the picture there is an inline text, but it is not visible. Maybe be the picture's height takes up the whole height? Any idea?

You are using GridView.builder. Instead you can use GridView.count.
In GridView.count, there is a parameter childAspectRatio which you can use to increase the height of the grid.

Related

Flutter grid with different size

how to create grid. My issue is that I want to display widget in my grid view and each one of these widgets has its own content and can have different width, I am facing trouble with achieving that…
GridView, Wrap, ListView, Rows + Columns, Stack.
You can use Wrap widget. Also check flutter_staggered_grid_view package.

GridView's shrinkWrap not shrink as small as possible in flutter?

I create a GridView in flutter with the shrinkWrap set to true (which I expect the GridView will be shrink exactly as the content's size).
But in my demo (Green background color indicates GridView , and the Red Color indicates the content widgets in the GridView)
I found that , the GridView will not shrink as small as possible to it's contents. The GridView's height is a bit larger than the GridView's content height .
What makes the GridView not shrink as small as possible?
OK, after debugging with the source code . I found the reason to this problem:
Seems when you create a ListView & GridView with a null padding passing to it . Flutter SDK will make a Inset (RenderSliverPadding)during the layout of the ListView&GridView.
So the way to remove this padding is set a padding in the ListView&GridView's constructor

Make scroll responsive to size of column in flutter

I have a screen with a column in flutter which is basically a form. At first i had trouble with the fact that the pop-up keyboard reduced the visible space and thus had an overflow. Fixed that adding the SingleChildScrollView and setting a container as a parent with an specific height (based on devicequery size).
Unfortunately, when I test the rotated screen, i get the same problem. Is there a way to set the height of the container which controls the SingleChildScrollView so that it adjusts to the total size occupied by the column widgets?
Please add Listview instead of Colum Widget.
in your scaffold
set resizeToAvoidBottomInset to false or add it
resizeToAvoidBottomInset:false

How to constrain the width of GridView with a Scrollbar in Flutter?

I am trying to display a scrollbar on the right-hand side of a ScrollView (a GridView in this case) but constraining the width of the scrollable area while still displaying a scrollbar on the right-hand side. I can't see how to customize the position of the scrollbar relative to the Scrollable
See this DartPad for an example.
In the example above, the ScrollBar is displayed directly to the right hand side of the GridView's children, but I would prefer to have it all the way to the right. I can't find any affordances in the GridView constructor to help me with this. Does this require a CustomScrollView or can this be achieved with a normal GridView?
It is necessary that this GridView to have exactly 400px in width? If this is not necessary you can set the width of your ConstrainedBox like:
width: MediaQuery.of(context).size.width,
Then the GridView will have the exact size as your screen, so in consequence th scroll bar will be where you want it to be.
The fix was to swap the Center and Scrollbar widgets.
Before:
Center
Scrollbar
ConstrainedBox
After:
Scrollbar
Center
ConstrainedBox
https://dartpad.dev/09ddf64d254b0c331920cf970acc4447

How to set flutter bottom sheet height fit with inner content?

how to control flutter bottom sheet height with its inner content without fixed height? totally I just want a height change with its inner content size
Use a ConstrainedBox give a minimum and maximum height and width as you need and the child of the ConsrainedBox should be your bottom sheet container and you are good to go.
Here is the youtube link on ConstrainedBox.
Here is more how you can deal with box constraints: https://flutter.dev/docs/development/ui/layout/box-constraints