Building page with ListView and ExpansionTile - flutter

I have problem building one page with ListView and ExpansionTile.
I have DefaultTabController page, in one tab page I represent list of items.
When you reach end of this list there should be ExpansionTile, and when it openes it should appear another items list. Everything should be scroll-able and without height limitation (if it is possible).
Something like that:
Container(
child: Column(
children: [
Scrollbar(child: ListView.builder()),
ExpansionTile(children: [Scrollbar(child: ListView.builder())]
]
)
);
I have tried use Expanded Widget but received only errors. The main idea is for the page to be fully filled with items, and when reach the end, expand to another list and continue scrolling.

Related

Flutter - Floating Button inside a popup widget overlaying the scroll

Im working on my first flutter app so i am still learning possible widgets and how they react in certain structures.
So far I was doing well but cant figure out one thing I want to do.
I want to get a floating button inside of my cupertinopopusurface widget like this.
My structure is similar, on the home screen I have a listview builder that builds my cards and when you press on each one it opens a cupertinopopupsurface.
Inside I also built a Single child scroll view structure for all my contant and its scrollable but I would to get a button that overlays it all and is in a fixed placed.
My structure currently is
CupertinoPopupSurface/
Container/
SingleChildScrollView/
Column/
Children/
Row/ (all rows now with content)
I cant get the button fixed somewhere in the structure but then it follows the scrolling its now fixed overlaying the contant.
You can use stack widget inside cupertinopopupsurface like this:
CupertinoPopupSurface(
child: Stack(
children:[
your SingleChildScrollView,
Positioned(left: 16, right: 16, bottom: 16,child: yourbutton),
]
)
)

Combine multiple ListView scroll as one in flutter

I have a simple ListView with a scrollable child, which works as it should. But the issue is, when I scroll the items of ScrollableChild and it reaches its last child, it doesn't scroll the parent ListView. How can I achieve this behaviour?
ListView(children: [
...items(5),
ScrollableChild(),
...items(30),
])
I have tried to use the NestedScrollableWidget but unable to find any working solution.
Sample Code
I've tried to use the CustomScrollView, but unfortunately, the result is the same.
CustomScrollView(slivers: [
SliverList(delegate: SliverChildListDelegate(items(5))),
SliverToBoxAdapter(child: ScrollableChild()),
SliverList(delegate: SliverChildListDelegate(items(50))),
]),
Sample Code
The expected behavior can be viewed in this [Video].
the code I have shared works fine in a browser without any issue if you scroll it using the mouse wheel only.
When the blue child items scroll reaches at the end. it just scrolls the parent, that's what I am looking for.

Automatically scrolling to bottom of ListView in flutter

I have been searching for a way to scroll to the bottom of the ListView widget automatically after retrieving data from firebase database. I have seen a number of solutions but they do not work for me.
I find that scrollController.postion.maxScrollExtent is always 0.0. I don't want to use the reverse property of the listView either as that doesn't give me exactly what I want even though very close.
Below is a snippet of the code. When I use chatController.position.maxScrollExtent the value is 0.0 and not the value of the size of the ListView. If I use a listener that listens to scrolls then I see the value of chatController.position.maxScrollExtent but that is not the behaviour I want. I don't want to manually initiate a scroll for the app then go to the bottom of the list. It must do that as I open the app.
Any help will be greatly appreciated. Thanks
Container(
child: Column(
children: <Widget>[
Expanded(
child: ListView(
controller: chatController,
//shrinkWrap: true,
children: [getConversation()], //list of chats wrapped in a Column widget
)
),
)

Make a part of the screen scrollable in Flutter

I want to only make a part of my screen scrollable. When the number of items in my ListView exceeds 4 or 5 I am unable to place any widgets below this list view. I am not sure if there is a way to wrap all the contents of the listview to make that scrollable.
ListView(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
children: _getListings(businessListing),
),
This is my ListView and this is how the UI looks
The problem is when the number of RadioTile exceeds 8; the textField and the Button are pushed out of the screen.
I am wondering if it is good to make the entire screen scrollable?
Or make only a part of the screen containing the RadioTiles Scrollable?
Thanks,
To complete thebuggycoder answer if you want to keep only a part of your screen scrollable but keep variable height bottom elements, you can embed your ListView inside the Expanded of a Column, as shown below:
Column(
children: [
Expanded(
child: ListView(
children: _getListings(businessListing),
),
),
Container(
child: Text('This element must stay at the bottom'),
),
],
);
What are you doing there is basically telling your Column that it has 2 (or more) elements where each element usually takes the space it needs, except elements that are Expanded elements and will take "the maximum space left" in the Column.
There are a couple of points to consider:
If you plan to have more fields below the RadioTiles along with the Google Listing URL and the Save button, then it might be a good option to keep the entire screen scrollable.
On the other hand, if it's going to be just the two things below the RadioTiles, then it would be better to keep only the RadioTile list to be scrollable. This way the TextField and the Save button will always be accessible to the user without the need to scroll.
Also, you can decide about the scrolling depending on the priority of the fields. If the TextField and Save button have more priority then it would be best if they are always visible on the screen.
To make only a part of the screen scrollable, you can wrap the ListView in a Container with some fixed height, so that the it will scroll only within those bounds.
You will also need to change the physics property to AlwaysScrollableScrollPhysics().
Example -
Container(
height: 300.0 //Your custom height
child: ListView(
shrinkWrap: true,
physics: AlwaysScrollableScrollPhysics(),
children: _getListings(businessListing),
),
)

Fix widget in bottom space

I need some help with a layout.
I need put some widgets inside a "Scrollview" but keep the buttoms in the bottom space of screen.
Image with a "Scrollview" with some textFields inside, and under de "Scrollview" a Rows containing two buttons
So if I change orientation the Layout will keep buttons at bottom and will scroll the widgets above.
How can I made it in flutter, I tried to use the Stack, Listview and others approaches, but i didn't have luck
Multiple ways. I recommend you either using a Scaffold or a Column:
If you are already using a Scaffold in your app, just add bottomNavigatorBar as a Parameter, your bar you want to have at the bottom in it and make sure the rest of your layout is located under it's body tag.
Otherwise you could use a Column:
Column(
children: <Widget> [
Expanded(child:ScrollView(..),),
yourBottomBar,
] )
Or Flutter also has a Positioned widget which you can use in combination with a Stack:
Stack(
children: [
// some stuff
Positioned(
bottom: 0,
child: yourBottomBar
),
],
)