How to change PageView scroll physics without rebuilding widget in Flutter - flutter

I'm not even sure if this is possible, but I want to change the physics from PageScrollPhysics to NeverScrollableScrollPhysics and back again without having to rebuild the PageView.
This is because I'm using it to render images that can be zoomed and the rebuild causes a blank image to appear before it loads again.

ValueNotifier Listener Builder can solve your problem, it will rebuild only child widget if value change.
For more details - ValueNotifierListenerBuilder

Related

Flutter Recreating the Hero Transition replacing Navigator with a custom Animator

Looking at the Flutter Hero Transition, it appears to move the tagged Widgets to an Overlay class that exists in all Navigator Widgets but sits above the main content in the stack.
If this is correct, it allows the Hero to widgets to still respond to the Route scope and its animators but exist above the actual route content. How is this actually done efficiently? Surely this involves taking an entire Widget and storing it in a state for the duration of the animation. That Widget still has to respond to intrinsic responses from its original position such as slivers responding to active scroll actions.
Recreating this could be done with state management but I wondered how the standard hero actually does this. It seems like Widgets are effectively duplicated and then conditionally rendered on the screen defaulting to the overlay during the route animation and swapping out the original widget with an Offstage or similar. Is this how it is done?
The reason for trying to understand it is the need to replicate this behaviour in situations where Navigator is not an effective use case for a transition taking place internally on a page. I built an accordion style navigator but still want a hero transition to take place on the AppBar / NavigationBar. I know that this could be done with Navigator but it doesn't suit the use case. I could also predefine the AppBar content for each internal navigator state of the accordion but that is a lot of additional code.

Flutter - How to Rebuild the SiverList without also rebuilding the SliverAppBar?

If I can't use a FutureBuilder inside a CustomScrollView how I can rebuild only the SliverList without also rebuilding the SliverAppBar?
I'm doing an app similar to Youtube, so like Youtube I have several buttons with the categories inside a ListView in the SliverAppBar area (Example in the image below) and a SliverList with the videos, but currently everything inside the CustomScrollView is rebuilt when I click on a category button. And the ListView inside the SliverAppBar always goes back to position 0 after rebuilding it instead of staying in the same position like Youtube.
The ideal result would be just rebuilding the SliverList. Or at least keep the ListView position (on the SliverAppBar) in the same position that was before rebuilding. How that can be done?

Is there a way to stop scrolling programmatically after the dragging started in Flutter?

What I need is basically to stop scrolling at a certain time without rebuilding/setting the state of the scrollable widget.
I know I can disable scrolling by using a boolean variable and setting state to switch between ScrollablePhysics like following as many people suggested:
physics: _canScroll ? ScrollPhysics() : NeverScrollableScrollPhysics(),
However, I don't want to call setState() and rebuild the children of the scrollable widget.
You can't change the physics without calling setState() because the UI has to update after changing the physics. If rebuilding those widgets are too cpu intensive for your case then consider using ListView.builder() or adding cacheExtent

Unwanted animation while scrolling down the ListView.builder in Flutter

I have listview.builder widget which have several ListView.builder and GridView.count with scrollDirection:Axis.horizontal inside of it. All the data comes from the services and I am using FutureBuilder to fetch them. My problem is whenever I scroll the main ListView.builder,other listview items comes with animation(items comes from left, from right). Specially if I scroll fast. I didn't use any animation, and I don't have any idea about the problem, maybe its rebuilding everytime I scroll the lisview, but I am using AutomaticKeepAliveClientMixin for main ListView. Do you have any idea? Thanks for reading.
This question might be duplicate, I solved my problem using this answer: https://stackoverflow.com/a/57984979/10025471
The problem is everytime I scroll the listview, it's children rebuilding again and again. So I convert to stateful widget all of the children and I added AutomaticKeepAliveClientMixin to all of them. Now, there is no unwanted animation, and redundant rebuild

How to remove a widget from the screen without rebuilding the whole page in flutter

Lets say i have a button and a container , and i want the container to disappear when i press the button.
Without rebuilding a new page, is this possible ? or is rebuilding the whole page is better?.
It's not possible to do it without setState but rebuilding the entire view might not be necessary.
The scope of setState is the current widget so if you encapsulate just the controls involved in this operation in a separated widget, only this tree will be recreated and not the entire view.