flutter make widget collapse when scroll - flutter

I want to make a container collapse (disappear) when scroll down, and expand (appear again) when scroll up. Just like the search bar in microsoft teams mobile.
I tried to do it using SliverAppBar and it worked but the ListView became lagging and had problems. Is there any way to do it without SliverAppBar?

I think you should only replace AppBar Widget with SliverAppBar
hope I could help.

You may check this library hidable

Related

PageView scroll under SliverAppBar

In material 3 the AppBar changes elevation and color when there is something scrolled under it.
It works fine using CustomScrollView with a SliverList or ListView scrolling under a SliverAppBar.
The issue is when I try to use PageView instead. It works fine using a SliverFillRemaining over the PageView but the appBar won’t notice when the page is scrolled.
I tried many ways, using NestedScrollView and CustomScrollView with no success.
The only way I could achieve that was using the PageView onPageChanged to check the page and calling back the setState of my homePage to change the color and elevation programmatically but at the cost of rebuilding almost the whole tree when it reaches or leaves the 1st page.
Any insights would be appreciated.

How do I get a GridView inside a TabBarView?

I want to achieve following layout in a flutter app:
App bar
Text widget
Row of chip widgets
Tab bar with three labels
Three tab views with each one ElevatedButton and a GridView.
The debugger starts bleeding once I try to place the GridView inside the tab view. The debugger complains about 'hasSize' etc.
As far as I know the problem is that I use GridView inside SingleChildScrollView. After that I tried many things, using CustomScrollView and slivers. But it got uglier and uglier. I used SingleChildScrollView because I want the view to be scrollable as far as the GridView goes.
I would appreciate it if someone who did something similar guided me to the right direction.
Here's an image of what I try to get:

How to prevent widgets from being hidden behind the system status bar

So I am creating a new flutter widget and I am unable to understand how my app looks because of the space on top of the screen in my emulator,
As you can see there is a shaded area on top and my widgets are under it, is there any way to remove it?
Use Safe Area.
SafeArea is basically a glorified Padding widget. If you wrap another widget with SafeArea, it adds any necessary padding needed to keep your widget from being blocked by the system status bar, notches, holes, rounded corners, and other "creative" features by manufacturers.
Check this link for more.
Wrap your code with the SafeArea.
more info about SafeArea class

MaterialBanner is showing above SliverAppBar

I want to use MaterialBanner with SliverAppBar and wanted it to be displayed below the SliverAppBar like this: Banners - Material Design.
It is working fine with AppBar However, with SliverAppBar, it is displaying above the SliverAppBar. Is there a way to display it without placing it inside the Scaffold body?
You can run the DartPad here.
It seems like this behaviour is a recorded on-going issue.
Here's the issue I've created:
MaterialBanner appears above SliverAppBar
and here's the related issue:
MaterialBanner updates

How to disable animation at the edges of PageView?

I want users to scroll between pages in PageView, but I don't want to show them an animation when they try to scroll before first and after last page. I can switch between colorful animation, black animation and no scrolling, but I could not find any possibility to disable the animation at all.
If there is no such possibility, how can I change the color of that animation or make it transparent at least?
Based on your screenshot, I can say that you are using BouncingScrollPhysics for your PageView. This behavior is commonly used by iOS devices. Nonetheless, I have also reviewed the entire source code you have provided here.
What went wrong
You have added PageView without accompanying it with a Scaffold or Material widget at the top level that's why the background behind the children of the PageView is color black.
https://dartpad.dev/c709e410d0a68248ac5b387b3bc6af93
From the documentation:
Scaffold implements the basic material design visual layout structure.
Without this widget, you'll notice that your app may occupy the entire screen of your device, including the notification bar, because it (PageView) does not know where is the status bar is located in the screen.
What you can do
I noticed that all of the children added inside the PageView has individual Scaffold and AppBar, it's not really necessary to nest scaffolds and you may want to use TabBarView instead of PageView, and let the parent widget handle the AppBar changes via TabController.
But if you think it'll cost you too much effort to refactor, feel free to review the following options that require minimal changes which will suit your needs:
Option 1. You can wrap your widget inside a Scaffold widget.
https://dartpad.dev/4620ff91444353f5e000d2063594bd96
Option 2. Given that nesting Scaffold widgets is not a good practice, you can just use the plain Material widget to wrap your PageView with children wrapped with Scaffold widget.
https://dartpad.dev/43f8730e5592ce1f96193fc01f08a29c
These solutions will change the background color of the PageView from black to white.
Option 3. If you really want to get rid of the animation, the easiest way to hack it is changing your scroll physics:
physics: ClampingScrollPhysics(),
However, this still has a glowing or ripple effect when you try to swipe at the end of the screen.
To further get rid of this effect, I'll share with you these SO answers:
How to remove scroll glow? (works for Android)
How to remove overscroll on ios? (works for iOS)
Further reading
https://api.flutter.dev/flutter/widgets/ScrollPhysics-class.html
https://medium.com/flutter-community/custom-scroll-physics-in-flutter-3224dd9e9b41