I need a DraggableSheet but not scrollable, so it does not require any scrollable widget inside it.
What I need is a DraggableSheet that only scrollable until it expands and not the content inside.
is there any native widget or 3rd party library for it?
Since the builder for the DraggableScrollableSheet requires you to return a Scrollable widget, you could return a ListView with NeverScrollableScrollPhysics assigned to the physics argument. Or any other widget you require that allows you to set the physics to NeverScrollableScrollPhysics
More info and code samples on the Flutter docs
More info and code samples on the NeverScrollPhysics docs
Have you try to just using a Container ?
Related
I have developed an application in Flutter Dart and used an Expanded widget in my application but wherever I used expanded widget, it destroyed my UI and converted that List into an infinite list with no data on it.
Please let me know that reason why does this occur and the potential solution.
Thank you everyone in advance
You can use the expanded widget inside the column and row. Sometimes with use of an expanded widget with the wrong widget will give the error in release mode while it is working in the debug mode.
Make sure you are using the expanded widget inside the column or row and that column and row should not be inside the scroll view or other scrollable widgets.
If still not clear then update the question with the widget hierarchy.
Lets just say I have 2 widgets on the screen, one a dynamic container that the size depends on the things that are inside that container, and the second widget would be a scrollable ListView. Ideally, I am trying to have both widget on a non scrollable screen, only having the list view to be scrollable. I have tried using a GlobalKey attached to the dynamic container, and then defining the size of the container that's holding the ListView widget with that, but it did not work. This is done on Flutter Mobile development
There are multiple ways to do this. Here is how I would do it-
To limit the height of ListView, wrap the ListView with a Container widget and set the height of the Container to the required height. To make the container cover entire space, wrap with in an Expanded widget. So this is how your widget tree would look like-
//Expanded { //Container { //ListView }}
I am new to flutter, I need to add an horizontal scroll bar as in the image, how can I go about in doing so. https://i.stack.imgur.com/rfsNB.png
you can test with a ListView, and using the property scrollDirection: Axis.horizontal.
You can get more info in this link:
https://flutter.dev/docs/cookbook/lists/horizontal-list
you can just wrap your widget with the Scrollbar() widget and it will do your job
for further information you can read the docs here
https://api.flutter.dev/flutter/material/Scrollbar-class.html
This class or widget is useful to create a responsive layout.
AspectRatio
CustomSingleChildLayout,
CustomMultiChildLayout,
FittedBox,
FractionallySizedBox,
LayoutBuilder,
MediaQuery,
MediaQueryData,
OrientationBuilder.
Which is to use the better responsive layout.
iDecode already told you that it all depends on what you need. here take a look at official documentation, https://flutter.dev/docs/development/ui/layout.
And here is my advice
Use row when you need Horizontal layout
Use column when you need Vertical layout
Use singleChildScrollView when you need scrolling layout
Use either GridView or listView when you need repetitive view
Use Expanded, Flexible, Limitedbox, flexiblebox for adjusting the size of the widget
Mine favourite : Rows for Horizontal, Column for vertical, Scrollview for Extra data exist in the page or UI not fitted in the screen, ListView for TableView UI etc
For best fitting layout: IS Expanded, AspectRatio
What are the differences between SliverList and ListView in Flutter?
There's almost no difference.
ListView is a SliverList. Same with GridView, which is a SliverGrid.
They are doing exactly the same thing. The only difference between them is that SliverList is a sliver, not a widget. Which means it's used inside a ScrollView, usually CustomScrollView.
ListView is nothing else but a biding of SliverList to transform it into a Widget to make it usable alongside other widgets such as Row/Container.
Most of the time, use ListView.
But if you want advanced scroll behavior such as appbar animations with scroll ; you'll need to use a CustomScrollView. Which will force you to use SliverList instead of ListView.
According this article,
All of the scrollable views you use, like ListView and GridView,
are actually implemented using Slivers. You can kind of think of
Slivers as a lower-level interface, providing finer-grained control on
implementing scrollable area. Because slivers can lazily build each
item just as it scrolls into view, slivers are particularly useful for
efficiently scrolling through large numbers of children.