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

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?

Related

Dart/Flutter: change content of container on tab in ListView

I am currently trying to create something like a TabBar. I created a horizontal ListView which should work as the TabBar and I my goal is, that one row fills itself with a list that contains the cards for the Tab I clicked on and refreshes when I click on another one. Is there a way to do that? It should look like this:
Reference Picture
Did you look at Work with tabs, an introduction to TabBar, TabBarView and DefaultTabController?
You could also create it from scratch using a ListView with a Card wrapped in a GestureDetector or a ListTile, and detect taps on onTap, which would set the selected data and update state using setState.

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.

ExpansionTile - how to collapse other tiles, hide keyboard on press

I'm new to Flutter, trying to build my first app.
my main app body contains a one level ExpansionTile list, which can be filterable by a searchbar.
I'm trying to implement the following behavior -
after a user press a tile to reveal the expanded info
1. the keyboard, if present, should hide
2. previously open tile if expanded should collapse
I have tried using GestureDetector on the root widget with on tap function taking focus, but it does not detect tapping on tiles.
using expansionList onExpansionChanged seems logical but i don't understand how to use it
advice will be greatly appreciated..

android - Why does view.bringToFront() doenst work in custom Listview case?

I am making a custom listview, in that data is dynamically changing after sometime. this part and click event part of list and list's button is working fine.I have to show some specific row on the top according to text.
I am using view.bringToFront() for showing that row in front. It is not working. How can i do this?? I want if(StatusText.get(position).equalsIgnoreCase("chat request")) if i check this method then this row come to front as top row of the list.
How can I do this?
bringToFront() change the view's z order in the tree, so it's on top of other sibling views (pay attention: Z-order) In your case you should resort your data and call notifyDataChanged for your adapter
I think you can use relative layout with listview and list item layout.Make Listitem layout invisible.After calling that method just make the visiblity of that listitem layout to View.VISIBLE as you are using relative layout you can position the list item layout to top bottom center or anywer.