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

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

Related

Flutter expand/collapse container without overflow error

Does anybody have a clue how to achieve expand/collapse animation for a given Container widget?
I tried to use ExpandablePanel but it is not what I really want, because I want to render a Column within a Container, and if the Container is collapsed I want to show only 150px from it, otherwise it should have the height of the content.
Clicking on the arrow the Container should toggle it's state.
Below are some images which represents the goal:
Collapsed
Expanded
The overflow error is thrown because when the column is collapsed there is no room to contain all the children inside the column.
What do we do when we have a column with children's height larger than the screen height? We use scrolling!
So you can wrap your column with SingleChildScrollView widget to make the column scrollable, so when it collapses it doesn't complain about the children's height, instead, the scrolling functionality handles them because you can scroll in a column even if it has very small width.

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

Flutter: dynamic bottom sheet height to fit content

I am trying to create a bottom sheet that resizes according to the content inside it. Only thing I found regarding bottom sheet's height is how to make it a fixed amount, but I would like to fit the content anytime it changes.

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

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

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.