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

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.

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.

Flutter Draggable widget that can be clicked or dragged to move to DragTarget

I am trying to create a small test that allows a user to click or drag a Draggable or Container to move it to a DragTarget. The best example I can think of for this would be how Duolingo allows for their users to click a word and automatically move it to the first location of a sentence to a certain target, then the app checks if the sequence is correct.
For those who are unfamiliar with how Duolingo uses this, I'll explain what I would like to do here. I would like to have 3 Draggables (call them A, B, and C), and 3 DragTargets. When a letter is clicked it will move to the leftmost empty DragTarget, however, the letter could also be dragged to the location as well. If a Draggable is clicked while inside the DragTarget it will return to its original location, or it could be dragged to switch spots with another filled DragTarget.
I hope that explained my goal well. If not please ask for more details and I can try to edit and provide them.
Thanks
What could work is to use the onDragStarted: () {} voidCallback which will be similar to a button click. You could use A Stack() and wrap the Draggables with an AnimatedPositioned() widget. To which field to move can propably be determined using If statements.

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?

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.