How to save scroll position in react-infinite-scroll-component from another page back to infinite-scroll page? - react-infinite-scroll-component

I use react-infinite-scroll-component to infinite fetch data in pageA and save the scrollY position in parameter or localstorage and click router.push(url) change to pageB.
But when I go back to pageA and use the saved parameter of scrollY to scroll to the position I want, the component does not scroll to the position I want.
Does it has a way to do this when using infinite-scroll?

Related

Flutter: PageView seems to ignore PageController's page property after setState

I'm having the following problem: My library easy_image_viewer has a request to add swipe-to-dismiss. I implemented it using the Dismissible widget. However, when the user zooms in on an image, I noticed I had to find a way to "deactivate" the Dismissible widget because otherwise the user can't pan around on the zoomed-in image. I solved that by using setState and a dismissDirection variable on the state that can be either none or down.
Now for the weird part: Whenever I call setState and the dismissDirection changes, the PageView jumps back to the first item. I've tried using AutomaticKeepAliveClientMixin, but to no avail.
The code can be found here: https://github.com/thesmythgroup/easy_image_viewer/tree/pagecontroller_problem_demo
Simply run the app (example/lib/main.dart), tap on Show Multiple Images (Simple), swipe to the second image and use pinch & zoom to zoom in. You'll notice it jumps back to the first image. What am I doing wrong?
Instead of changing the dismiss direction you can use confirmDismiss i opened a PR for you to check here

Swipe page over another page in flutter

I want create verticaly scrolling pageView and want change page change animation, I want swiping page come over another page. How can I do this?

Flutter using Draggable & DragTarget: While dragging update the "childWhenDragging" location as candidate drags over a dragtarget

I've been able to get this to work while dragging a ListItem around in a ListView. With each ListItem wrapped as a DragTarget I update attributes of the 'candidates[0]' & trigger a screen refresh. This moves the "selected" list tile (selected via childWhenDragging) to each listtile as I pass over a dragtarget.
The goal is to drag between tabs though. Currently I can select an item, then use another finger to switch tabs, then switch back to the original tab. This keeps the item on the first tab selected using childWhenDragging. However, if I switch tabs and swap with an item there, between tabs, the swap works but I am losing the childWhenDragging "selection".
This did have to add AutomaticKeepAliveClientMixin to the item being dragged to keep things working between tabs... not sure why the childWhenDragging quits working when I swap with item on 2nd tab.
At the moment I'm using a single array of Items as a class { int tab, int order, Widget child } & choose what to display per tab based on the tab/order attributes.
Adding 'addAutomaticKeepAlives' to the ListViews didn't help. Ideas?

Can I assign an onClick() function to my various SliverPersistentHeader to jump to that position in the CustomScrollView?

I have successfully built my CustomScrollView() that contains SliverGrid() items and SliverPersistentHeaders() which are pinned. I want a click on any SliverPersistentHeader() to scroll to the exact position. I want to know if this is possible in flutter.

Hero animation after deleting element from list - how to stop it trying to animate a blank box?

Basic setup:
I have a ListView builder that generates a list based on a List.
Each element of the list is wrapped with a Hero() widget and had a unique tag.
List renders just fine, GestureDetector initiates a 'Details' page on tap, with same widget wrapped in Hero() widget with same tag, and animates just fine, as does the 'return' animation on Navigator.pop();
The problem is...
I allow the user to delete the list element on the details page, if they do this, when I close the page with .pop(), the Hero animation basically animates a blank box of the original size back over the top of the newly rendered (and shorter list) making it look like there are 'blanks' in the list.
I originally thought it was an issue with the state of the list and the list not updating, but lots of checking proves the list is being updated, and the widgets are being re-rendered exactly as they should, it's just that there's a blank box sitting on top of them because of the Hero animation caused by the deletion.
Remove the Hero() widget wrapper and it works fine.
Break the 'tag' so it no longer matches between the two pages and it's fine (but obviously doesn't animate when navigating to the Details page).
Obviously I can stop deletion and move to the main page to avoid the animation at all or remove the animation, but is there a 'correct' way yo do this?
Anyone else hitting the same?
What a quite interesting case you got there. Is your details page statefull? One thing i imagine you could do is to setState after the deletion, so in the rebuild the deleted hero widget wouldn't exists anymore, and when poping navigation the hero navigation won't be fired because it doesn't exist anymore.
What if instead of deleting the item from the list on the pop-up up page, when the user clicks delete on the pop-up page you send a flag/parameter back to the parent page to delete the record. That way the animation will play fine as the pop-up closes, and then you can animate out the deleted record.